From 23093adcb98c74952c9bf46f1a282e332fd857c9 Mon Sep 17 00:00:00 2001 From: Jason Tedor Date: Mon, 18 Sep 2017 07:48:08 -0400 Subject: [PATCH] Update global checkpoint with permit after recovery After recovery completes from a primary, we now update the local knowledge on the primary of the global checkpoint on the recovery target. However if this occurs concurrently with a relocation, an assertion could trip that we are no longer in primary mode. As this local knowledge should only be tracked when we are in primary mode, updating this local knowledge should be done under a permit. This commit causes that to be the case. Relates #26666 --- .../elasticsearch/indices/recovery/RecoverySourceHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/java/org/elasticsearch/indices/recovery/RecoverySourceHandler.java b/core/src/main/java/org/elasticsearch/indices/recovery/RecoverySourceHandler.java index 01d971ba32599..c717e29353b65 100644 --- a/core/src/main/java/org/elasticsearch/indices/recovery/RecoverySourceHandler.java +++ b/core/src/main/java/org/elasticsearch/indices/recovery/RecoverySourceHandler.java @@ -477,7 +477,7 @@ public void finalizeRecovery(final long targetLocalCheckpoint) { runUnderPrimaryPermit(() -> shard.markAllocationIdAsInSync(request.targetAllocationId(), targetLocalCheckpoint)); final long globalCheckpoint = shard.getGlobalCheckpoint(); cancellableThreads.execute(() -> recoveryTarget.finalizeRecovery(globalCheckpoint)); - shard.updateGlobalCheckpointForShard(request.targetAllocationId(), globalCheckpoint); + runUnderPrimaryPermit(() -> shard.updateGlobalCheckpointForShard(request.targetAllocationId(), globalCheckpoint)); if (request.isPrimaryRelocation()) { logger.trace("performing relocation hand-off");