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 2020/11/11 07:00:21 UTC

[iotdb] branch rel/0.11 updated: [To rel/0.11] Fix reconnect cannot get queryId bug (#2005)

This is an automated email from the ASF dual-hosted git repository.

qiaojialin pushed a commit to branch rel/0.11
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/rel/0.11 by this push:
     new 9f9dbd7  [To rel/0.11] Fix reconnect cannot get queryId bug (#2005)
9f9dbd7 is described below

commit 9f9dbd7e3493df6c6a882d218ea3d894fbc418fe
Author: Jackie Tien <Ja...@foxmail.com>
AuthorDate: Wed Nov 11 14:32:03 2020 +0800

    [To rel/0.11] Fix reconnect cannot get queryId bug (#2005)
---
 .../src/main/java/org/apache/iotdb/db/service/TSServiceImpl.java  | 8 +++++---
 session/src/main/java/org/apache/iotdb/session/Session.java       | 6 ++++++
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/server/src/main/java/org/apache/iotdb/db/service/TSServiceImpl.java b/server/src/main/java/org/apache/iotdb/db/service/TSServiceImpl.java
index 2e4c247..0d2ab43 100644
--- a/server/src/main/java/org/apache/iotdb/db/service/TSServiceImpl.java
+++ b/server/src/main/java/org/apache/iotdb/db/service/TSServiceImpl.java
@@ -27,12 +27,12 @@ import java.time.ZoneId;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
-import java.util.HashSet;
 import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.CopyOnWriteArraySet;
 import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.TimeUnit;
@@ -696,7 +696,8 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
       }
       // put it into the corresponding Set
 
-      statementId2QueryId.computeIfAbsent(statementId, k -> new HashSet<>()).add(queryId);
+      statementId2QueryId.computeIfAbsent(statementId, k -> new CopyOnWriteArraySet<>())
+          .add(queryId);
 
       if (plan instanceof AuthorPlan) {
         plan.setLoginUserName(username);
@@ -1720,7 +1721,8 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
   @Override
   public long requestStatementId(long sessionId) {
     long statementId = statementIdGenerator.incrementAndGet();
-    sessionId2StatementId.computeIfAbsent(sessionId, s -> new HashSet<>()).add(statementId);
+    sessionId2StatementId.computeIfAbsent(sessionId, s -> new CopyOnWriteArraySet<>())
+        .add(statementId);
     return statementId;
   }
 
diff --git a/session/src/main/java/org/apache/iotdb/session/Session.java b/session/src/main/java/org/apache/iotdb/session/Session.java
index 91e8e94..d4abb13 100644
--- a/session/src/main/java/org/apache/iotdb/session/Session.java
+++ b/session/src/main/java/org/apache/iotdb/session/Session.java
@@ -959,6 +959,8 @@ public class Session {
     } catch (TException e) {
       if (reconnect()) {
         try {
+          execReq.setSessionId(sessionId);
+          execReq.setStatementId(statementId);
           execResp = client.executeQueryStatement(execReq);
         } catch (TException tException) {
           throw new IoTDBConnectionException(tException);
@@ -990,6 +992,8 @@ public class Session {
     } catch (TException e) {
       if (reconnect()) {
         try {
+          execReq.setSessionId(sessionId);
+          execReq.setStatementId(statementId);
           execResp = client.executeUpdateStatement(execReq);
         } catch (TException tException) {
           throw new IoTDBConnectionException(tException);
@@ -1026,6 +1030,8 @@ public class Session {
     } catch (TException e) {
       if (reconnect()) {
         try {
+          execReq.setSessionId(sessionId);
+          execReq.setStatementId(statementId);
           execResp = client.executeRawDataQuery(execReq);
         } catch (TException tException) {
           throw new IoTDBConnectionException(tException);