Repository navigation
Fix Kafka temporary partition locking iterating the unshuffled list - #108033
Merged
Merged
Conversation
In KeeperHandlingConsumer::lockTemporaryLocksLocked the code shuffled a copy (available_topic_partitions_copy) but then iterated the original, unshuffled available_topic_partitions, so the std::shuffle had no effect and every replica walked partitions in the same order, biasing lock acquisition. Closes: #102049 Related: #102757 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Contributor
|
Workflow [PR], commit [504ff74] Summary: ✅
AI ReviewSummaryThis PR changes Final VerdictStatus: ✅ Approve |
Contributor
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered by tests: 5/5 (100.00%) | Lost baseline coverage (was covered on master, now uncovered in this PR): 1 line(s) · Uncovered code |
1 task
zeekay
pushed a commit
to hanzoai/datastore
that referenced
this pull request
Sep 11, 2026
…e-temporary-locks Fix Kafka temporary partition locking iterating the unshuffled list
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.
In
KeeperHandlingConsumer::lockTemporaryLocksLocked, the code builds a copy of the available topic partitions and shuffles it (available_topic_partitions_copy), but then iterates the original, unshuffledavailable_topic_partitions. The shuffle result was therefore unused, so every replica walked the partitions in the same deterministic order each round, biasing all replicas toward the same partitions and increasing temporary-lock contention. This iterates the shuffled copy, as the surroundingstd::shuffleclearly intends.Testing: this is not covered by a targeted automated test because it concerns the randomized fairness of temporary-lock distribution across replicas, which is not deterministically observable; the existing Kafka integration tests continue to cover functional correctness. The fix is a one-line correction that makes the already-present
std::shuffletake effect.Note on the changelog category: although this corrects code that did not behave as written, its only user-visible effect is fairer distribution of temporary partition locks across replicas and reduced lock contention - query results were never affected. It is therefore categorized as an
Improvementrather than aBug Fix, which also matches the fact that the randomized-fairness behavior cannot be covered by a deterministic regression test.This revives the change from the closed PR #102757 (closed for process reasons) and rebases it onto current
master.Closes: #102049
Related: #102757
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
The Keeper-based Kafka consumer now randomizes the order in which it acquires temporary partition locks across replicas, improving fairness of partition distribution and reducing lock contention. Previously the intended
std::shufflehad no effect because the iteration used the unshuffled list.Documentation entry for user-facing changes
Version info
26.7.1.234(included in26.7and later)