Unverified 提交 04d83310 authored 作者: Andrei Tokar's avatar Andrei Tokar 提交者: GitHub

Merge pull request #1633 from h2database/Issue_1632

Issue_1632
...@@ -294,10 +294,6 @@ public class MVStore implements AutoCloseable { ...@@ -294,10 +294,6 @@ public class MVStore implements AutoCloseable {
private final int autoCompactFillRate; private final int autoCompactFillRate;
private long autoCompactLastFileOpCount; private long autoCompactLastFileOpCount;
/**
* Simple lock to ensure that no more than one compaction runs at any given time
*/
private boolean compactInProgress;
private volatile IllegalStateException panicException; private volatile IllegalStateException panicException;
...@@ -1964,19 +1960,16 @@ public class MVStore implements AutoCloseable { ...@@ -1964,19 +1960,16 @@ public class MVStore implements AutoCloseable {
// it might go into deadlock with concurrent database closure // it might go into deadlock with concurrent database closure
// and attempt to stop this thread. // and attempt to stop this thread.
try { try {
if (storeLock.tryLock(10, TimeUnit.MILLISECONDS)) { if (!storeLock.isHeldByCurrentThread() &&
storeLock.tryLock(10, TimeUnit.MILLISECONDS)) {
try { try {
if (!compactInProgress) { ArrayList<Chunk> old = findOldChunks(targetFillRate, write);
compactInProgress = true; if (old == null || old.isEmpty()) {
ArrayList<Chunk> old = findOldChunks(targetFillRate, write); return false;
if (old == null || old.isEmpty()) {
return false;
}
compactRewrite(old);
return true;
} }
compactRewrite(old);
return true;
} finally { } finally {
compactInProgress = false;
storeLock.unlock(); storeLock.unlock();
} }
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论