From d6cc5588560e91281985914000793cd62e694858 Mon Sep 17 00:00:00 2001 From: Suraj Singh Date: Mon, 20 Mar 2023 10:29:48 -0700 Subject: [PATCH] [Segment Replication] Handle update target cp for relocating primary Signed-off-by: Suraj Singh --- .../main/java/org/opensearch/index/shard/IndexShard.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/server/src/main/java/org/opensearch/index/shard/IndexShard.java b/server/src/main/java/org/opensearch/index/shard/IndexShard.java index d54cd2c2c6574..13d049d155e11 100644 --- a/server/src/main/java/org/opensearch/index/shard/IndexShard.java +++ b/server/src/main/java/org/opensearch/index/shard/IndexShard.java @@ -2725,9 +2725,11 @@ public void updateGlobalCheckpointForShard(final String allocationId, final long * @param visibleCheckpoint the visible checkpoint */ public void updateVisibleCheckpointForShard(final String allocationId, final ReplicationCheckpoint visibleCheckpoint) { - assert assertPrimaryMode(); - verifyNotClosed(); - replicationTracker.updateVisibleCheckpointForShard(allocationId, visibleCheckpoint); + // Update target replication checkpoint only when in active primary mode + if (shardRouting.primary() && replicationTracker.isPrimaryMode()) { + verifyNotClosed(); + replicationTracker.updateVisibleCheckpointForShard(allocationId, visibleCheckpoint); + } } /**