-
Notifications
You must be signed in to change notification settings - Fork 2.5k
[segment replication] Simplify the ckp verification for the primary shard relocation #20609
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -47,20 +47,17 @@ public abstract class AbstractSegmentReplicationTarget extends ReplicationTarget | |
| protected final SegmentReplicationSource source; | ||
| protected final SegmentReplicationState state; | ||
| protected final MultiFileWriter multiFileWriter; | ||
| protected final boolean isRetry; | ||
|
|
||
| public AbstractSegmentReplicationTarget( | ||
| String name, | ||
| IndexShard indexShard, | ||
| ReplicationCheckpoint checkpoint, | ||
| SegmentReplicationSource source, | ||
| boolean isRetry, | ||
| ReplicationListener listener | ||
| ) { | ||
| super(name, indexShard, new ReplicationLuceneIndex(), listener); | ||
| this.checkpoint = checkpoint; | ||
| this.source = source; | ||
| this.isRetry = isRetry; | ||
| this.state = new SegmentReplicationState( | ||
| indexShard.routingEntry(), | ||
| stateIndex, | ||
|
|
@@ -165,28 +162,6 @@ public void startReplication(ActionListener<Void> listener, BiConsumer<Replicati | |
| getCheckpointMetadata(checkpointInfoListener); | ||
|
|
||
| checkpointInfoListener.whenComplete(checkpointInfo -> { | ||
| ReplicationCheckpoint getMetadataCheckpoint = checkpointInfo.getCheckpoint(); | ||
| // Only enforce strict checkpoint validation during normal replication, not during recovery. | ||
| // During recovery (shard is INITIALIZING or RELOCATING), the replica may have a stale checkpoint | ||
| // from before a restart, and should accept the primary's current state even if it appears older. | ||
| // See: https://github.com/opensearch-project/OpenSearch/issues/19234 | ||
| boolean isRecovering = indexShard.routingEntry().initializing() || indexShard.routingEntry().relocating(); | ||
| if (indexShard.indexSettings().isSegRepLocalEnabled() | ||
| && checkpoint.isAheadOf(getMetadataCheckpoint) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We cannot remove
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm wondering whether an existing test would catch this? |
||
| && false == isRecovering | ||
| && false == isRetry) { | ||
| // Fixes https://github.com/opensearch-project/OpenSearch/issues/18490 | ||
| listener.onFailure( | ||
| new ReplicationFailedException( | ||
| "Rejecting stale metadata checkpoint [" | ||
| + getMetadataCheckpoint | ||
| + "] since initial checkpoint [" | ||
| + checkpoint | ||
| + "] is ahead of it" | ||
| ) | ||
| ); | ||
| return; | ||
| } | ||
| updateCheckpoint(checkpointInfo.getCheckpoint(), checkpointUpdater); | ||
| final List<StoreFileMetadata> filesToFetch = getFiles(checkpointInfo); | ||
| state.setStage(SegmentReplicationState.Stage.GET_FILES); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.