Use internal searcher for all indexing related operations in the engine
The changes introduced in missed two places where an internal searcher should be used.
@@ -538,7 +538,7 @@ public class InternalEngine extends Engine {
} else {
// load from index
assert incrementIndexVersionLookup();
- try (Searcher searcher = acquireSearcher("load_seq_no")) {
+ try (Searcher searcher = acquireSearcher("load_seq_no", SearcherScope.INTERNAL)) {
DocIdAndSeqNo docAndSeqNo = VersionsAndSeqNoResolver.loadDocIdAndSeqNo(searcher.reader(), op.uid());
if (docAndSeqNo == null) {
status = OpVsLuceneDocStatus.LUCENE_DOC_NOT_FOUND;
@@ -965,7 +965,7 @@ public class InternalEngine extends Engine {
throw new AssertionError("doc [" + index.type() + "][" + index.id() + "] exists in version map (version " + versionValue + ")");
}
} else {
- try (Searcher searcher = acquireSearcher("assert doc doesn't exist")) {
+ try (Searcher searcher = acquireSearcher("assert doc doesn't exist", SearcherScope.INTERNAL)) {
final long docsWithId = searcher.searcher().count(new TermQuery(index.uid()));
if (docsWithId > 0) {
throw new AssertionError("doc [" + index.type() + "][" + index.id() + "] exists [" + docsWithId + "] times in index");
@@ -1672,7 +1672,9 @@ public class InternalEngine extends Engine {
assert rwl.isWriteLockedByCurrentThread() || failEngineLock.isHeldByCurrentThread() : "Either the write lock must be held or the engine must be currently be failing itself";
try {
this.versionMap.clear();
+ if (internalSearcherManager != null) {
internalSearcherManager.removeListener(versionMap);
+ }
try {
IOUtils.close(externalSearcherManager, internalSearcherManager);
} catch (Exception e) {
