-
Notifications
You must be signed in to change notification settings - Fork 8.9k
optimize: update resource cleanup logic for channel disconnection #7360
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
Conversation
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.
Pull Request Overview
This pull request updates the resource cleanup logic for channel disconnection to ensure that both the pending message futures and the child–parent mapping are cleaned up properly when a channel disconnects. Key changes include:
- Introduction of a new childToParentMap field in tests and corresponding assertions to validate its cleanup.
- Modifications in AbstractNettyRemotingClient to remove parent mapping from mergeMsgMap when cleaning up message futures.
- Updates to logging and code formatting for improved readability.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| core/src/test/java/org/apache/seata/core/rpc/netty/ResourceCleanupTest.java | Adds childToParentMap initialization and assertions to verify cleanup on channel disconnection. |
| core/src/main/java/org/apache/seata/core/rpc/netty/AbstractNettyRemotingClient.java | Refactors resource cleanup logic, updates scheduling lambda formatting, and adjusts exception logging in sendAsyncRequest. |
| changes/zh-cn/2.x.md | Updates changelog to include the new resource cleanup behavior. |
| changes/en-us/2.x.md | Updates changelog to include the new resource cleanup behavior. |
Comments suppressed due to low confidence (2)
core/src/main/java/org/apache/seata/core/rpc/netty/AbstractNettyRemotingClient.java:227
- Consider providing a more descriptive Throwable message instead of using a hardcoded "throw" to give clearer context for the exception.
throw new FrameworkException(new Throwable("throw"), "frameworkException", FrameworkErrorCode.ChannelIsNotWritable);
core/src/main/java/org/apache/seata/core/rpc/netty/AbstractNettyRemotingClient.java:517
- [nitpick] If multiple child messages share the same parent ID, removing the parent's mapping for each child could potentially lead to premature cleanup of mergeMsgMap; ensure that this behavior is as intended or consider grouping removals by parent ID.
Integer parentId = childToParentMap.remove(messageId);
|
After applying Spotless and creating a PR, it seems that a lot more code gets modified than what I actually changed, which makes the review process more difficult. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## 2.x #7360 +/- ##
=========================================
Coverage 58.41% 58.42%
Complexity 535 535
=========================================
Files 1272 1272
Lines 45853 45865 +12
Branches 5520 5521 +1
=========================================
+ Hits 26785 26795 +10
- Misses 16546 16548 +2
Partials 2522 2522
🚀 New features to boost your workflow:
|
I agree, so we should submit a PR to format all the code with Spotless at once, otherwise it will seriously affect the efficiency of code review. @slievrly |
funky-eyes
left a comment
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
Ⅰ. Describe what this PR did
fixes #5283
Ⅱ. Does this pull request fix one issue?
Ⅲ. Why don't you add test cases (unit test/integration test)?
Ⅳ. Describe how to verify it
Ⅴ. Special notes for reviews