Repository navigation
Description
Search before asking
- I searched in the issues and found nothing similar.
Motivation
Description
CoordinatorContext maintains an in-memory copy of LeaderAndIsr, while ZooKeeper stores the durable coordinator state. Currently, coordinator code does not have a consistent rule for deciding which source should be used.
Some paths read LeaderAndIsr from ZooKeeper even when the same snapshot is already available in CoordinatorContext or has just been read by the caller. This adds synchronous ZooKeeper round trips on the coordinator event thread.
There is also a consistency risk in write paths. For example, updateBucketEpochAndSendRequest() currently updates CoordinatorContext before writing the new LeaderAndIsr to ZooKeeper. If the ZooKeeper write fails or has an uncertain outcome, the in-memory state may diverge from the durable state.
This was identified while reviewing the rebalance recovery changes in #3860:
The task should define and apply a consistent access policy for LeaderAndIsr:
- Use the current
CoordinatorContextsnapshot for normal coordinator processing when it is known to be current. - Avoid repeated ZooKeeper reads when the caller already has the required
LeaderAndIsr. - Publish a new
LeaderAndIsrtoCoordinatorContextonly after the corresponding ZooKeeper write is confirmed. - If a ZooKeeper write has an uncertain outcome, reload the durable state and reconcile
CoordinatorContextbefore continuing. - Reload
LeaderAndIsrfrom ZooKeeper during coordinator recovery or when the in-memory state cannot be trusted. - Prefer centralizing these rules so individual call sites do not need to decide independently between ZooKeeper and
CoordinatorContext.
Regression tests should cover:
- A confirmed ZooKeeper write updates both ZooKeeper and
CoordinatorContext. - A failed write does not leave
CoordinatorContextahead of ZooKeeper. - An uncertain write outcome is reconciled from ZooKeeper.
- Recovery rebuilds the in-memory state from the durable state.
- Existing coordinator paths do not introduce redundant synchronous ZooKeeper reads.
This task should focus on the consistency contract and shared access pattern. The rebalance-specific removal of redundant reads remains part of #3860.
Solution
No response
Anything else?
No response
Willingness to contribute
- I'm willing to submit a PR!
Activity