Skip to content

Commit

Permalink
Acquire seacher on closing engine should throw ACE (#33331)
Browse files Browse the repository at this point in the history
Closes #33330
  • Loading branch information
dnhatn authored Sep 5, 2018
1 parent b697f48 commit 41839cf
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2014,7 +2014,9 @@ public Searcher acquireSearcher(String source, SearcherScope scope) {
/* Acquire order here is store -> manager since we need
* to make sure that the store is not closed before
* the searcher is acquired. */
store.incRef();
if (store.tryIncRef() == false) {
throw new AlreadyClosedException(shardId + " store is closed", failedEngine.get());
}
Releasable releasable = store::decRef;
try {
final ReferenceManager<IndexSearcher> referenceManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5020,6 +5020,11 @@ public void testLastRefreshCheckpoint() throws Exception {
assertThat(engine.lastRefreshedCheckpoint(), equalTo(engine.getLocalCheckpoint()));
}

public void testAcquireSearcherOnClosingEngine() throws Exception {
engine.close();
expectThrows(AlreadyClosedException.class, () -> engine.acquireSearcher("test"));
}

private static void trimUnsafeCommits(EngineConfig config) throws IOException {
final Store store = config.getStore();
final TranslogConfig translogConfig = config.getTranslogConfig();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ public void testSyncerSendsOffCorrectDocuments() throws Exception {
closeShards(shard);
}

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

0 comments on commit 41839cf

Please sign in to comment.