Skip to content

Commit 5fb70b2

Browse files
committed
Use internal searcher for all indexing related operations in the engine
The changes introduced in #26972 missed two places where an internal searcher should be used.
1 parent faa5faf commit 5fb70b2

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

core/src/main/java/org/elasticsearch/index/engine/InternalEngine.java

+5-3
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ private OpVsLuceneDocStatus compareOpToLuceneDocBasedOnSeqNo(final Operation op)
538538
} else {
539539
// load from index
540540
assert incrementIndexVersionLookup();
541-
try (Searcher searcher = acquireSearcher("load_seq_no")) {
541+
try (Searcher searcher = acquireSearcher("load_seq_no", SearcherScope.INTERNAL)) {
542542
DocIdAndSeqNo docAndSeqNo = VersionsAndSeqNoResolver.loadDocIdAndSeqNo(searcher.reader(), op.uid());
543543
if (docAndSeqNo == null) {
544544
status = OpVsLuceneDocStatus.LUCENE_DOC_NOT_FOUND;
@@ -965,7 +965,7 @@ private boolean assertDocDoesNotExist(final Index index, final boolean allowDele
965965
throw new AssertionError("doc [" + index.type() + "][" + index.id() + "] exists in version map (version " + versionValue + ")");
966966
}
967967
} else {
968-
try (Searcher searcher = acquireSearcher("assert doc doesn't exist")) {
968+
try (Searcher searcher = acquireSearcher("assert doc doesn't exist", SearcherScope.INTERNAL)) {
969969
final long docsWithId = searcher.searcher().count(new TermQuery(index.uid()));
970970
if (docsWithId > 0) {
971971
throw new AssertionError("doc [" + index.type() + "][" + index.id() + "] exists [" + docsWithId + "] times in index");
@@ -1672,7 +1672,9 @@ protected final void closeNoLock(String reason, CountDownLatch closedLatch) {
16721672
assert rwl.isWriteLockedByCurrentThread() || failEngineLock.isHeldByCurrentThread() : "Either the write lock must be held or the engine must be currently be failing itself";
16731673
try {
16741674
this.versionMap.clear();
1675-
internalSearcherManager.removeListener(versionMap);
1675+
if (internalSearcherManager != null) {
1676+
internalSearcherManager.removeListener(versionMap);
1677+
}
16761678
try {
16771679
IOUtils.close(externalSearcherManager, internalSearcherManager);
16781680
} catch (Exception e) {

0 commit comments

Comments
 (0)