Skip to content

Commit ac3d321

Browse files
committed
Acquire seacher on closing engine should throw ACE (#33331)
Closes #33330
1 parent 91925c3 commit ac3d321

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -2094,7 +2094,9 @@ public Searcher acquireSearcher(String source, SearcherScope scope) {
20942094
/* Acquire order here is store -> manager since we need
20952095
* to make sure that the store is not closed before
20962096
* the searcher is acquired. */
2097-
store.incRef();
2097+
if (store.tryIncRef() == false) {
2098+
throw new AlreadyClosedException(shardId + " store is closed", failedEngine.get());
2099+
}
20982100
Releasable releasable = store::decRef;
20992101
try {
21002102
final ReferenceManager<IndexSearcher> referenceManager;

server/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java

+5
Original file line numberDiff line numberDiff line change
@@ -5038,6 +5038,11 @@ public void testLastRefreshCheckpoint() throws Exception {
50385038
assertThat(engine.lastRefreshedCheckpoint(), equalTo(engine.getLocalCheckpoint()));
50395039
}
50405040

5041+
public void testAcquireSearcherOnClosingEngine() throws Exception {
5042+
engine.close();
5043+
expectThrows(AlreadyClosedException.class, () -> engine.acquireSearcher("test"));
5044+
}
5045+
50415046
private static void trimUnsafeCommits(EngineConfig config) throws IOException {
50425047
final Store store = config.getStore();
50435048
final TranslogConfig translogConfig = config.getTranslogConfig();

server/src/test/java/org/elasticsearch/index/shard/PrimaryReplicaSyncerTests.java

-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ public void testSyncerSendsOffCorrectDocuments() throws Exception {
125125
closeShards(shard);
126126
}
127127

128-
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/33330")
129128
public void testSyncerOnClosingShard() throws Exception {
130129
IndexShard shard = newStartedShard(true);
131130
AtomicBoolean syncActionCalled = new AtomicBoolean();

0 commit comments

Comments
 (0)