@@ -77,8 +77,8 @@ class TransportGetChangesAction @Inject constructor(threadPool: ThreadPool, clus
7777 indexMetric.lastFetchTime.set(relativeStartNanos)
7878
7979 val indexShard = indicesService.indexServiceSafe(shardId.index).getShard(shardId.id)
80- val isRemoteStoreEnabled = ValidationUtil .isRemoteStoreEnabledCluster (clusterService)
81- if (lastGlobalCheckpoint(indexShard, isRemoteStoreEnabled ) < request.fromSeqNo) {
80+ val isRemoteEnabledOrMigrating = ValidationUtil .isRemoteEnabledOrMigrating (clusterService)
81+ if (lastGlobalCheckpoint(indexShard, isRemoteEnabledOrMigrating ) < request.fromSeqNo) {
8282 // There are no new operations to sync. Do a long poll and wait for GlobalCheckpoint to advance. If
8383 // the checkpoint doesn't advance by the timeout this throws an ESTimeoutException which the caller
8484 // should catch and start a new poll.
@@ -87,18 +87,18 @@ class TransportGetChangesAction @Inject constructor(threadPool: ThreadPool, clus
8787 // At this point indexShard.lastKnownGlobalCheckpoint has advanced but it may not yet have been synced
8888 // to the translog, which means we can't return those changes. Return to the caller to retry.
8989 // TODO: Figure out a better way to wait for the global checkpoint to be synced to the translog
90- if (lastGlobalCheckpoint(indexShard, isRemoteStoreEnabled ) < request.fromSeqNo) {
91- assert (gcp > lastGlobalCheckpoint(indexShard, isRemoteStoreEnabled )) { " Checkpoint didn't advance at all $gcp ${lastGlobalCheckpoint(indexShard, isRemoteStoreEnabled )} " }
90+ if (lastGlobalCheckpoint(indexShard, isRemoteEnabledOrMigrating ) < request.fromSeqNo) {
91+ assert (gcp > lastGlobalCheckpoint(indexShard, isRemoteEnabledOrMigrating )) { " Checkpoint didn't advance at all $gcp ${lastGlobalCheckpoint(indexShard, isRemoteEnabledOrMigrating )} " }
9292 throw OpenSearchTimeoutException (" global checkpoint not synced. Retry after a few miliseconds..." )
9393 }
9494 }
9595
9696 relativeStartNanos = System .nanoTime()
9797 // At this point lastSyncedGlobalCheckpoint is at least fromSeqNo
98- val toSeqNo = min(lastGlobalCheckpoint(indexShard, isRemoteStoreEnabled ), request.toSeqNo)
98+ val toSeqNo = min(lastGlobalCheckpoint(indexShard, isRemoteEnabledOrMigrating ), request.toSeqNo)
9999
100100 var ops: List <Translog .Operation > = listOf ()
101- var fetchFromTranslog = isTranslogPruningByRetentionLeaseEnabled(shardId) && isRemoteStoreEnabled == false
101+ var fetchFromTranslog = isTranslogPruningByRetentionLeaseEnabled(shardId) && isRemoteEnabledOrMigrating == false
102102 if (fetchFromTranslog) {
103103 try {
104104 ops = translogService.getHistoryOfOperations(indexShard, request.fromSeqNo, toSeqNo)
@@ -136,16 +136,16 @@ class TransportGetChangesAction @Inject constructor(threadPool: ThreadPool, clus
136136 indexMetric.ops.addAndGet(ops.size.toLong())
137137
138138 ops.stream().forEach{op -> indexMetric.bytesRead.addAndGet(op.estimateSize()) }
139- GetChangesResponse (ops, request.fromSeqNo, indexShard.maxSeqNoOfUpdatesOrDeletes, lastGlobalCheckpoint(indexShard, isRemoteStoreEnabled ))
139+ GetChangesResponse (ops, request.fromSeqNo, indexShard.maxSeqNoOfUpdatesOrDeletes, lastGlobalCheckpoint(indexShard, isRemoteEnabledOrMigrating ))
140140 }
141141 }
142142 }
143143
144- private fun lastGlobalCheckpoint (indexShard : IndexShard , isRemoteStoreEnabled : Boolean ): Long {
144+ private fun lastGlobalCheckpoint (indexShard : IndexShard , isRemoteEnabledOrMigrating : Boolean ): Long {
145145 // We rely on lastSyncedGlobalCheckpoint as it has been durably written to disk. In case of remote store
146146 // enabled clusters, the semantics are slightly different, and we can't use lastSyncedGlobalCheckpoint. Falling back to
147147 // lastKnownGlobalCheckpoint in such cases.
148- return if (isRemoteStoreEnabled ) {
148+ return if (isRemoteEnabledOrMigrating ) {
149149 indexShard.lastKnownGlobalCheckpoint
150150 } else {
151151 indexShard.lastSyncedGlobalCheckpoint
@@ -173,7 +173,7 @@ class TransportGetChangesAction @Inject constructor(threadPool: ThreadPool, clus
173173 override fun shards (state : ClusterState , request : InternalRequest ): ShardsIterator {
174174 val shardIt = state.routingTable().shardRoutingTable(request.request().shardId)
175175 // Random active shards
176- return if (ValidationUtil .isRemoteStoreEnabledCluster (clusterService)) shardIt.primaryShardIt()
176+ return if (ValidationUtil .isRemoteEnabledOrMigrating (clusterService)) shardIt.primaryShardIt()
177177 else shardIt.activeInitializingShardsRandomIt()
178178 }
179179}
0 commit comments