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

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


The following commit(s) were added to refs/heads/master by this push:
     new 28c338b52d [IOTDB-4119] Fix concurrency problem when auto create 
schemaCacheEntry in updateLastCache method (#6974)
28c338b52d is described below

commit 28c338b52dbc5dd66e63b450bebeb48b59557bc4
Author: ZhangHongYin <[email protected]>
AuthorDate: Sat Aug 13 22:44:54 2022 +0800

    [IOTDB-4119] Fix concurrency problem when auto create schemaCacheEntry in 
updateLastCache method (#6974)
---
 .../iotdb/db/metadata/cache/DataNodeSchemaCache.java      | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git 
a/server/src/main/java/org/apache/iotdb/db/metadata/cache/DataNodeSchemaCache.java
 
b/server/src/main/java/org/apache/iotdb/db/metadata/cache/DataNodeSchemaCache.java
index 17cf02d7c3..4afca8a361 100644
--- 
a/server/src/main/java/org/apache/iotdb/db/metadata/cache/DataNodeSchemaCache.java
+++ 
b/server/src/main/java/org/apache/iotdb/db/metadata/cache/DataNodeSchemaCache.java
@@ -151,11 +151,16 @@ public class DataNodeSchemaCache {
     PartialPath seriesPath = measurementPath.transformToPartialPath();
     SchemaCacheEntry entry = cache.getIfPresent(seriesPath);
     if (null == entry) {
-      entry =
-          new SchemaCacheEntry(
-              (MeasurementSchema) measurementPath.getMeasurementSchema(),
-              measurementPath.isUnderAlignedEntity());
-      cache.put(seriesPath, entry);
+      synchronized (cache) {
+        entry = cache.getIfPresent(seriesPath);
+        if (null == entry) {
+          entry =
+              new SchemaCacheEntry(
+                  (MeasurementSchema) measurementPath.getMeasurementSchema(),
+                  measurementPath.isUnderAlignedEntity());
+          cache.put(seriesPath, entry);
+        }
+      }
     }
 
     DataNodeLastCacheManager.updateLastCache(

Reply via email to