From d6a8984be63a18abe17f818d560277d6cc1597bb Mon Sep 17 00:00:00 2001 From: Yannick Welsch Date: Fri, 21 Jul 2017 14:20:03 +0200 Subject: [PATCH] Make sure shard is not closed when updating local checkpoint If a primary shard is relocated, and then subsequently closed, there is a short window where ReplicationOperation could access the closed shard (engine is not shut down yet) and, because it does not know that the shard was relocated, try to update the local checkpoint, tripping an assertion in GlobalCheckPointTracker that a local checkpoint cannot be updated if it's not in primary mode. --- .../main/java/org/elasticsearch/index/shard/IndexShard.java | 3 ++- 1 file changed, 2 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 c03492f382f..76c6791ac44 100644 --- a/core/src/main/java/org/elasticsearch/index/shard/IndexShard.java +++ b/core/src/main/java/org/elasticsearch/index/shard/IndexShard.java @@ -477,7 +477,7 @@ public class IndexShard extends AbstractIndexShardComponent implements IndicesCl */ getEngine().restoreLocalCheckpointFromTranslog(); getEngine().fillSeqNoGaps(newPrimaryTerm); - updateLocalCheckpointForShard(currentRouting.allocationId().getId(), + getEngine().seqNoService().updateLocalCheckpointForShard(currentRouting.allocationId().getId(), getEngine().seqNoService().getLocalCheckpoint()); primaryReplicaSyncer.accept(this, new ActionListener() { @Override @@ -1661,6 +1661,7 @@ public class IndexShard extends AbstractIndexShardComponent implements IndicesCl */ public void updateLocalCheckpointForShard(final String allocationId, final long checkpoint) { verifyPrimary(); + verifyNotClosed(); getEngine().seqNoService().updateLocalCheckpointForShard(allocationId, checkpoint); }