Concurrent calls to refresh might result in "dangling" searchers, closes #823.
This commit is contained in:
parent
1280512097
commit
db1dcaded3
|
@ -128,6 +128,8 @@ public class RobinEngine extends AbstractIndexShardComponent implements Engine {
|
|||
|
||||
private final Object[] dirtyLocks;
|
||||
|
||||
private final Object refreshMutex = new Object();
|
||||
|
||||
private final ApplySettings applySettings = new ApplySettings();
|
||||
|
||||
@Inject public RobinEngine(ShardId shardId, @IndexSettings Settings indexSettings, IndexSettingsService indexSettingsService,
|
||||
|
@ -577,8 +579,11 @@ public class RobinEngine extends AbstractIndexShardComponent implements Engine {
|
|||
throw new EngineClosedException(shardId);
|
||||
}
|
||||
try {
|
||||
// we need to obtain a mutex here, to make sure we don't leave dangling readers
|
||||
// we could have used an AtomicBoolean#compareAndSet, but, then we might miss refresh requests
|
||||
// compared to on going ones
|
||||
synchronized (refreshMutex) {
|
||||
if (dirty || refresh.force()) {
|
||||
// we eagerly set dirty to false so we won't miss refresh requests
|
||||
dirty = false;
|
||||
AcquirableResource<ReaderSearcherHolder> current = nrtResource;
|
||||
IndexReader newReader = current.resource().reader().reopen(true);
|
||||
|
@ -589,6 +594,7 @@ public class RobinEngine extends AbstractIndexShardComponent implements Engine {
|
|||
current.markForClose();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (AlreadyClosedException e) {
|
||||
// an index writer got replaced on us, ignore
|
||||
} catch (Exception e) {
|
||||
|
|
Loading…
Reference in New Issue