-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
[Segment Replication] Ensure replica's store always contains the previous commit point. #2551
[Segment Replication] Ensure replica's store always contains the previous commit point. #2551
Conversation
❌ Gradle Check failure 5dd980e1c68f1e97613fdeba73491e46b66f6ec0 |
This change: 1. Updates the cleanup and validation steps after a replication event occurs to prevent deleting files still referenced by both the on disk segments_N file and the in memory SegmentInfos. 2. Sends metadata diff of on disk segments with each copy event. This allows replicas that are multiple commit points behind to catch up. 3. Update initial recovery in IndexShard to copy segments before lighting up as active. This fixes bug where replicas could not be added after primary. Signed-off-by: Marc Handalian <[email protected]>
force push is a rebase from the feature branch. |
...er/src/internalClusterTest/java/org/opensearch/indices/replication/SegmentReplicationIT.java
Show resolved
Hide resolved
segmentReplicationReplicaService.startReplication( | ||
checkpoint, | ||
this, | ||
source, | ||
new SegmentReplicationReplicaService.SegmentReplicationListener() { | ||
@Override | ||
public void onReplicationDone(SegmentReplicationState state) { | ||
markReplicationComplete(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would we remove this when we continue to use MarkAsReplicating()?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved this to when ReplicationTarget's finalize method completes because I didn't like SegmentReplicationListener being responsible for marking it as complete. With that said I think we can do better by moving it to the onDone/onCancel/onFail methods of SegmentReplicationTarget. Will also move markAsReplicating to ReplicationTarget as well so these classes don't have to manage that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cleaned this up in latest commit, what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wasn't the plan to move markAsReplicating
to ReplicationTarget
as well? Right now, that seems to be in ReplicaService
so the lifecycle management is distributed across two classes, which smells. How do we improve this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, maybe we can completely remove this state and make a synchronized check if ReplicationCollection has an ongoing replication for the shard. Would like to take this as a follow up change if thats ok.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you create a task to track it, so we don't forget?
server/src/main/java/org/opensearch/indices/replication/SegmentReplicationReplicaService.java
Show resolved
Hide resolved
server/src/main/java/org/opensearch/indices/replication/copy/CopyState.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Marc Handalian <[email protected]>
...main/java/org/opensearch/indices/replication/checkpoint/TransportCheckpointInfoResponse.java
Outdated
Show resolved
Hide resolved
.../src/main/java/org/opensearch/indices/replication/copy/SegmentReplicationPrimaryService.java
Show resolved
Hide resolved
assert Transports.assertNotTransportThread(this + "[onFailure]"); | ||
logger.error("Failure", e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this change in behavior?
Also, better log message?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The existing responseListener's onFailure was getting triggered but doing nothing. This at least logs the error on the primary. I've updated to also send the exception back to the replica.
server/src/main/java/org/opensearch/indices/replication/copy/SegmentReplicationTarget.java
Outdated
Show resolved
Hide resolved
...er/src/internalClusterTest/java/org/opensearch/indices/replication/SegmentReplicationIT.java
Show resolved
Hide resolved
Outside of my review comments and the changes in this PR specifically, I wanted to put a high-level question - should we make the seg-rep tests more rigorous to validate the file structure on replica nodes to make sure they are consistent with the primary? Our current asserts are around hit count, which seems largely sufficient given that our test case is checking if newly indexed documents show up on the replica. But it doesn't validate that the shards are point-in-time consistent |
Good call. I think we can do a decent comparison with the results of _cat/segments. |
❌ Gradle Check failure 8ce2c1a9c78301f9208b5c6a028044d229ed41b2 |
❌ Gradle Check failure c7791601588393a1d25388acc286985a824e3281 |
.../src/main/java/org/opensearch/indices/replication/copy/SegmentReplicationPrimaryService.java
Outdated
Show resolved
Hide resolved
- Updated TrackShardRequestHandler to send error case back to replicas. - Renamed additionalFiles to pendingDeleteFiles in TransportCheckpointInfoResponse. - Refactored Store.cleanupAndVerify methods to remove duplication. Signed-off-by: Marc Handalian <[email protected]>
❌ Gradle Check failure f0410ac5b3b8c13bba3ffbe240241ccc6d3bcf69 |
Description
This change:
Issues Resolved
closes #2331
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.