diff --git a/server/src/main/java/org/elasticsearch/index/shard/IndexShard.java b/server/src/main/java/org/elasticsearch/index/shard/IndexShard.java index ce82e146ef5d4..cd9faa8761623 100644 --- a/server/src/main/java/org/elasticsearch/index/shard/IndexShard.java +++ b/server/src/main/java/org/elasticsearch/index/shard/IndexShard.java @@ -3222,12 +3222,17 @@ private class RefreshPendingLocationListener implements ReferenceManager.Refresh @Override public void beforeRefresh() { - lastWriteLocation = getEngine().getTranslogLastWriteLocation(); + try { + lastWriteLocation = getEngine().getTranslogLastWriteLocation(); + } catch (AlreadyClosedException exc) { + // shard is closed - no location is fine + lastWriteLocation = null; + } } @Override public void afterRefresh(boolean didRefresh) { - if (didRefresh) { + if (didRefresh && lastWriteLocation != null) { pendingRefreshLocation.updateAndGet(pendingLocation -> { if (pendingLocation == null || pendingLocation.compareTo(lastWriteLocation) <= 0) { return null; diff --git a/x-pack/plugin/async-search/src/test/java/org/elasticsearch/xpack/search/AsyncSearchActionIT.java b/x-pack/plugin/async-search/src/test/java/org/elasticsearch/xpack/search/AsyncSearchActionIT.java index f4592fd5593d2..2f8a2ad120aa4 100644 --- a/x-pack/plugin/async-search/src/test/java/org/elasticsearch/xpack/search/AsyncSearchActionIT.java +++ b/x-pack/plugin/async-search/src/test/java/org/elasticsearch/xpack/search/AsyncSearchActionIT.java @@ -170,7 +170,6 @@ public void testTermsAggregation() throws Exception { } } - @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/55792") public void testRestartAfterCompletion() throws Exception { final AsyncSearchResponse initial; try (SearchResponseIterator it = @@ -208,7 +207,6 @@ public void testDeleteCleanupIndex() throws Exception { ensureTaskRemoval(response.getId()); } - @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/55792") public void testCleanupOnFailure() throws Exception { final AsyncSearchResponse initial; try (SearchResponseIterator it =