Repository navigation
Conversation
When a replica goes offline, ReplicaStateMachine removes it from the ISR in ZooKeeper and notifies the remaining replicas. If the ZooKeeper batch update fails, for example with BadVersion because a newer coordinator has fenced this one, the error was logged and the unsaved LeaderAndIsr was still sent to the tablet servers. The tablet servers then held a bucket epoch that ZooKeeper never stored, so the next coordinator's NotifyLeaderAndIsr was rejected as stale and the replica marked offline. Return no adjusted LeaderAndIsr when the update fails, as the leader election paths in TableBucketStateMachine already do. Generated-by: Grok Bot
Generated-by: Grok Bot
Jackeyzhe
reviewed
Dec 5, 2026
| LOG.error("Fail to batch update bucket LeaderAndIsr.", e); | ||
| } | ||
| return adjustedLeaderAndIsr; | ||
| return Collections.emptyMap(); |
Contributor
There was a problem hiding this comment.
Returning an empty map makes sense when the ZooKeeper transaction fails without committing any updates. How do we recover if only some batches commit?
batchUpdateLeaderAndIsr uses a separate ZooKeeper transaction for each batch of up to 1,024 buckets. If the first batch commits and the second fails, returning an empty map here means the coordinator neither updates its cache nor notifies the TabletServers about the buckets that were already committed. What reconciles those buckets after the failure? Could we add a test that commits the first batch, fails the second, and verifies the recovery path? The new test only covers a single bucket.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Generative AI disclosure: Yes. Prepared with Grok Bot.
Generated-by: Grok Bot following the guidelines
Purpose
Linked issue: close #5478
When a fenced coordinator takes a replica out of the ISR,
ReplicaStateMachine#doRemoveReplicaFromIsrfails to write the newLeaderAndIsrto ZooKeeper but still returns it, so it is sent to the tablet servers. They then hold an epoch that ZooKeeper never stored and reject the next coordinator'sNotifyLeaderAndIsras stale.Brief change log
doRemoveReplicaFromIsrreturns an empty map whenbatchUpdateLeaderAndIsrfails, so only persisted state is sent.TableBucketStateMachinealready aborts the same way on a fenced write.CoordinatorEventProcessor#updateBucketEpochAndSendRequeststops before sending when its write throws, so it is left as is. Its cache ordering is covered by [server] Unify LeaderAndIsr access between CoordinatorContext and ZooKeeper #5108.Tests
ReplicaStateMachineTest#testFencedIsrRemovalIsNotSentToTabletServersfences the coordinator, takes a replica offline, and checks that ZooKeeper and the coordinator cache keep the originalLeaderAndIsrand that noNotifyLeaderAndIsris sent. It fails without the change.API and Format
None.
Documentation
None.