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/03/23 01:32:16 UTC

[incubator-iotdb] branch fix_concurrent_error created (now da1f872)

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

qiaojialin pushed a change to branch fix_concurrent_error
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git.


      at da1f872  fix sqlArgumentsList concurrent modification error

This branch includes the following new commits:

     new da1f872  fix sqlArgumentsList concurrent modification error

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.



[incubator-iotdb] 01/01: fix sqlArgumentsList concurrent modification error

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

qiaojialin pushed a commit to branch fix_concurrent_error
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git

commit da1f872cd5cdb19397e42b83908571cf1fbd5793
Author: qiaojialin <64...@qq.com>
AuthorDate: Mon Mar 23 09:31:58 2020 +0800

    fix sqlArgumentsList concurrent modification error
---
 .../org/apache/iotdb/db/service/TSServiceImpl.java     | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 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 a8afa57..ec55f5d 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
@@ -133,7 +133,7 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
   private static final int DELETE_SIZE = 50;
   private static final String ERROR_PARSING_SQL =
       "meet error while parsing SQL to physical plan: {}";
-  public static Vector<SqlArgument> sqlArgumentsList = new Vector<>();
+  public static final Vector<SqlArgument> sqlArgumentsList = new Vector<>();
 
   protected Planner processor;
   protected IPlanExecutor executor;
@@ -508,9 +508,11 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
                 sessionIdUsernameMap.get(req.getSessionId()));
         long endTime = System.currentTimeMillis();
         sqlArgument = new SqlArgument(resp, physicalPlan, statement, startTime, endTime);
-        sqlArgumentsList.add(sqlArgument);
-        if (sqlArgumentsList.size() > MAX_SIZE) {
-          sqlArgumentsList.subList(0, DELETE_SIZE).clear();
+        synchronized (sqlArgumentsList) {
+          sqlArgumentsList.add(sqlArgument);
+          if (sqlArgumentsList.size() > MAX_SIZE) {
+            sqlArgumentsList.subList(0, DELETE_SIZE).clear();
+          }
         }
         return resp;
       } else {
@@ -567,9 +569,11 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
           sessionIdUsernameMap.get(req.getSessionId()));
       long endTime = System.currentTimeMillis();
       sqlArgument = new SqlArgument(resp, physicalPlan, statement, startTime, endTime);
-      sqlArgumentsList.add(sqlArgument);
-      if (sqlArgumentsList.size() > MAX_SIZE) {
-        sqlArgumentsList.subList(0, DELETE_SIZE).clear();
+      synchronized (sqlArgumentsList) {
+        sqlArgumentsList.add(sqlArgument);
+        if (sqlArgumentsList.size() > MAX_SIZE) {
+          sqlArgumentsList.subList(0, DELETE_SIZE).clear();
+        }
       }
       return resp;
     } catch (ParseCancellationException e) {