You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ja...@apache.org on 2020/11/11 03:39:09 UTC

[iotdb] branch REBug updated: fix reconnect bug

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

jackietien pushed a commit to branch REBug
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/REBug by this push:
     new 6e629c6  fix reconnect bug
6e629c6 is described below

commit 6e629c612d6d53d6c5b4237a936f8dd30c259461
Author: JackieTien97 <Ja...@foxmail.com>
AuthorDate: Wed Nov 11 11:38:51 2020 +0800

    fix reconnect bug
---
 .../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 6ca49c4..34f0588 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;
@@ -695,7 +695,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);
@@ -1719,7 +1720,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);