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

shuwenwei pushed a commit to branch fixConcurrentIssues-0518
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit 5a8b842d537500636313762b0f635dad9999cc3a
Author: shuwenwei <[email protected]>
AuthorDate: Mon May 18 11:07:05 2026 +0800

    Fix query TVList snapshot race during working memtable reads
---
 .../schemaengine/schemaregion/utils/ResourceByPathUtils.java   | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/utils/ResourceByPathUtils.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/utils/ResourceByPathUtils.java
index 6a2e554900e..ee5cd1a02a7 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/utils/ResourceByPathUtils.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/utils/ResourceByPathUtils.java
@@ -171,11 +171,17 @@ public abstract class ResourceByPathUtils {
         list.getQueryContextSet().add(context);
         tvListQueryMap.put(list, list.rowCount());
       } else {
-        if (list.isSorted() || list.getQueryContextSet().isEmpty()) {
+        boolean isSorted;
+        int rowCount;
+        synchronized (list) {
+          isSorted = list.isSorted();
+          rowCount = list.rowCount();
+        }
+        if (isSorted || list.getQueryContextSet().isEmpty()) {
           LOGGER.debug(
               "Working MemTable - add current query context to mutable 
TVList's query list when it's sorted or no other query on it");
           list.getQueryContextSet().add(context);
-          tvListQueryMap.put(list, list.rowCount());
+          tvListQueryMap.put(list, rowCount);
         } else {
           /*
            * +----------------------+

Reply via email to