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:40:44 UTC

[iotdb] branch RE11Bug created (now a6c05bb)

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

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


      at a6c05bb  fix reconnect bugf

This branch includes the following new commits:

     new a6c05bb  fix reconnect bugf

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[iotdb] 01/01: fix reconnect bugf

Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit a6c05bb3729d2750ff9a2e7bf77b7cdb9da8dce3
Author: JackieTien97 <Ja...@foxmail.com>
AuthorDate: Wed Nov 11 11:40:20 2020 +0800

    fix reconnect bugf
---
 .../src/main/java/org/apache/iotdb/db/service/TSServiceImpl.java   | 7 +++++--
 session/src/main/java/org/apache/iotdb/session/Session.java        | 6 ++++++
 2 files changed, 11 insertions(+), 2 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..2a76cc2 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
@@ -33,6 +33,7 @@ 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 +697,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 +1722,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);