Repository navigation
Cherry pick #119847 to 26.3: Handle a ZooKeeper Multi request without subrequests in Keeper - #120666
Merged
robot-ch-test-poll3 merged 14 commits intoSep 18, 2026
Merged
Conversation
`ZooKeeperMultiRequest::readImpl` accepted a `Multi` request whose subrequest list contained nothing but the terminator record. `preprocess` then iterated over zero subrequests, so it appended neither `SubDeltaEnd` nor `FailedMultiDelta` and returned `ZOK`, which is enough for the entry to be written to the changelog and replicated. At commit time `process` read `deltas.front()` on that empty range, guarded only by a `chassert` that is compiled out in the release build, and the process terminated on the raft commit thread. Because the entry was already durable, every restart replayed it and terminated again. The request is now rejected while it is parsed, before it can reach the changelog. `process` no longer relies on the `chassert` either: an entry written by an older version is still replayed on startup, so the empty range returns the empty (successful) multi response instead of dereferencing it. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
ZooKeeper answers such a request with an empty successful response, and a client that builds a transaction from a list that turns out to be empty sends exactly that - `kazoo`, for one, does not special-case it. Refusing the request while it is parsed would answer that client by closing its session, so keep the handling of the empty delta range in `process` as the fix (`processWatches` next to it already handles the same range) and let the request through. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
… nothing Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Address review: the success return of the empty-deltas branch in `process` for `ZooKeeperMultiRequest` is reserved for the true zero-subrequest case. A request with subrequests but without the `SubDeltaEnd` / `FailedMultiDelta` markers goes through `onStorageInconsistency` instead of a debug-only `chassert`, so a release build does not answer it with an empty success that silently drops every suboperation. Co-Authored-By: Claude Fable 5.1 <[email protected]>
Address review: TCP does not preserve message boundaries, so a one-shot `recv` may return a partial connect response, length prefix, or `multi` body. Add `recv_exactly` and `recv_frame` helpers and use them for both the handshake and the `multi` reply. Co-Authored-By: Claude Fable 5.1 <[email protected]>
…rker `extractSubdeltas` searched for the `SubDeltaEnd` marker of the next subrequest and, when the marker was missing, incremented the end iterator of the range, which is undefined behavior on the raft commit and replay threads. The `deltas.empty()` guard in `process` for `ZooKeeperMultiRequest` covered only a range without any markers at all. Now `extractSubdeltas` routes a missing marker to `onStorageInconsistency`, and `process` checks that the range is fully consumed after the last subrequest, so deltas after the last marker are not silently ignored. Addresses the AI review finding on #119847 Co-Authored-By: Claude Fable 5.1 <[email protected]>
…`test_keeper_empty_multi` kazoo serializes a transaction without operations as exactly the terminator record, so `zk.transaction().commit()` is the empty `Multi` request that the test hand-built over a raw socket. The test now uses it and asserts the empty list of results, and drops the frame helpers. #119847 (comment) Co-Authored-By: Claude Fable 5.1 <[email protected]>
…in `process` for `Multi` The failure marker of a failed `Multi` request is the only delta the rollback in `preprocess` leaves for the transaction. `process` used to trust that and answer with the failure response even if the range held more deltas, which would have dropped them silently on the commit and replay path. Now such a range goes through `onStorageInconsistency`, like the trailing deltas after the last subrequest. Co-Authored-By: Claude Fable 5.1 <[email protected]>
… of a `Multi` request `extractSubdeltas` looked only for the `SubDeltaEnd` marker, so a misplaced `FailedMultiDelta` later in the transaction was handed to `commit` as an ordinary delta of a subrequest. `commit` ignores that variant and returns `ZOK`, so a malformed delta stream such as `[UpdateNodeDataDelta, SubDeltaEnd, FailedMultiDelta, SubDeltaEnd]` was replayed as a fully successful `Multi` instead of failing closed like every other mismatch between a request and its deltas. The walk now stops on both markers and routes a failure marker inside a subrequest slice to `onStorageInconsistency`. The legitimate shape - the failure marker as the sole delta of the transaction - is still handled by the callers before they reach the walk. Co-Authored-By: Claude Fable 5.1 <[email protected]>
Handle a ZooKeeper `Multi` request without subrequests in Keeper
Resolve the Keeper storage refactoring conflict by porting the empty `Multi` request handling and delta-integrity checks into `KeeperStorage.cpp`. PR: https://github.com/ClickHouse/ClickHouse/pull/120666\nOriginal pull-request: #119847
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.
Original pull-request #119847
Do not merge this PR manually
This pull-request is a first step of an automated backporting.
It contains changes similar to calling
git cherry-picklocally.If you intend to continue backporting the changes, then resolve all conflicts if any.
Otherwise, if you do not want to backport them, then just close this pull-request.
The check results does not matter at this step - you can safely ignore them.
Before you resolve anything
Conflicts are often caused by a prerequisite change that has not been backported yet, rather than by a real divergence. The bot re-tries this cherry-pick against the release branch on every run, so if that is the case here it will merge itself as soon as the prerequisite lands, and you will see a comment saying so. Manual resolution is only needed while the conflict persists.
Troubleshooting
If the conflicts were resolved in a wrong way
If this cherry-pick PR is completely screwed by a wrong conflicts resolution, and you want to recreate it:
pr-cherrypicklabel from the PRYou also need to check the Original pull-request for
pr-backports-createdlabel, and delete if it's presented thereThe PR source
The PR is created in the CI job