[ENGINE] Inc store reference before reading segments info
If a tragic even happens while we are reading the segments info from the store the store might have been closed concurrently. We had this behavior before and was lost in a refactoring.
This commit is contained in:
parent
274da68040
commit
565ee05cda
|
@ -654,8 +654,15 @@ public class InternalEngine extends Engine {
|
|||
}
|
||||
|
||||
}
|
||||
// reread the last committed segment infos
|
||||
/*
|
||||
* we have to inc-ref the store here since if the engine is closed by a tragic event
|
||||
* we don't acquire the write lock and wait until we have exclusive access. This might also
|
||||
* dec the store reference which can essentially close the store and unless we can inc the reference
|
||||
* we can't use it.
|
||||
*/
|
||||
store.incRef();
|
||||
try {
|
||||
// reread the last committed segment infos
|
||||
lastCommittedSegmentInfos = store.readLastCommittedSegmentsInfo();
|
||||
} catch (Throwable e) {
|
||||
if (isClosed.get() == false) {
|
||||
|
@ -664,6 +671,8 @@ public class InternalEngine extends Engine {
|
|||
throw new FlushFailedEngineException(shardId, e);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
store.decRef();
|
||||
}
|
||||
} catch (FlushFailedEngineException ex) {
|
||||
maybeFailEngine("flush", ex);
|
||||
|
|
Loading…
Reference in New Issue