Browse Source

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
Jason Tedor 8 years ago
parent
commit
23093adcb9

+ 1 - 1
core/src/main/java/org/elasticsearch/indices/recovery/RecoverySourceHandler.java

@@ -477,7 +477,7 @@ public class RecoverySourceHandler {
         runUnderPrimaryPermit(() -> shard.markAllocationIdAsInSync(request.targetAllocationId(), targetLocalCheckpoint));
         runUnderPrimaryPermit(() -> shard.markAllocationIdAsInSync(request.targetAllocationId(), targetLocalCheckpoint));
         final long globalCheckpoint = shard.getGlobalCheckpoint();
         final long globalCheckpoint = shard.getGlobalCheckpoint();
         cancellableThreads.execute(() -> recoveryTarget.finalizeRecovery(globalCheckpoint));
         cancellableThreads.execute(() -> recoveryTarget.finalizeRecovery(globalCheckpoint));
-        shard.updateGlobalCheckpointForShard(request.targetAllocationId(), globalCheckpoint);
+        runUnderPrimaryPermit(() -> shard.updateGlobalCheckpointForShard(request.targetAllocationId(), globalCheckpoint));
 
 
         if (request.isPrimaryRelocation()) {
         if (request.isPrimaryRelocation()) {
             logger.trace("performing relocation hand-off");
             logger.trace("performing relocation hand-off");