Skip to content

Commit a517758

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 a789583 commit a517758

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ private OpVsLuceneDocStatus compareOpToLuceneDocBasedOnSeqNo(final Operation op)
525525
} else {
526526
// load from index
527527
assert incrementIndexVersionLookup();
528-
try (Searcher searcher = acquireSearcher("load_seq_no")) {
528+
try (Searcher searcher = acquireSearcher("load_seq_no", SearcherScope.INTERNAL)) {
529529
DocIdAndSeqNo docAndSeqNo = VersionsAndSeqNoResolver.loadDocIdAndSeqNo(searcher.reader(), op.uid());
530530
if (docAndSeqNo == null) {
531531
status = OpVsLuceneDocStatus.LUCENE_DOC_NOT_FOUND;
@@ -952,7 +952,7 @@ private boolean assertDocDoesNotExist(final Index index, final boolean allowDele
952952
throw new AssertionError("doc [" + index.type() + "][" + index.id() + "] exists in version map (version " + versionValue + ")");
953953
}
954954
} else {
955-
try (Searcher searcher = acquireSearcher("assert doc doesn't exist")) {
955+
try (Searcher searcher = acquireSearcher("assert doc doesn't exist", SearcherScope.INTERNAL)) {
956956
final long docsWithId = searcher.searcher().count(new TermQuery(index.uid()));
957957
if (docsWithId > 0) {
958958
throw new AssertionError("doc [" + index.type() + "][" + index.id() + "] exists [" + docsWithId + "] times in index");
@@ -1659,7 +1659,9 @@ protected final void closeNoLock(String reason, CountDownLatch closedLatch) {
16591659
assert rwl.isWriteLockedByCurrentThread() || failEngineLock.isHeldByCurrentThread() : "Either the write lock must be held or the engine must be currently be failing itself";
16601660
try {
16611661
this.versionMap.clear();
1662-
internalSearcherManager.removeListener(versionMap);
1662+
if (internalSearcherManager != null) {
1663+
internalSearcherManager.removeListener(versionMap);
1664+
}
16631665
try {
16641666
IOUtils.close(externalSearcherManager, internalSearcherManager);
16651667
} catch (Exception e) {

0 commit comments

Comments
 (0)