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 committed Sep 6, 2018
1 parent 91925c3 commit ac3d321
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 @@ -2094,7 +2094,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 @@ -5038,6 +5038,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 ac3d321

Please sign in to comment.