This is an automated email from the ASF dual-hosted git repository.
xuekaifeng 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 6e5e209 Fix dead lock in setDataTTL method (#4738)
6e5e209 is described below
commit 6e5e2095f9e888ce3561b47f55ec0c47ab79865c
Author: SilverNarcissus <[email protected]>
AuthorDate: Mon Jan 10 14:06:37 2022 +0800
Fix dead lock in setDataTTL method (#4738)
* fix dead lock
* pretty format
---
.../db/engine/storagegroup/VirtualStorageGroupProcessor.java | 12 ++++++++++--
1 file changed, 10 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..d272bf3 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,16 @@ 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() {