Skip to content

IGNITE-28105 Ensure new leader clock is not lower than last applied cmd#7731

Open
EgorKuts wants to merge 2 commits intoapache:mainfrom
EgorKuts:ignite-28105
Open

IGNITE-28105 Ensure new leader clock is not lower than last applied cmd#7731
EgorKuts wants to merge 2 commits intoapache:mainfrom
EgorKuts:ignite-28105

Conversation

@EgorKuts
Copy link
Contributor

@EgorKuts EgorKuts commented Mar 9, 2026

It's possible that new elected leader would have a lower clock's value than the last applied command(see ItNewLeaderClockTest).
Such behavior breaks state machine invariants and causes all nodes in the replication group to fail.

@EgorKuts EgorKuts marked this pull request as ready for review March 9, 2026 10:54
this.currTerm
);
if (request.timestamp() != null) {
clock.update(request.timestamp());
Copy link
Contributor

Choose a reason for hiding this comment

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

Propagating HLC in each AppendEntry request creates additinal contention on HLC.
For this reason it was removed earlier.
Could we instead do it in RequestVoteRequest ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No. If the leader has the most advanced clock, it is possible for the new leader to have a stale clock value. This scenario is shown in the reproducer (2 out of 3 nodes have a lower HLC).

If we need to address the contention, I propose creating a separate clock per partition. This clock would be updated on each appendEntry and merged with the main clock when the node becomes a leader.

Co-authored-by: Aleksei Scherbakov <alexey.scherbakoff@gmail.com>
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