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/01/09 07:26:47 UTC

[incubator-iotdb] branch fix_remove_resource_bug created (now 381afdc)

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

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


      at 381afdc  fix concurrent modification

This branch includes the following new commits:

     new 381afdc  fix concurrent modification

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 concurrent modification

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

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

commit 381afdcd1319f7f840a939ec060db0af237afb1a
Author: qiaojialin <64...@qq.com>
AuthorDate: Thu Jan 9 15:26:20 2020 +0800

    fix concurrent modification
---
 .../org/apache/iotdb/db/query/control/QueryFileManager.java    | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/server/src/main/java/org/apache/iotdb/db/query/control/QueryFileManager.java b/server/src/main/java/org/apache/iotdb/db/query/control/QueryFileManager.java
index 5c58351..ad2cfd2 100644
--- a/server/src/main/java/org/apache/iotdb/db/query/control/QueryFileManager.java
+++ b/server/src/main/java/org/apache/iotdb/db/query/control/QueryFileManager.java
@@ -19,6 +19,7 @@
 package org.apache.iotdb.db.query.control;
 
 import java.util.HashSet;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -67,17 +68,18 @@ public class QueryFileManager {
   }
 
   private void addUsedFilesForQuery(long queryId, List<TsFileResource> resources) {
-    for (TsFileResource tsFileResource : resources) {
-      // the file may change from open to closed within the few statements, so the initial status
-      // should be recorded to ensure consistency
+    Iterator<TsFileResource> iterator = resources.iterator();
+    while (iterator.hasNext()) {
+      TsFileResource tsFileResource = iterator.next();
       boolean isClosed = tsFileResource.isClosed();
       addFilePathToMap(queryId, tsFileResource, isClosed);
+
       // this file may be deleted just before we lock it
       if (tsFileResource.isDeleted()) {
         Map<Long, Set<TsFileResource>> pathMap = !isClosed ? unsealedFilePathsMap : sealedFilePathsMap;
         pathMap.get(queryId).remove(tsFileResource);
         FileReaderManager.getInstance().decreaseFileReaderReference(tsFileResource, isClosed);
-        resources.remove(tsFileResource);
+        iterator.remove();
       }
     }
   }