Skip to content

Conversation

@superchee0526
Copy link
Contributor

When deploying multiple controllers, the old leader lost the leader doesn't update the preTermLeader information. This will cause later leader resume cannot be accessed.

		if c.clusterStore.IsLeader() {
			if prevTermLeader != c.clusterStore.ID() {
				c.becomeLeader(ctx, prevTermLeader)
				prevTermLeader = c.clusterStore.ID()
			}
		} else {
			if prevTermLeader != c.clusterStore.ID() {
				continue
			}
			c.suspend()
			prevTermLeader = c.clusterStore.Leader()
			logger.Get().Warn("Lost the leader, suspend the controller")
		}
  1. A is leader, B is follower
  2. leader change to B: A lost the leader and suspend(), however the prevTermLeader is still A
  3. When A re-get the leadership, since prevTermLeader == c.clusterStore.ID(), it cannot resume the leadership

@git-hulk
Copy link
Member

The CI failure is not related to this PR, will fix it later.

@git-hulk git-hulk self-requested a review September 27, 2025 02:15
@git-hulk git-hulk changed the title fix: leader change haven't updated prevTermLeader when lost the leader Fix leader change haven't updated prevTermLeader when lost the leader Sep 28, 2025
@codecov-commenter
Copy link

codecov-commenter commented Sep 28, 2025

Codecov Report

❌ Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 47.44%. Comparing base (6c56470) to head (5b4791b).
⚠️ Report is 100 commits behind head on unstable.

Files with missing lines Patch % Lines
controller/controller.go 50.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##           unstable     #353      +/-   ##
============================================
+ Coverage     43.38%   47.44%   +4.05%     
============================================
  Files            37       45       +8     
  Lines          2971     4456    +1485     
============================================
+ Hits           1289     2114     +825     
- Misses         1544     2134     +590     
- Partials        138      208      +70     
Flag Coverage Δ
unittests 47.44% <50.00%> (+4.05%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@git-hulk git-hulk merged commit 167acb7 into apache:unstable Sep 28, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants