From bef92053e833de401e20fce5609a282844e7465d Mon Sep 17 00:00:00 2001 From: Armin Braun Date: Tue, 30 Mar 2021 16:09:32 +0200 Subject: [PATCH] Fix Tripped Assertion on Resync during Node Shutdown We can have a race here where the closed check passes and then we concurrently to a shard close try to fail the shard also. Previously this was covered by the catch below the changed code that would just ignore the already-closed exception but with #69949 we're now forking to the generic pool for this logic and thus have to handle the exception in the callback as well. --- .../main/java/org/elasticsearch/index/shard/IndexShard.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 292467ccd7fe0..48082f1ed86ab 100644 --- a/server/src/main/java/org/elasticsearch/index/shard/IndexShard.java +++ b/server/src/main/java/org/elasticsearch/index/shard/IndexShard.java @@ -597,7 +597,11 @@ public void onFailure(Exception e) { if (state == IndexShardState.CLOSED) { // ignore, shutting down } else { - failShard("exception during primary-replica resync", e); + try { + failShard("exception during primary-replica resync", e); + } catch (AlreadyClosedException ace) { + // okay, the index was deleted + } } } });