From ebdae09df3137e3dee3a7556de0909d2223ea96b Mon Sep 17 00:00:00 2001 From: Jason Tedor Date: Wed, 28 Jun 2017 08:42:13 -0400 Subject: [PATCH] Do not swallow exception when relocating When relocating a shard before changing the state to relocated, we verify that a relocation is a still taking place. Yet, this can throw an exception if the relocation is in fact no longer valid. Sadly, we were swallowing the exception in this situation. This commit allows such an exception to bubble up after safely releasing resources. --- .../java/org/elasticsearch/index/shard/IndexShard.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/org/elasticsearch/index/shard/IndexShard.java b/core/src/main/java/org/elasticsearch/index/shard/IndexShard.java index 10fe3ccfd76..5d39292a46d 100644 --- a/core/src/main/java/org/elasticsearch/index/shard/IndexShard.java +++ b/core/src/main/java/org/elasticsearch/index/shard/IndexShard.java @@ -545,7 +545,12 @@ public class IndexShard extends AbstractIndexShardComponent implements IndicesCl changeState(IndexShardState.RELOCATED, reason); } } catch (final Exception e) { - getEngine().seqNoService().releasePrimaryContext(); + try { + getEngine().seqNoService().releasePrimaryContext(); + } catch (final Exception inner) { + e.addSuppressed(inner); + } + throw e; } }); } catch (TimeoutException e) {