diff --git a/server/src/test/java/org/elasticsearch/index/shard/IndexShardTests.java b/server/src/test/java/org/elasticsearch/index/shard/IndexShardTests.java index df6b0fce944..9bef8974563 100644 --- a/server/src/test/java/org/elasticsearch/index/shard/IndexShardTests.java +++ b/server/src/test/java/org/elasticsearch/index/shard/IndexShardTests.java @@ -1117,11 +1117,14 @@ public class IndexShardTests extends IndexShardTestCase { final String replicaAllocationId = replicaShard.routingEntry().allocationId().getId(); primaryShard.updateLocalCheckpointForShard(replicaAllocationId, replicaLocalCheckpoint); - // initialize the local knowledge on the primary of the global checkpoint on the replica shard + // initialize the local knowledge on the primary of the persisted global checkpoint on the replica shard final int replicaGlobalCheckpoint = randomIntBetween(Math.toIntExact(SequenceNumbers.NO_OPS_PERFORMED), Math.toIntExact(primaryShard.getLastKnownGlobalCheckpoint())); primaryShard.updateGlobalCheckpointForShard(replicaAllocationId, replicaGlobalCheckpoint); + // initialize the local knowledge on the primary of the persisted global checkpoint on the primary + primaryShard.updateGlobalCheckpointForShard(shardRouting.allocationId().getId(), primaryShard.getLastKnownGlobalCheckpoint()); + // simulate a background maybe sync; it should only run if the knowledge on the replica of the global checkpoint lags the primary primaryShard.maybeSyncGlobalCheckpoint("test"); assertThat(