Skip to content

Commit

Permalink
Avoid use of indicesService in Resume replicaiton flow (#1030) (#1043)
Browse files Browse the repository at this point in the history
Avoid use of indicesService in Resume replicaiton flow.
Signed-off-by: monusingh-1 <[email protected]>
  • Loading branch information
monusingh-1 authored Jul 6, 2023
1 parent a0ed3f3 commit ee5a9fa
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ import org.opensearch.env.Environment
import org.opensearch.index.IndexNotFoundException
import org.opensearch.index.shard.ShardId
import org.opensearch.replication.ReplicationPlugin.Companion.KNN_INDEX_SETTING
import org.opensearch.replication.util.indicesService
import org.opensearch.threadpool.ThreadPool
import org.opensearch.transport.TransportService
import java.io.IOException
Expand Down Expand Up @@ -139,10 +138,7 @@ class TransportResumeIndexReplicationAction @Inject constructor(transportService
shards.forEach {
val followerShardId = it.value.shardId

val followerIndexService = indicesService.indexServiceSafe(followerShardId.index)
val indexShard = followerIndexService.getShard(followerShardId.id)

if (!retentionLeaseHelper.verifyRetentionLeaseExist(ShardId(params.leaderIndex, followerShardId.id), followerShardId, indexShard.lastSyncedGlobalCheckpoint+1)) {
if (!retentionLeaseHelper.verifyRetentionLeaseExist(ShardId(params.leaderIndex, followerShardId.id), followerShardId)) {
isResumable = false
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class RemoteClusterRetentionLeaseHelper constructor(var followerClusterNameWithU
}
}

public suspend fun verifyRetentionLeaseExist(leaderShardId: ShardId, followerShardId: ShardId, seqNo: Long): Boolean {
public suspend fun verifyRetentionLeaseExist(leaderShardId: ShardId, followerShardId: ShardId): Boolean {
val retentionLeaseId = retentionLeaseIdForShard(followerClusterNameWithUUID, followerShardId)
// Currently there is no API to describe/list the retention leases .
// So we are verifying the existence of lease by trying to renew a lease by same name .
Expand All @@ -74,7 +74,7 @@ class RemoteClusterRetentionLeaseHelper constructor(var followerClusterNameWithU
return true
}
catch (e: RetentionLeaseNotFoundException) {
return addNewRetentionLeaseIfOldExists(leaderShardId, followerShardId, seqNo)
return addNewRetentionLeaseIfOldExists(leaderShardId, followerShardId, RetentionLeaseActions.RETAIN_ALL)
}catch (e : Exception) {
return false
}
Expand Down

0 comments on commit ee5a9fa

Please sign in to comment.