You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ej...@apache.org on 2020/04/30 05:11:56 UTC
[incubator-iotdb] 01/01: fix merge stuck bug
This is an automated email from the ASF dual-hosted git repository.
ejttianyu pushed a commit to branch fix_merge_stuck_bug
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git
commit c598cb32b0635a9200c27e393ed4f7b1370821e5
Author: EJTTianyu <16...@qq.com>
AuthorDate: Thu Apr 30 13:10:15 2020 +0800
fix merge stuck bug
---
.../db/engine/storagegroup/StorageGroupProcessor.java | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/StorageGroupProcessor.java b/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/StorageGroupProcessor.java
index 4a6037b..1f226ac 100755
--- a/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/StorageGroupProcessor.java
+++ b/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/StorageGroupProcessor.java
@@ -1383,7 +1383,6 @@ public class StorageGroupProcessor {
@SuppressWarnings("squid:S1141")
private void updateMergeModification(TsFileResource seqFile) {
- seqFile.getWriteQueryLock().writeLock().lock();
try {
// remove old modifications and write modifications generated during merge
seqFile.removeModFile();
@@ -1401,8 +1400,6 @@ public class StorageGroupProcessor {
} catch (IOException e) {
logger.error("{} cannot clean the ModificationFile of {} after merge", storageGroupName,
seqFile.getFile(), e);
- } finally {
- seqFile.getWriteQueryLock().writeLock().unlock();
}
}
@@ -1432,7 +1429,15 @@ public class StorageGroupProcessor {
for (int i = 0; i < seqFiles.size(); i++) {
TsFileResource seqFile = seqFiles.get(i);
- mergeLock.writeLock().lock();
+ while (!seqFile.getWriteQueryLock().writeLock().tryLock() || !mergeLock.writeLock()
+ .tryLock()) {
+ if (seqFile.getWriteQueryLock().writeLock().isHeldByCurrentThread()) {
+ seqFile.getWriteQueryLock().writeLock().unlock();
+ }
+ if(mergeLock.writeLock().isHeldByCurrentThread()) {
+ mergeLock.writeLock().unlock();
+ }
+ }
try {
updateMergeModification(seqFile);
if (i == seqFiles.size() - 1) {
@@ -1443,6 +1448,7 @@ public class StorageGroupProcessor {
}
} finally {
mergeLock.writeLock().unlock();
+ seqFile.getWriteQueryLock().writeLock().unlock();
}
}
logger.info("{} a merge task ends", storageGroupName);