-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
fix: refresh leader on disconnect #1140
Conversation
WalkthroughRecent changes enhance the error handling mechanisms in the jraft framework by introducing a new Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant BoltRpcClient
participant ConnectionFailureException
participant RheaKVRpcService
Client->>BoltRpcClient: invokeSync(request)
BoltRpcClient-->>ConnectionFailureException: Check for ConnectException
ConnectionFailureException-->>BoltRpcClient: Throw ConnectionFailureException
BoltRpcClient->>RheaKVRpcService: Handle connection error
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (5)
- jraft-core/src/main/java/com/alipay/sofa/jraft/error/ConnectionFailureException.java (1 hunks)
- jraft-core/src/main/java/com/alipay/sofa/jraft/rpc/impl/BoltRpcClient.java (4 hunks)
- jraft-core/src/main/java/com/alipay/sofa/jraft/util/internal/ThrowUtil.java (1 hunks)
- jraft-rheakv/rheakv-core/src/main/java/com/alipay/sofa/jraft/rhea/client/DefaultRheaKVRpcService.java (3 hunks)
- jraft-rheakv/rheakv-core/src/main/java/com/alipay/sofa/jraft/rhea/client/pd/DefaultPlacementDriverRpcService.java (3 hunks)
Additional comments not posted (9)
jraft-core/src/main/java/com/alipay/sofa/jraft/error/ConnectionFailureException.java (1)
1-45
: New Exception Class Added:ConnectionFailureException
.The new class
ConnectionFailureException
is well-structured, providing multiple constructors for flexibility in handling RPC connection failures. This addition enhances error handling granularity.jraft-core/src/main/java/com/alipay/sofa/jraft/util/internal/ThrowUtil.java (2)
69-75
: New Method Added:getRootCause
.The
getRootCause
method effectively traverses the cause chain to find the root cause of aThrowable
. This utility enhances error diagnostics.
64-64
: Improvement incutCause
Method.The
cutCause
method now sets the stack trace to that of the root cause, enhancing the accuracy of error reporting.jraft-rheakv/rheakv-core/src/main/java/com/alipay/sofa/jraft/rhea/client/pd/DefaultPlacementDriverRpcService.java (3)
28-28
: Improved Error Handling:ConnectionFailureException
Import.The import of
ConnectionFailureException
aligns with the enhanced error handling strategy focused on connection failures.
114-114
: Simplified Error Handling incomplete
Method.The removal of specific handling for
RemotingException
in favor of a generalized approach simplifies the error handling logic.
126-132
: Refined Error Handling inexecutor
Method.The catch block now explicitly handles
ConnectionFailureException
, improving specificity and robustness in error management.jraft-core/src/main/java/com/alipay/sofa/jraft/rpc/impl/BoltRpcClient.java (2)
124-126
: Consistent error handling is approved.The handling of
ConnectException
ininvokeAsync
aligns withinvokeSync
, ensuring consistency.Verify that
ConnectionFailureException
is consistently handled throughout the codebase.
106-108
: Enhanced error handling is approved.The addition of
ConnectionFailureException
forConnectException
improves error granularity and diagnostics.Ensure that
ConnectionFailureException
is properly handled in other parts of the codebase to maintain robustness.Verification successful
ConnectionFailureException
is properly handled in the codebase.The exception is checked in key classes such as
DefaultRheaKVRpcService
andDefaultPlacementDriverRpcService
, indicating that the error handling is robust and consistent across the codebase.
DefaultRheaKVRpcService
: Checks forConnectionFailureException
.DefaultPlacementDriverRpcService
: Checks forConnectionFailureException
.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify handling of `ConnectionFailureException` throughout the codebase. # Test: Search for the usage of `ConnectionFailureException`. Expect: Proper handling in all relevant locations. rg --type java 'ConnectionFailureException'Length of output: 2976
jraft-rheakv/rheakv-core/src/main/java/com/alipay/sofa/jraft/rhea/client/DefaultRheaKVRpcService.java (1)
156-161
: Streamlined error handling is approved.The specific handling of
ConnectionFailureException
improves clarity and reduces redundancy.Ensure that
ConnectionFailureException
handling is consistent across the codebase.
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, thank you! @shihuili1218
This change won't affect the Jepsen test results. I think we can release |
Motivation:
Explain the context, and why you're making that change.
To make others understand what is the problem you're trying to solve.
Modification:
Describe the idea and modifications you've done.
Result:
Fixes #.
If there is no issue then describe the changes introduced by this PR.
Summary by CodeRabbit
New Features
ConnectionFailureException
for improved error handling related to RPC connection failures.getRootCause
to enhance exception diagnostics.Bug Fixes
BoltRpcClient
to differentiate connection failures from other remoting exceptions.DefaultRheaKVRpcService
andDefaultPlacementDriverRpcService
for consistency in handling connection errors.Documentation