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

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

commit b573de7e3fa446fe413de620ce2432e53926932e
Author: 151250176 <[email protected]>
AuthorDate: Mon Jan 10 11:01:49 2022 +0800

    fix dead lock
---
 .../engine/storagegroup/VirtualStorageGroupProcessor.java   | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git 
a/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/VirtualStorageGroupProcessor.java
 
b/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/VirtualStorageGroupProcessor.java
index df72353..296830c 100755
--- 
a/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/VirtualStorageGroupProcessor.java
+++ 
b/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/VirtualStorageGroupProcessor.java
@@ -2925,8 +2925,17 @@ public class VirtualStorageGroupProcessor {
   }
 
   public void setDataTTL(long dataTTL) {
-    this.dataTTL = dataTTL;
-    checkFilesTTL();
+    // Check files ttl will lock tsfile resource firstly and then lock tsfile.
+    // This lock order is conflict with tsfile creation in insert method, so 
we get a potential dead
+    // lock
+    // Add this write lock to avoid dead lock above.
+    writeLock("setDataTTL");
+    try {
+      this.dataTTL = dataTTL;
+      checkFilesTTL();
+    } finally {
+      writeUnlock();
+    }
   }
 
   public List<TsFileResource> getSequenceFileTreeSet() {

Reply via email to