Skip to content

[server] Fix spurious ISR shrink after leader election#3702

Open
fxbing wants to merge 1 commit into
apache:mainfrom
fxbing:fix/20260720-spurious-isr-shrink
Open

[server] Fix spurious ISR shrink after leader election#3702
fxbing wants to merge 1 commit into
apache:mainfrom
fxbing:fix/20260720-spurious-isr-shrink

Conversation

@fxbing

@fxbing fxbing commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Purpose

Linked issue: close #3698

A newly elected leader may remove healthy followers from ISR immediately after the first write because their newly created FollowerReplica state does not receive the normal lag grace period.

A repeated NotifyLeaderAndIsr request can also replace existing FollowerReplica objects and discard their fetch offsets and caught-up timestamps, causing the same spurious ISR shrink.

Brief change log

  • Preserve existing FollowerReplica objects for unchanged assignments.
  • Reset follower state when the leader epoch advances:
    • initialize ISR followers with the normal lag grace period for a new leader;
    • preserve follower LEO for a same-broker leader re-election.
  • Keep follower state unchanged for repeated notifications with the same leader epoch.
  • Add regression tests for the initial leader election, repeated notification, and same-broker re-election cases.

Tests

  • AdjustIsrTest#testShrinkIsr
  • AdjustIsrTest#testDoNotShrinkIsrAfterRepeatedNotifyLeaderAndIsr
  • AdjustIsrTest#testPreserveFollowerStateOnLeaderReelection
  • AdjustIsrTest, FollowerReplicaTest, and ReplicaTest: 25 tests passed.
  • Checkstyle and Spotless checks passed.

API and Format

No public API, configuration, metric, RPC, or storage-format changes.

Documentation

No documentation changes. This is an internal replica lifecycle bug fix.

Generative AI disclosure

Yes. Generated with OpenAI Codex and reviewed by the human developer.

Preserve follower fetch state across repeated leader notifications and reset follower state only when the leader epoch advances.

Fixes apache#3698.
@fxbing
fxbing marked this pull request as ready for review July 20, 2026 07:07
@fxbing fxbing closed this Jul 20, 2026
@fxbing fxbing reopened this Jul 20, 2026
@fxbing fxbing closed this Jul 20, 2026
@fxbing fxbing reopened this Jul 20, 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.

[server] NotifyLeaderAndIsr may trigger a spurious ISR shrink

1 participant