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 9d1ca272495e3..246729f9152db 100644 --- a/server/src/main/java/org/opensearch/index/shard/IndexShard.java +++ b/server/src/main/java/org/opensearch/index/shard/IndexShard.java @@ -795,6 +795,14 @@ public void updateShardState( if (currentRouting.initializing() && currentRouting.isRelocationTarget() == false && newRouting.active()) { // the cluster-manager started a recovering primary, activate primary mode. replicationTracker.activatePrimaryMode(getLocalCheckpoint()); + if (indexSettings.isSegRepLocalEnabled() && this.checkpointPublisher != null) { + // Force publish checkpoint so replicas catch up to segments that existed before + // the node restart. Without this, the internal refresh during engine construction + // may have already opened the latest reader, causing subsequent external refreshes + // to see no change and never trigger CheckpointRefreshListener. + updateReplicationCheckpoint(); + checkpointPublisher.publish(this, getLatestReplicationCheckpoint()); + } postActivatePrimaryMode(); } } else { @@ -2291,6 +2299,10 @@ public void onCheckpointPublished(ReplicationCheckpoint checkpoint) { */ public void resetToWriteableEngine() throws IOException, InterruptedException, TimeoutException { indexShardOperationPermits.blockOperations(30, TimeUnit.MINUTES, () -> { resetEngineToGlobalCheckpoint(); }); + // Force update and publish checkpoint so replicas learn about segments that existed + // before the engine reset. See resetEngineToGlobalCheckpoint() in updateShardState() + // promotion path for the same pattern. + updateReplicationCheckpoint(); } public MergedSegmentTransferTracker mergedSegmentTransferTracker() {