Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix(coordinator): choose highest term and entry node as leader #579

Merged
merged 2 commits into from
Nov 16, 2024

Conversation

mattisonchao
Copy link
Member

@mattisonchao mattisonchao commented Nov 16, 2024

Motivation

Follow the TLA+. We should choose the highest term entry node as the leader, which can also fix the issue we encountered.

{"level":"info","time":"2024-11-14T01:04:55.195566194Z","component":"shard-controller","namespace":"xxx","shard":10,"term":278,"time":"2024-11-14T01:04:55.195588258Z","message":"Starting leader election"}
{"level":"info","time":"2024-11-14T01:04:55.218118449Z","component":"shard-controller","entry-id":{"term":"78","offset":"5652112"},"namespace":"xxx","server-address":{"public":"xxxxxxx:6648","internal":"xxxxxxx:6649"},"shard":10,"time":"2024-11-14T01:04:55.218152924Z","message":"Processed newTerm response"}
{"level":"info","time":"2024-11-14T01:04:55.218347701Z","component":"shard-controller","entry-id":{"term":"78","offset":"5652112"},"namespace":"xxx","server-address":{"public":"xxxxxxx:6648","internal":"xxxxxxx:6649"},"shard":10,"time":"2024-11-14T01:04:55.218369944Z","message":"Processed newTerm response"}
{"level":"info","time":"2024-11-14T01:04:55.219517988Z","component":"shard-controller","entry-id":{"term":"77","offset":"5653106"},"namespace":"xxx","server-address":{"public":"xxxxxxx:6648","internal":"xxxxxxx:6649"},"shard":10,"time":"2024-11-14T01:04:55.219534113Z","message":"Processed newTerm response"}
{"level":"info","time":"2024-11-14T01:04:55.219554195Z","component":"shard-controller","followers":[{"server-address":{"public":"xxxxxxx:6648","internal":"xxxxxxx:6649"},"entry-id":{"term":78,"offset":5652112}},{"server-address":{"public":"xxxxxxx:6648","internal":"xxxxxxx:6649"},"entry-id":{"term":78,"offset":5652112}}],"namespace":"xxx","new-leader":{"public":"xxxxxxx:6648","internal":"xxxxxxx:6649"},"shard":10,"term":278,"time":"2024-11-14T01:04:55.219564969Z","message":"Successfully moved ensemble to a new term"}

@mattisonchao mattisonchao merged commit 02d3f5c into main Nov 16, 2024
7 checks passed
@mattisonchao mattisonchao deleted the fix.election.term branch November 16, 2024 03:53
merlimat added a commit that referenced this pull request Jan 24, 2025
### Motivation

#579 want to support choosing the highest term as leader. But that PR
didn't support it well.


### Modification

- Fix the bug might choose a lower term as leader.
- Add enhanced test to cover logic.

---------

Co-authored-by: Matteo Merli <mmerli@apache.org>
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants