improve lock logic when recovering to reduce chance of throwable slipping and causing no release of lock
This commit is contained in:
parent
15b9e00888
commit
47b0750171
|
@ -945,10 +945,10 @@ public class RobinEngine extends AbstractIndexShardComponent implements Engine {
|
||||||
failEngine(e);
|
failEngine(e);
|
||||||
throw new OptimizeFailedEngineException(shardId, e);
|
throw new OptimizeFailedEngineException(shardId, e);
|
||||||
} finally {
|
} finally {
|
||||||
|
rwl.readLock().unlock();
|
||||||
if (indexWriter != null && indexWriter.getConfig().getMergePolicy() instanceof EnableMergePolicy) {
|
if (indexWriter != null && indexWriter.getConfig().getMergePolicy() instanceof EnableMergePolicy) {
|
||||||
((EnableMergePolicy) indexWriter.getConfig().getMergePolicy()).disableMerge();
|
((EnableMergePolicy) indexWriter.getConfig().getMergePolicy()).disableMerge();
|
||||||
}
|
}
|
||||||
rwl.readLock().unlock();
|
|
||||||
optimizeMutex.set(false);
|
optimizeMutex.set(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1031,18 +1031,9 @@ public class RobinEngine extends AbstractIndexShardComponent implements Engine {
|
||||||
}
|
}
|
||||||
|
|
||||||
rwl.writeLock().lock();
|
rwl.writeLock().lock();
|
||||||
Translog.Snapshot phase3Snapshot;
|
Translog.Snapshot phase3Snapshot = null;
|
||||||
try {
|
try {
|
||||||
phase3Snapshot = translog.snapshot(phase2Snapshot);
|
phase3Snapshot = translog.snapshot(phase2Snapshot);
|
||||||
} catch (Exception e) {
|
|
||||||
--disableFlushCounter;
|
|
||||||
rwl.writeLock().unlock();
|
|
||||||
phase1Snapshot.release();
|
|
||||||
phase2Snapshot.release();
|
|
||||||
throw new RecoveryEngineException(shardId, 3, "Snapshot failed", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
recoveryHandler.phase3(phase3Snapshot);
|
recoveryHandler.phase3(phase3Snapshot);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RecoveryEngineException(shardId, 3, "Execution failed", e);
|
throw new RecoveryEngineException(shardId, 3, "Execution failed", e);
|
||||||
|
@ -1051,7 +1042,9 @@ public class RobinEngine extends AbstractIndexShardComponent implements Engine {
|
||||||
rwl.writeLock().unlock();
|
rwl.writeLock().unlock();
|
||||||
phase1Snapshot.release();
|
phase1Snapshot.release();
|
||||||
phase2Snapshot.release();
|
phase2Snapshot.release();
|
||||||
phase3Snapshot.release();
|
if (phase3Snapshot != null) {
|
||||||
|
phase3Snapshot.release();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue