Skip to content

Commit 3fa4dfd

Browse files
authored
Fix segment replication bug during primary relocation (#18944) (#18958)
* Fix segment replication bug during primary relocation * Fix applicable for segrep local indexes only --------- Signed-off-by: Ashish Singh <ssashish@amazon.com>
1 parent ef432e8 commit 3fa4dfd

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

server/src/main/java/org/opensearch/indices/replication/SegmentReplicationTarget.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,20 @@ public void startReplication(ActionListener<Void> listener) {
177177
source.getCheckpointMetadata(getId(), checkpoint, checkpointInfoListener);
178178

179179
checkpointInfoListener.whenComplete(checkpointInfo -> {
180+
ReplicationCheckpoint getMetadataCheckpoint = checkpointInfo.getCheckpoint();
181+
if (indexShard.indexSettings().isSegRepLocalEnabled() && checkpoint.isAheadOf(getMetadataCheckpoint)) {
182+
// Fixes https://github.com/opensearch-project/OpenSearch/issues/18490
183+
listener.onFailure(
184+
new ReplicationFailedException(
185+
"Rejecting stale metadata checkpoint ["
186+
+ getMetadataCheckpoint
187+
+ "] since initial checkpoint ["
188+
+ checkpoint
189+
+ "] is ahead of it"
190+
)
191+
);
192+
return;
193+
}
180194
final List<StoreFileMetadata> filesToFetch = getFiles(checkpointInfo);
181195
state.setStage(SegmentReplicationState.Stage.GET_FILES);
182196
cancellableThreads.checkForCancel();

0 commit comments

Comments
 (0)