Skip to content

Commit a22e956

Browse files
committed
Address review: rename async lease method, return early during force resume bootstrap
Signed-off-by: Mohit Kumar <mohitamg@amazon.com>
1 parent b857c4d commit a22e956

3 files changed

Lines changed: 17 additions & 7 deletions

File tree

src/main/kotlin/org/opensearch/replication/action/resume/ForceResumeCoordinator.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ class ForceResumeCoordinator(
121121
val retainingSeqNo = getLeaderGlobalCheckpoint(remoteClient, params.leaderIndex.name, leaderShardId.id) + 1
122122

123123
try {
124-
retentionLeaseHelper.addRetentionLease(
124+
retentionLeaseHelper.addRetentionLeaseAsync(
125125
leaderShardId, retainingSeqNo, followerShardId
126126
)
127127
} catch (e: RetentionLeaseAlreadyExistsException) {

src/main/kotlin/org/opensearch/replication/action/resume/TransportResumeIndexReplicationAction.kt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,18 @@ class TransportResumeIndexReplicationAction @Inject constructor(transportService
140140
listener.onResponse(ReplicateIndexResponse(false))
141141
}
142142

143-
// Now wait for the replication to start and the follower index to get created before returning
143+
// Wait for the replication task to start. For force resume (snapshot bootstrap),
144+
// return once RESTORING state is reached — same as start replication — since
145+
// bootstrap can take a long time for large indices. For normal resume, wait
146+
// until FOLLOWING since no snapshot restore is needed.
144147
persistentTasksService.waitForTaskCondition(task.id, request.timeout()) { t ->
145148
val replicationState = (t.state as IndexReplicationState?)?.state
146-
replicationState == ReplicationState.FOLLOWING
149+
if (request.forceResume) {
150+
replicationState == ReplicationState.FOLLOWING ||
151+
replicationState == ReplicationState.RESTORING
152+
} else {
153+
replicationState == ReplicationState.FOLLOWING
154+
}
147155
}
148156

149157
AcknowledgedResponse(true)

src/main/kotlin/org/opensearch/replication/seqno/RemoteClusterRetentionLeaseHelper.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,13 @@ class RemoteClusterRetentionLeaseHelper constructor(var followerClusterNameWithU
116116
}
117117

118118
/**
119-
* Suspend (non-blocking) version of addRetentionLease for use in coroutine contexts
120-
* (e.g., transport thread). The blocking overload below uses actionGet() and must NOT
121-
* be called from transport threads.
119+
* Non-blocking (suspend) version of addRetentionLease for use in coroutine contexts.
120+
* The blocking overload [addRetentionLease(ShardId, Long, ShardId, Long)] uses actionGet()
121+
* and is intended for synchronous callers (e.g., leader-side restore service).
122+
* This suspend variant must NOT be called from transport threads directly — only from
123+
* coroutine scopes (e.g., ForceResumeCoordinator).
122124
*/
123-
public suspend fun addRetentionLease(leaderShardId: ShardId, seqNo: Long, followerShardId: ShardId) {
125+
public suspend fun addRetentionLeaseAsync(leaderShardId: ShardId, seqNo: Long, followerShardId: ShardId) {
124126
val retentionLeaseId = retentionLeaseIdForShard(followerClusterNameWithUUID, followerShardId)
125127
val request = RetentionLeaseActions.AddRequest(leaderShardId, retentionLeaseId, seqNo, retentionLeaseSource)
126128
log.info("Adding retention lease $retentionLeaseId (async)")

0 commit comments

Comments
 (0)