-
Notifications
You must be signed in to change notification settings - Fork 8.9k
optimize:Remove unnecessary refreshLeader from ClusterController cluster endpoint #7970
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: 2.x
Are you sure you want to change the base?
Conversation
…er cluster endpoint - Remove RouteTable.refreshLeader/selectLeader calls in GET /metadata/v1/cluster - Use RaftStateMachine.getRaftLeaderMetadata() only for cluster metadata - Removes redundant JRaft round-trip; response shape and semantics unchanged - Remove unused PeerId import
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## 2.x #7970 +/- ##
============================================
+ Coverage 71.74% 71.80% +0.05%
Complexity 872 872
============================================
Files 1300 1300
Lines 49727 49721 -6
Branches 5908 5908
============================================
+ Hits 35678 35702 +24
+ Misses 11114 11083 -31
- Partials 2935 2936 +1
🚀 New features to boost your workflow:
|
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.
Please register your PR in those two files :
https://github.com/apache/incubator-seata/blob/2.x/changes/zh-cn/2.x.md https://github.com/apache/incubator-seata/blob/2.x/changes/en-us/2.x.md
And I believe this PR is an optimization, not a bug. Therefore the PR title should begin with the prefix "optimize:".
Abhishekmishra2808
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.
One thing I noticed: Codecov reports 4 uncovered lines in ClusterController.java.
Should we add or adjust a test in ClusterControllerTest to explicitly cover the path where:
raftServer != nullleaderNodeis present viagetRaftLeaderMetadata()
This would help avoid coverage regressions.
| routeTable.refreshLeader(RaftServerManager.getCliClientServiceInstance(), group, 1000); | ||
| PeerId leader = routeTable.selectLeader(group); | ||
| if (leader != null) { | ||
| RaftClusterMetadata raftClusterMetadata = |
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.
Small question: do we need a null-safety check around getRaftLeaderMetadata() or its fields (leader / learners) during leader transition windows, or is the state machine guaranteed to return a consistent snapshot here?
Thanks. I’m registering this PR in both changes/en-us/2.x.md and changes/zh-cn/2.x.md under the Optimize section. |
|
Thanks. I’m registering this PR in both changes/en-us/2.x.md and changes/zh-cn/2.x.md under the Optimize section. |
Remove unnecessary refreshLeader from ClusterController
Remove unnecessary refreshLeader from ClusterController
Remove unnecessary refreshLeader from ClusterController cluster endpoint.
Why didn't you commit the related changes directly to this PR's branch instead of creating a new branch and opening a separate PR? |
xingfudeshi
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
What's changed
RouteTable.refreshLeader()andRouteTable.selectLeader()fromGET /metadata/v1/clusterinClusterController.RaftStateMachine.getRaftLeaderMetadata()for cluster metadata (leader, followers, learners, term).PeerIdimport.Why
The cluster endpoint already builds the response from
RaftStateMachine.getRaftLeaderMetadata(). TherefreshLeader/selectLeadercalls only checked "is there a leader?" via JRaft's RouteTable, duplicating info we already have. Removing them:/clustercallMetadataResponseshape and semanticschangeClusterunchanged (still uses RouteTable forchangePeers/updateConfiguration)Testing
ClusterControllerTest(runmvn test -pl server -Dtest=ClusterControllerTest)RaftRegistryServiceImplor other callers; response contract unchanged.fix #7967