You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by qi...@apache.org on 2023/04/07 01:40:33 UTC
[iotdb] branch rel/1.1 updated: [To rel/1.1] Adapt insert data by 0.13 client (#9545)
This is an automated email from the ASF dual-hosted git repository.
qiaojialin pushed a commit to branch rel/1.1
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/rel/1.1 by this push:
new 78ee634f17 [To rel/1.1] Adapt insert data by 0.13 client (#9545)
78ee634f17 is described below
commit 78ee634f17adc27787ee50693dc1c02643bc4f03
Author: Haonan <hh...@outlook.com>
AuthorDate: Fri Apr 7 09:40:27 2023 +0800
[To rel/1.1] Adapt insert data by 0.13 client (#9545)
---
docs/UserGuide/Reference/Common-Config-Manual.md | 9 +++++++++
docs/zh/UserGuide/Reference/Common-Config-Manual.md | 9 +++++++++
.../src/assembly/resources/conf/iotdb-common.properties | 5 +++++
.../main/java/org/apache/iotdb/db/conf/IoTDBConfig.java | 10 ++++++++++
.../java/org/apache/iotdb/db/conf/IoTDBDescriptor.java | 5 +++++
.../java/org/apache/iotdb/db/mpp/common/SessionInfo.java | 14 ++++++++++++++
.../apache/iotdb/db/mpp/plan/execution/QueryExecution.java | 7 ++++++-
.../org/apache/iotdb/db/query/control/SessionManager.java | 6 +++++-
8 files changed, 63 insertions(+), 2 deletions(-)
diff --git a/docs/UserGuide/Reference/Common-Config-Manual.md b/docs/UserGuide/Reference/Common-Config-Manual.md
index 5e6538fe9c..0c95f5a317 100644
--- a/docs/UserGuide/Reference/Common-Config-Manual.md
+++ b/docs/UserGuide/Reference/Common-Config-Manual.md
@@ -781,6 +781,15 @@ Different configuration parameters take effect in the following three ways:
|Default| 5000 |
|Effective| After restarting system |
+* 0.13\_data\_insert\_adapt
+
+|Name| 0.13\_data\_insert\_adapt |
+|:---:|:----------------------------------------------------------------------|
+|Description| if using v0.13 client to insert data, set this configuration to true. |
+|Type| Boolean |
+|Default| false |
+|Effective| After restarting system |
+
* upgrade\_thread\_count
| Name | upgrade\_thread\_count |
diff --git a/docs/zh/UserGuide/Reference/Common-Config-Manual.md b/docs/zh/UserGuide/Reference/Common-Config-Manual.md
index 78883d6711..0068927b3c 100644
--- a/docs/zh/UserGuide/Reference/Common-Config-Manual.md
+++ b/docs/zh/UserGuide/Reference/Common-Config-Manual.md
@@ -829,6 +829,15 @@ IoTDB ConfigNode 和 DataNode 的公共配置参数位于 `conf` 目录下。
| 默认值 | 5000 |
| 改后生效方式 | 重启服务生效 |
+* 0.13\_data\_insert\_adapt
+
+| 名字 | 0.13\_data\_insert\_adapt |
+| :----------: |:----------------------------------|
+| 描述 | 如果 0.13 版本客户端进行写入,需要将此配置项设置为 true |
+| 类型 | Boolean |
+| 默认值 | false |
+| 改后生效方式 | 重启服务生效 |
+
* upgrade\_thread\_count
| 名字 | upgrade\_thread\_count |
diff --git a/node-commons/src/assembly/resources/conf/iotdb-common.properties b/node-commons/src/assembly/resources/conf/iotdb-common.properties
index 934f81e736..9f6fc4c526 100644
--- a/node-commons/src/assembly/resources/conf/iotdb-common.properties
+++ b/node-commons/src/assembly/resources/conf/iotdb-common.properties
@@ -528,6 +528,11 @@ cluster_name=defaultCluster
# Datatype: int
# recovery_log_interval_in_ms=5000
+# If using v0.13 client to insert data, please set this configuration to true.
+# Notice: if using v0.13/v1.0 client or setting Client Version to V_0_13 manually, enable this config will disable insert redirection.
+# Datatype: boolean
+# 0.13_data_insert_adapt=false
+
# When there exists old version(v2) TsFile, how many thread will be set up to perform upgrade tasks, 1 by default.
# Set to 1 when less than or equal to 0.
# Datatype: int
diff --git a/server/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java b/server/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java
index 8bd7128679..35baad5505 100644
--- a/server/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java
+++ b/server/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java
@@ -752,6 +752,8 @@ public class IoTDBConfig {
// if enable partial insert, one measurement failure will not impact other measurements
private boolean enablePartialInsert = true;
+ private boolean enable13DataInsertAdapt = false;
+
/**
* Used to estimate the memory usage of text fields in a UDF query. It is recommended to set this
* value to be slightly larger than the average length of all text records.
@@ -1844,6 +1846,14 @@ public class IoTDBConfig {
this.enablePartialInsert = enablePartialInsert;
}
+ public boolean isEnable13DataInsertAdapt() {
+ return enable13DataInsertAdapt;
+ }
+
+ public void setEnable13DataInsertAdapt(boolean enable13DataInsertAdapt) {
+ this.enable13DataInsertAdapt = enable13DataInsertAdapt;
+ }
+
public int getCompactionThreadCount() {
return compactionThreadCount;
}
diff --git a/server/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java b/server/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java
index 469dd66c15..773f8732ff 100644
--- a/server/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java
+++ b/server/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java
@@ -681,6 +681,11 @@ public class IoTDBDescriptor {
properties.getProperty(
"enable_partial_insert", String.valueOf(conf.isEnablePartialInsert()))));
+ conf.setEnable13DataInsertAdapt(
+ Boolean.parseBoolean(
+ properties.getProperty(
+ "0.13_data_insert_adapt", String.valueOf(conf.isEnable13DataInsertAdapt()))));
+
int rpcSelectorThreadNum =
Integer.parseInt(
properties.getProperty(
diff --git a/server/src/main/java/org/apache/iotdb/db/mpp/common/SessionInfo.java b/server/src/main/java/org/apache/iotdb/db/mpp/common/SessionInfo.java
index 5d7645c78e..3183c50b11 100644
--- a/server/src/main/java/org/apache/iotdb/db/mpp/common/SessionInfo.java
+++ b/server/src/main/java/org/apache/iotdb/db/mpp/common/SessionInfo.java
@@ -18,6 +18,7 @@
*/
package org.apache.iotdb.db.mpp.common;
+import org.apache.iotdb.commons.conf.IoTDBConstant.ClientVersion;
import org.apache.iotdb.tsfile.utils.ReadWriteIOUtils;
import java.io.DataOutputStream;
@@ -29,12 +30,21 @@ public class SessionInfo {
private final String userName;
private final String zoneId;
+ private ClientVersion version = ClientVersion.V_1_0;
+
public SessionInfo(long sessionId, String userName, String zoneId) {
this.sessionId = sessionId;
this.userName = userName;
this.zoneId = zoneId;
}
+ public SessionInfo(long sessionId, String userName, String zoneId, ClientVersion version) {
+ this.sessionId = sessionId;
+ this.userName = userName;
+ this.zoneId = zoneId;
+ this.version = version;
+ }
+
public long getSessionId() {
return sessionId;
}
@@ -47,6 +57,10 @@ public class SessionInfo {
return zoneId;
}
+ public ClientVersion getVersion() {
+ return version;
+ }
+
public static SessionInfo deserializeFrom(ByteBuffer buffer) {
long sessionId = ReadWriteIOUtils.readLong(buffer);
String userName = ReadWriteIOUtils.readString(buffer);
diff --git a/server/src/main/java/org/apache/iotdb/db/mpp/plan/execution/QueryExecution.java b/server/src/main/java/org/apache/iotdb/db/mpp/plan/execution/QueryExecution.java
index 4c2d0c23bf..3588cc4462 100644
--- a/server/src/main/java/org/apache/iotdb/db/mpp/plan/execution/QueryExecution.java
+++ b/server/src/main/java/org/apache/iotdb/db/mpp/plan/execution/QueryExecution.java
@@ -23,6 +23,7 @@ import org.apache.iotdb.common.rpc.thrift.TSStatus;
import org.apache.iotdb.commons.client.IClientManager;
import org.apache.iotdb.commons.client.async.AsyncDataNodeInternalServiceClient;
import org.apache.iotdb.commons.client.sync.SyncDataNodeInternalServiceClient;
+import org.apache.iotdb.commons.conf.IoTDBConstant;
import org.apache.iotdb.commons.exception.IoTDBException;
import org.apache.iotdb.commons.service.metric.enums.PerformanceOverviewMetrics;
import org.apache.iotdb.db.conf.IoTDBConfig;
@@ -618,8 +619,12 @@ public class QueryExecution implements IQueryExecution {
}
// collect redirect info to client for writing
+ // if 0.13_data_insert_adapt is true and ClientVersion is NOT V_1_0, stop returning redirect
+ // info to client
if (analysis.getStatement() instanceof InsertBaseStatement
- && !analysis.isFinishQueryAfterAnalyze()) {
+ && !analysis.isFinishQueryAfterAnalyze()
+ && (!config.isEnable13DataInsertAdapt()
+ || IoTDBConstant.ClientVersion.V_1_0.equals(context.getSession().getVersion()))) {
InsertBaseStatement insertStatement = (InsertBaseStatement) analysis.getStatement();
List<TEndPoint> redirectNodeList =
insertStatement.collectRedirectInfo(analysis.getDataPartitionInfo());
diff --git a/server/src/main/java/org/apache/iotdb/db/query/control/SessionManager.java b/server/src/main/java/org/apache/iotdb/db/query/control/SessionManager.java
index e2bd2a0c5c..93198c34da 100644
--- a/server/src/main/java/org/apache/iotdb/db/query/control/SessionManager.java
+++ b/server/src/main/java/org/apache/iotdb/db/query/control/SessionManager.java
@@ -351,7 +351,11 @@ public class SessionManager implements SessionManagerMBean {
}
public SessionInfo getSessionInfo(IClientSession session) {
- return new SessionInfo(session.getId(), session.getUsername(), session.getZoneId().getId());
+ return new SessionInfo(
+ session.getId(),
+ session.getUsername(),
+ session.getZoneId().getId(),
+ session.getClientVersion());
}
@Override