From 88fa571322009d643a1be831f7bd5b385dbeed95 Mon Sep 17 00:00:00 2001 From: Armin Braun Date: Wed, 31 Mar 2021 10:42:54 +0200 Subject: [PATCH] Fix Tripped Assertion on Resync during Node Shutdown (#71062) 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 2b8c038c20cca..21b4b879fb0ce 100644 --- a/server/src/main/java/org/elasticsearch/index/shard/IndexShard.java +++ b/server/src/main/java/org/elasticsearch/index/shard/IndexShard.java @@ -592,7 +592,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 + } } } });