Skip to content

Commit

Permalink
Hold store reference in InternalEngine#performActionWithDirectoryRead…
Browse files Browse the repository at this point in the history
…er(...) (#123010)

This method gets called from `InternalEngine#resolveDocVersion(...)`, which gets during indexing (via `InternalEngine.index(...)`).

When `InternalEngine.index(...)` gets invoked, the InternalEngine only ensures that it holds a ref to the engine via Engine#acquireEnsureOpenRef(), but this doesn't ensure whether it holds a reference to the store.

Closes #122974

* Update docs/changelog/123010.yaml
  • Loading branch information
martijnvg authored Feb 21, 2025
1 parent edcc218 commit 8d1f5d3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
6 changes: 6 additions & 0 deletions docs/changelog/123010.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pr: 123010
summary: Hold store reference in `InternalEngine#performActionWithDirectoryReader(...)`
area: Engine
type: bug
issues:
- 122974
3 changes: 0 additions & 3 deletions muted-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -314,9 +314,6 @@ tests:
issue: https://github.com/elastic/elasticsearch/issues/122913
- class: org.elasticsearch.xpack.search.AsyncSearchSecurityIT
issue: https://github.com/elastic/elasticsearch/issues/122940
- class: org.elasticsearch.action.admin.indices.create.ShrinkIndexIT
method: testShrinkIndexPrimaryTerm
issue: https://github.com/elastic/elasticsearch/issues/122974
- class: org.elasticsearch.test.apmintegration.TracesApmIT
method: testApmIntegration
issue: https://github.com/elastic/elasticsearch/issues/122129
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3470,7 +3470,9 @@ protected long getPreCommitSegmentGeneration() {
<T> T performActionWithDirectoryReader(SearcherScope scope, CheckedFunction<DirectoryReader, T, IOException> action)
throws EngineException {
assert scope == SearcherScope.INTERNAL : "performActionWithDirectoryReader(...) isn't prepared for external usage";
assert store.hasReferences();
if (store.tryIncRef() == false) {
throw new AlreadyClosedException(shardId + " store is closed", failedEngine.get());
}
try {
ReferenceManager<ElasticsearchDirectoryReader> referenceManager = getReferenceManager(scope);
ElasticsearchDirectoryReader acquire = referenceManager.acquire();
Expand All @@ -3486,6 +3488,8 @@ <T> T performActionWithDirectoryReader(SearcherScope scope, CheckedFunction<Dire
ensureOpen(ex); // throw EngineCloseException here if we are already closed
logger.error("failed to perform action with directory reader", ex);
throw new EngineException(shardId, "failed to perform action with directory reader", ex);
} finally {
store.decRef();
}
}
}

0 comments on commit 8d1f5d3

Please sign in to comment.