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.
This commit is contained in:
Yannick Welsch 2017-07-21 14:20:03 +02:00
parent f1f1725fcf
commit d6a8984be6
1 changed files with 2 additions and 1 deletions

View File

@ -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<ResyncTask>() {
@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);
}