Topic Bug?
Bug Description use SubscribeDemo code of JAVA to get data and the tags line is the same
when I use consumer.poll(Duration.ofMillis(100)),return data is like follow: {"id":19501,"name":"nt.pcaihla65aa101_sp","tagValue":-8.333332,"ts":1710832654439,"type":6} {"id":19501,"name":"nt.pcaihla65aa101_sp","tagValue":79.78789,"ts":1710832654439,"type":6} {"id":19501,"name":"nt.pcaihla65aa101_sp","tagValue":0.0,"ts":1710832654439,"type":6} {"id":19501,"name":"nt.pcaihla65aa101_sp","tagValue":0.0,"ts":1710832654439,"type":6} {"id":19501,"name":"nt.pcaihla65aa101_sp","tagValue":3.022977,"ts":1710832654439,"type":6} {"id":19501,"name":"nt.pcaihla65aa101_sp","tagValue":0.0,"ts":1710832654439,"type":6} {"id":19501,"name":"nt.pcaihla65aa101_sp","tagValue":2.3694275E-38,"ts":1710832654439,"type":6} {"id":19501,"name":"nt.pcaihla65aa101_sp","tagValue":328.96332,"ts":1710832654439,"type":6} {"id":19501,"name":"nt.pcaihla65aa101_sp","tagValue":3.59E-43,"ts":1710832654439,"type":6} {"id":19501,"name":"nt.pcaihla65aa101_sp","tagValue":68.0,"ts":1710832654439,"type":6} {"id":19501,"name":"nt.pcaihla65aa101_sp","tagValue":0.0,"ts":1710832654439,"type":6} the tags id and name is the same, but this should be different.
please provide more detail like software version, specific code
TDengine Version: 3.2.3.0
code: 使用的是你们网站上的示例代码 https://docs.taosdata.com/develop/tmq/#%E8%AE%A2%E9%98%85-topics 只做了简单的修改,如下:
public class SubscribeDemo { private static final String TOPIC = "tmq_topic"; private static final AtomicBoolean shutdown = new AtomicBoolean(false);
public static void main(String[] args) {
Timer timer = new Timer();
timer.schedule(new TimerTask() {
public void run() {
shutdown.set(true);
}
}, 3_000);
try {
// prepare
Class.forName("com.taosdata.jdbc.TSDBDriver");
String jdbcUrl = "jdbc:TAOS://127.0.0.1:6030/?user=root&password=taosdata";
Connection connection = DriverManager.getConnection(jdbcUrl);
try (Statement statement = connection.createStatement()) {
statement.executeUpdate("drop topic if exists " + TOPIC);
// create topic
statement.executeUpdate("create topic " + TOPIC + " as select * from now_tech.his_data");
}
// create consumer
Properties properties = new Properties();
properties.getProperty(TMQConstants.CONNECT_TYPE, "jni");
properties.setProperty(TMQConstants.BOOTSTRAP_SERVERS, "127.0.0.1:6030");
properties.setProperty(TMQConstants.CONNECT_USER, "root");
properties.setProperty(TMQConstants.CONNECT_PASS, "taosdata");
properties.setProperty(TMQConstants.MSG_WITH_TABLE_NAME, "true");
properties.setProperty(TMQConstants.ENABLE_AUTO_COMMIT, "true");
properties.setProperty(TMQConstants.AUTO_COMMIT_INTERVAL, "1000");
properties.setProperty(TMQConstants.GROUP_ID, "test1");
properties.setProperty(TMQConstants.CLIENT_ID, "1");
properties.setProperty(TMQConstants.AUTO_OFFSET_RESET, "earliest");
properties.setProperty(TMQConstants.VALUE_DESERIALIZER,
"com.nowtech.testtdengine.util.hisDataDeserializer");
properties.setProperty(TMQConstants.VALUE_DESERIALIZER_ENCODING, "UTF-8");
// poll data
try (TaosConsumer<HisData> consumer = new TaosConsumer<>(properties)) {
consumer.subscribe(Collections.singletonList(TOPIC));
while (!shutdown.get()) {
ConsumerRecords<HisData> hisDatas = consumer.poll(Duration.ofMillis(100));
for (ConsumerRecord<HisData> hisData : hisDatas ) {
System.out.println(hisData.value());
}
}
consumer.unsubscribe();
}
} catch (ClassNotFoundException | SQLException e) {
e.printStackTrace();
}
timer.cancel();
}
}
HisData结构如下: public class HisData { Long ts; Double tagValue; Long id; String name; Short type; }
his_data表结构如下
CREATE STABLE his_data (ts TIMESTAMP, tagValue DOUBLE) TAGS (id INT, name NCHAR(64), type SMALLINT)
该表下有大概10w个子表(但这不重要,因为即使只有两个子表问题依然存在),每个子表具有不同的ID和name,当我同时向不同子表插入具有相同ts的数据时,我使用consumer.poll(Duration.ofMillis(100));获取到的数据如下:
{"id":19501,"name":"nt.pcaihla65aa101_sp","tagValue":-8.333332,"ts":1710832654439,"type":6}
{"id":19501,"name":"nt.pcaihla65aa101_sp","tagValue":79.78789,"ts":1710832654439,"type":6}
{"id":19501,"name":"nt.pcaihla65aa101_sp","tagValue":0.0,"ts":1710832654439,"type":6}
{"id":19501,"name":"nt.pcaihla65aa101_sp","tagValue":0.0,"ts":1710832654439,"type":6}
{"id":19501,"name":"nt.pcaihla65aa101_sp","tagValue":3.022977,"ts":1710832654439,"type":6}
{"id":19501,"name":"nt.pcaihla65aa101_sp","tagValue":0.0,"ts":1710832654439,"type":6}
{"id":19501,"name":"nt.pcaihla65aa101_sp","tagValue":2.3694275E-38,"ts":1710832654439,"type":6}
{"id":19501,"name":"nt.pcaihla65aa101_sp","tagValue":328.96332,"ts":1710832654439,"type":6}
{"id":19501,"name":"nt.pcaihla65aa101_sp","tagValue":3.59E-43,"ts":1710832654439,"type":6}
{"id":19501,"name":"nt.pcaihla65aa101_sp","tagValue":68.0,"ts":1710832654439,"type":6}
{"id":19501,"name":"nt.pcaihla65aa101_sp","tagValue":0.0,"ts":1710832654439,"type":6}
它给相同ts的数据返回了相同的tags,然而这应该是不同的tags
之后我尝试使用python和C跑了一遍相同的代码,发现了相同的问题,所以我确定是订阅功能的BUG
能再发一下写入部分的代码吗?
另外,为了加快效率,可以加微信a15652223354.
暂作关闭处理,等联系上再做reopen