-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Use ReplicationFailedException instead of OpensearchException in Repl… #4725
Use ReplicationFailedException instead of OpensearchException in Repl… #4725
Conversation
…icationTarget Signed-off-by: Ayush Kataria <[email protected]>
Signed-off-by: Ayush Kataria <[email protected]>
Gradle Check (Jenkins) Run Completed with:
|
Gradle Check (Jenkins) Run Completed with:
|
Signed-off-by: Ayush Kataria <[email protected]>
Gradle Check (Jenkins) Run Completed with:
|
Signed-off-by: Ayush Kataria <[email protected]>
Gradle Check (Jenkins) Run Completed with:
|
Signed-off-by: Ayush Kataria <[email protected]>
Gradle Check (Jenkins) Run Completed with:
|
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.
Thanks for the change @ayushKataria. Some minor comments that I think are causing the test failures.
new CancellableThreads.ExecutionCancelledException("replication was canceled reason [" + reason + "]"); | ||
final ReplicationFailedException executionCancelledException = new ReplicationFailedException( | ||
"replication was canceled reason [" + reason + "]" | ||
); | ||
notifyListener(executionCancelledException, false); |
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.
With notifyListener now accepting a ReplicationFailedException, we should wrap the cancellationException in ReplicationFailedException.
cancellableThreads.setOnCancel((reason, beforeCancelEx) -> {
// This method only executes when cancellation is triggered by this node and caught by a call to checkForCancel,
// SegmentReplicationSource does not share CancellableThreads.
final CancellableThreads.ExecutionCancelledException executionCancelledException =
new CancellableThreads.ExecutionCancelledException("replication was canceled reason [" + reason + "]");
notifyListener(new ReplicationFailedException("Segment replication failed to complete", executionCancelledException), false);
throw executionCancelledException;
});
There is some special logic above in SegmentReplicationTarget that overrides notifyListener to unwrap the failure and mark it as cancelled. This block will never trigger if the cancellation initiates from the primary however. So thats why the special logic is not in this setOnCancel block.
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.
ahh, thanks for the help. For some reason I was not able to figure the trigger out exactly
// Cancellations still are passed to our SegmentReplicationListner as failures, if we have failed because of cancellation | ||
// update the stage. | ||
final Throwable cancelledException = ExceptionsHelper.unwrap(e, CancellableThreads.ExecutionCancelledException.class); | ||
if (cancelledException != null) { | ||
state.setStage(SegmentReplicationState.Stage.CANCELLED); | ||
listener.onFailure(state(), (CancellableThreads.ExecutionCancelledException) cancelledException, sendShardFailure); | ||
listener.onFailure(state(), new ReplicationFailedException(indexShard, cancelledException), sendShardFailure); |
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.
A nit - I don't think we need to cast or re-wrap the exception here.
@Override
public void notifyListener(ReplicationFailedException e, boolean sendShardFailure) {
// Cancellations still are passed to our SegmentReplicationListner as failures, if we have failed because of cancellation
// update the stage.
if (ExceptionsHelper.unwrap(e, CancellableThreads.ExecutionCancelledException.class) != null) {
state.setStage(SegmentReplicationState.Stage.CANCELLED);
}
listener.onFailure(state(), e, sendShardFailure);
}
* @param e exception that encapsulates the failure | ||
* @param sendShardFailure indicates whether to notify the master of the shard failure | ||
*/ | ||
public void fail(RecoveryFailedException e, boolean sendShardFailure) { |
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.
With RecoveryFailedException
extending ReplicationFailedException
I don't think we need to override here in RecoveryTarget?
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.
Yeah, makes sense. This is redundant now, so will remove it.
Signed-off-by: Ayush Kataria <[email protected]>
Gradle Check (Jenkins) Run Completed with:
|
Codecov Report
@@ Coverage Diff @@
## main #4725 +/- ##
============================================
- Coverage 70.66% 70.65% -0.01%
- Complexity 57578 57594 +16
============================================
Files 4661 4669 +8
Lines 276662 276870 +208
Branches 40325 40346 +21
============================================
+ Hits 195501 195624 +123
- Misses 64926 64949 +23
- Partials 16235 16297 +62
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Gradle Check (Jenkins) Run Completed with:
|
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.
LGTM! Thanks for the change @ayushKataria!
Gradle Check (Jenkins) Run Completed with:
|
Gradle Check (Jenkins) Run Completed with:
|
Gradle Check (Jenkins) Run Completed with:
|
opensearch-project#4725) * Use ReplicationFailedException instead of OpensearchException in ReplicationTarget Signed-off-by: Ayush Kataria <[email protected]> * CHANGELOG.md updated Signed-off-by: Ayush Kataria <[email protected]> * test fixes Signed-off-by: Ayush Kataria <[email protected]> * spotless fix Signed-off-by: Ayush Kataria <[email protected]> * spotless fix Signed-off-by: Ayush Kataria <[email protected]> * fixes for failing test as suggested in PR comments Signed-off-by: Ayush Kataria <[email protected]> Signed-off-by: Ayush Kataria <[email protected]>
The backport to
To backport manually, run these commands in your terminal: # Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/backport-2.x 2.x
# Navigate to the new working tree
pushd ../.worktrees/backport-2.x
# Create a new branch
git switch --create backport/backport-4725-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 6bae823cefad7373a748ce833ce75d80f48b380b
# Push it to GitHub
git push --set-upstream origin backport/backport-4725-to-2.x
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/backport-2.x Then, create a pull request where the |
opensearch-project#4725) * Use ReplicationFailedException instead of OpensearchException in ReplicationTarget Signed-off-by: Ayush Kataria <[email protected]> * CHANGELOG.md updated Signed-off-by: Ayush Kataria <[email protected]> * test fixes Signed-off-by: Ayush Kataria <[email protected]> * spotless fix Signed-off-by: Ayush Kataria <[email protected]> * spotless fix Signed-off-by: Ayush Kataria <[email protected]> * fixes for failing test as suggested in PR comments Signed-off-by: Ayush Kataria <[email protected]> Signed-off-by: Ayush Kataria <[email protected]>
opensearch-project#4725) * Use ReplicationFailedException instead of OpensearchException in ReplicationTarget Signed-off-by: Ayush Kataria <[email protected]> * CHANGELOG.md updated Signed-off-by: Ayush Kataria <[email protected]> * test fixes Signed-off-by: Ayush Kataria <[email protected]> * spotless fix Signed-off-by: Ayush Kataria <[email protected]> * spotless fix Signed-off-by: Ayush Kataria <[email protected]> * fixes for failing test as suggested in PR comments Signed-off-by: Ayush Kataria <[email protected]> Signed-off-by: Ayush Kataria <[email protected]>
opensearch-project#4725) * Use ReplicationFailedException instead of OpensearchException in ReplicationTarget Signed-off-by: Ayush Kataria <[email protected]> * CHANGELOG.md updated Signed-off-by: Ayush Kataria <[email protected]> * test fixes Signed-off-by: Ayush Kataria <[email protected]> * spotless fix Signed-off-by: Ayush Kataria <[email protected]> * spotless fix Signed-off-by: Ayush Kataria <[email protected]> * fixes for failing test as suggested in PR comments Signed-off-by: Ayush Kataria <[email protected]> Signed-off-by: Ayush Kataria <[email protected]>
opensearch-project#4725) * Use ReplicationFailedException instead of OpensearchException in ReplicationTarget Signed-off-by: Ayush Kataria <[email protected]> * CHANGELOG.md updated Signed-off-by: Ayush Kataria <[email protected]> * test fixes Signed-off-by: Ayush Kataria <[email protected]> * spotless fix Signed-off-by: Ayush Kataria <[email protected]> * spotless fix Signed-off-by: Ayush Kataria <[email protected]> * fixes for failing test as suggested in PR comments Signed-off-by: Ayush Kataria <[email protected]> Signed-off-by: Ayush Kataria <[email protected]> Signed-off-by: Suraj Singh <[email protected]>
…icationTarget (#5955) * Use ReplicationFailedException instead of OpensearchException in Repl… (#4725) * Use ReplicationFailedException instead of OpensearchException in ReplicationTarget Signed-off-by: Ayush Kataria <[email protected]> * CHANGELOG.md updated Signed-off-by: Ayush Kataria <[email protected]> * test fixes Signed-off-by: Ayush Kataria <[email protected]> * spotless fix Signed-off-by: Ayush Kataria <[email protected]> * spotless fix Signed-off-by: Ayush Kataria <[email protected]> * fixes for failing test as suggested in PR comments Signed-off-by: Ayush Kataria <[email protected]> Signed-off-by: Ayush Kataria <[email protected]> Signed-off-by: Suraj Singh <[email protected]> * Update SegmentReplicationListener to use ReplicationFailedException Signed-off-by: Suraj Singh <[email protected]> * Spotless fix Signed-off-by: Suraj Singh <[email protected]> Signed-off-by: Ayush Kataria <[email protected]> Signed-off-by: Suraj Singh <[email protected]> Co-authored-by: Ayush Kataria <[email protected]>
…st backport Signed-off-by: Suraj Singh <[email protected]>
Signed-off-by: Suraj Singh <[email protected]> Signed-off-by: Suraj Singh <[email protected]>
…icationTarget (#5955) * Use ReplicationFailedException instead of OpensearchException in Repl… (#4725) * Use ReplicationFailedException instead of OpensearchException in ReplicationTarget Signed-off-by: Ayush Kataria <[email protected]> * CHANGELOG.md updated Signed-off-by: Ayush Kataria <[email protected]> * test fixes Signed-off-by: Ayush Kataria <[email protected]> * spotless fix Signed-off-by: Ayush Kataria <[email protected]> * spotless fix Signed-off-by: Ayush Kataria <[email protected]> * fixes for failing test as suggested in PR comments Signed-off-by: Ayush Kataria <[email protected]> Signed-off-by: Ayush Kataria <[email protected]> Signed-off-by: Suraj Singh <[email protected]> * Update SegmentReplicationListener to use ReplicationFailedException Signed-off-by: Suraj Singh <[email protected]> * Spotless fix Signed-off-by: Suraj Singh <[email protected]> Signed-off-by: Ayush Kataria <[email protected]> Signed-off-by: Suraj Singh <[email protected]> Co-authored-by: Ayush Kataria <[email protected]>
…icationTarget
Signed-off-by: Ayush Kataria [email protected]
Description
Uses a narrower ReplicationFailedException instead of OpensearchException in ReplicationTarget and ReplicationListener
Issues Resolved
[List any issues this PR will resolve]
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.