Skip to content

RATIS-2311. Check appliedIndex gap before starting a transfer election - #1586

Merged
szetszwo merged 6 commits into
apache:masterfrom
Elia-Renzoni:refactor/transfer-leadership
Oct 1, 2026
Merged

szetszwo merged 6 commits into
apache:masterfrom
Elia-Renzoni:refactor/transfer-leadership

Conversation

@Elia-Renzoni

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

This PR makes the leadership transfer check in TransferLeadership#isFollowerUpToDate stricter by also verifying that the gap between the target follower's matchIndex (replicated log) and its appliedIndex (state machine apply progress) is within an acceptable threshold, in addition to the existing matchIndex up-to-date check

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/RATIS-2311?page=com.atlassian.jira.plugin.system.issuetabpanels%3Aall-tabpanel

How was this patch tested?

Added testRiskyLeadershipTransfer to the abstract LeaderElectionTests class, alongside the existing testTransferLeader and testTransferLeaderTimeout tests

@Elia-Renzoni
Elia-Renzoni force-pushed the refactor/transfer-leadership branch from 7c5ef5f to 23e8344 Compare September 15, 2026 15:35
@Elia-Renzoni

Copy link
Copy Markdown
Contributor Author

@szetszwo Could you take a look at this PR? Thanks!

@szetszwo

Copy link
Copy Markdown
Contributor

Sure, will review this.

@Elia-Renzoni
Elia-Renzoni force-pushed the refactor/transfer-leadership branch from 23e8344 to db777b1 Compare September 24, 2026 07:42
@szetszwo

Copy link
Copy Markdown
Contributor

I looked at this once. Since this PR adds new public API and conf, I need some more time to think about the changes.

@szetszwo szetszwo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Elia-Renzoni , thanks for working on this! It looks quite good.

  • Please use 2-space for indentation.
  • See also the comments inlined.

Comment thread ratis-server-api/src/main/java/org/apache/ratis/server/RaftServerConfigKeys.java Outdated
Comment thread ratis-server/src/main/java/org/apache/ratis/server/impl/TransferLeadership.java Outdated
Comment thread ratis-server/src/main/java/org/apache/ratis/server/impl/TransferLeadership.java Outdated
Comment thread ratis-server/src/main/java/org/apache/ratis/server/impl/TransferLeadership.java Outdated
Comment thread ratis-server/src/main/java/org/apache/ratis/server/leader/LogAppenderDefault.java Outdated
@Elia-Renzoni
Elia-Renzoni force-pushed the refactor/transfer-leadership branch from 7a9f350 to 110c11a Compare October 1, 2026 13:41
@Elia-Renzoni
Elia-Renzoni requested a review from szetszwo October 1, 2026 13:43
Signed-off-by: Elia Renzoni <[email protected]>
@szetszwo

szetszwo commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Elia-Renzoni force-pushed the refactor/transfer-leadership branch from 7a9f350 to 110c11a

@Elia-Renzoni , please don't force push after a review has started. Otherwise, it also forces the reviewers to read everything again since it is hard to see only the new changes.

@szetszwo szetszwo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 the change looks good!

@szetszwo
szetszwo merged commit 4915a26 into apache:master Oct 1, 2026
16 checks passed
@szetszwo szetszwo changed the title RATIS-2311. Control appliedIndex before starting a transfer election RATIS-2311. Check appliedIndex gap before starting a transfer election Oct 1, 2026
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.

2 participants