apache / iotdb

Apache IoTDB
https://iotdb.apache.org/
Apache License 2.0
5.52k stars 997 forks source link

重启后再次修改测点的tag发现没法按照tag做查询了 #3424

Open juice411 opened 3 years ago

juice411 commented 3 years ago

1.老版本是11.3,加了测点 2.后面升级到11.5后,在次修改测点(sql=ALTER timeseries {} UPSERT ALIAS={} TAGS(name='{}',dir='{}',exName='{}',description='{}',unit='{}') ATTRIBUTES(minValue={},maxValue={})),sessionPool.executeNonQueryStatement(sql)修改是正常提交了,但完成后根据tag查不到数据 3.实在没有办法就删除了测点 delete timeseries,重新添加测点 4.再次查询,发现可以正常了

liuzhen1207 commented 3 years ago

复现过程:

  1. bm在release 0.11.3上生成数据 bm配置文件: INSERT_MODE=session IS_CLIENT_BIND=true CLIENT_NUMBER=10 GROUP_NUMBER=1 DEVICE_NUMBER=1 SENSOR_NUMBER=6 BATCH_SIZE=1000 LOOP=10000 IS_OVERFLOW=false OPERATION_PROPORTION=1:0:0:0:0:0:0:0:0:0:0

  2. Rel 0.11.3 cli 修改序列增加tags信息 show timeseries; flush alter timeseries root.group_0.d_0.s_2 UPSERT ALIAS=alias_s2 TAGS(tag='hi',tag2='hello') ATTRIBUTES(attr1='red',attr2='blue') // 根据tag信息查询时间序列 结果正确 不报错 show timeseries root.group_0.d_0 where tag2='hello'; show timeseries root.group_0.d_0 where tag='hi'; image

  3. 重启0.11.3 或 copy 0.11.3的data到rel 0.11.4/0.11.4 cli根据tag查询序列报错 show timeseries root.group_0.d_0 where tag2='hello'; Msg: 500: The key tag2 is not a tag. image show timeseries可以看到tags信息 image

liuzhen1207 commented 3 years ago

复现过程2:

  1. bm在release 0.11.3上生成数据 同上
  2. 0.11.3 cli修改时间序列,增加tag信息 alter timeseries root.group_0.d_0.s_2 UPSERT ALIAS=alias_s2 TAGS(tag='hi') ATTRIBUTES(attr1='money') flush 3.copy 0.11.3的data到rel 0.11.4 java程序测试用例: import org.apache.iotdb.rpc.IoTDBConnectionException; import org.apache.iotdb.rpc.StatementExecutionException; import org.apache.iotdb.session.SessionDataSet.DataIterator; import org.apache.iotdb.session.pool.SessionDataSetWrapper; import org.apache.iotdb.session.pool.SessionPool; import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType; import org.apache.iotdb.session.SessionDataSet; import org.apache.iotdb.session.Session;

import java.util.ArrayList; import java.util.List; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors;

public class SessionPoolExample {

private static SessionPool pool; private static ExecutorService service; private static Session session;

public static void main(String[] args) throws StatementExecutionException, IoTDBConnectionException, InterruptedException { pool = new SessionPool("127.0.0.1", 6667, "root", "root", 3); service = Executors.newFixedThreadPool(10);

session = new Session("127.0.0.1", 6667, "root", "root");
session.open(false);
query();
Thread.sleep(1000);
pool.close();
session.close();
service.shutdown();

}

private static void query() throws IoTDBConnectionException, StatementExecutionException { SessionDataSet dataSet; String sql = "ALTER timeseries root.group_0.d_0.s_2 UPSERT ALIAS=alias_test TAGS(tag='test',dir='/data/test',exName='exTest',description='desTest',unit='unitTest') ATTRIBUTES(minValue=1,maxValue=1000)";

pool.executeNonQueryStatement(sql);
dataSet = session.executeQueryStatement("show timeseries where tag='test'");
System.out.println(dataSet.getColumnNames());
dataSet.setFetchSize(1024); // default is 10000
while (dataSet.hasNext()) {
  System.out.println(dataSet.next());
}

dataSet.closeOperationHandle();

}

} 编译,运行: javac -cp /data/lz/pr_test/rel_12/distribution/target/apache-iotdb-0.12.1-SNAPSHOT-server-bin/apache-iotdb-0.12.1-SNAPSHOT-server-bin/lib/*:. ./SessionPoolExample.java

java -cp /data/lz/pr_test/rel_12/distribution/target/apache-iotdb-0.12.1-SNAPSHOT-server-bin/apache-iotdb-0.12.1-SNAPSHOT-server-bin/lib/*:. SessionPoolExample 执行结果: image

未复现。