Skip to content

Commit 6419a2b

Browse files
Merge pull request #4686 from guoquanwu/fix/checkpoint-reset
fix: make delete operation atomic when cleaning tmp db
2 parents bd9bfe6 + 84d2a21 commit 6419a2b

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

chainbase/src/main/java/org/tron/core/db2/core/SnapshotManager.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,17 @@ private List<String> getCheckpointList() {
429429
}
430430

431431
private void deleteCheckpoint() {
432-
checkTmpStore.reset();
432+
try {
433+
Map<byte[], byte[]> hmap = new HashMap<>();
434+
for (Map.Entry<byte[], byte[]> e : checkTmpStore.getDbSource()) {
435+
hmap.put(e.getKey(), null);
436+
}
437+
if (hmap.size() != 0) {
438+
checkTmpStore.getDbSource().updateByBatch(hmap);
439+
}
440+
} catch (Exception e) {
441+
throw new TronDBException(e);
442+
}
433443
}
434444

435445
private void pruneCheckpoint() {

0 commit comments

Comments
 (0)