Repository navigation
Handle a ZooKeeper Multi request without subrequests in Keeper - #119847
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]>
|
Workflow [PR], commit [5185243] Summary: ✅
AI ReviewSummaryThis PR fixes Keeper's handling of a ZooKeeper Final VerdictStatus: ✅ Approve LLVM Coverage ReportMeasured on commit 5185243.
Changed lines: Changed C/C++ lines covered: 22/27 (81.48%) · Uncovered code |
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]>
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units7 translation units recompiled, 14 s compile time in total, 7 of them have a recent master baseline. |
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]>
|
🕵 The three red stress jobs on d433b1f are unrelated to this Keeper-only change (the diff touches
I will merge master into this branch once those fixes land, so the reds clear on the next CI run. |
|
That Same signature as #119899. The null lives in the One caveat for merging master into this branch: this red clears only once #119387 lands, not on a rerun. That PR has been open and unreviewed since I pushed the reshaped predicate ( |
|
🕵 Thanks, @groeneai. Recorded: the None of the three fixes (#119387, #119700, #119715) has landed on master yet, so I am not merging master into this branch now: it would re-run the same unrelated reds. This PR itself is Keeper-only, has 0 unresolved threads and an approving AI review, and is ready for a human review and merge as is. |
|
The three |
| raise | ||
|
|
||
|
|
||
| def test_empty_multi_request(started_cluster): |
There was a problem hiding this comment.
Why not use kazoo if it supports it?
There was a problem hiding this comment.
🕵 It does: kazoo serializes a transaction without operations as exactly the terminator record, and it deserializes the empty response into an empty list. Switched the test to zk.transaction().commit() and dropped the raw-socket frame helpers in de8b439; the test passes locally.
…`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]>
Backport #119847 to 26.9: Handle a ZooKeeper `Multi` request without subrequests in Keeper
Backport #119847 to 26.7: 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
Cherry pick #119847 to 26.3: Handle a ZooKeeper `Multi` request without subrequests in Keeper
…subrequests in Keeper
Cherry pick #119847 to 26.6: Handle a ZooKeeper `Multi` request without subrequests in Keeper
…subrequests in Keeper
…t without subrequests in Keeper
Backport #119847 to 26.8: Handle a ZooKeeper `Multi` request without subrequests in Keeper
Backport #119847 to 26.6: Handle a ZooKeeper `Multi` request without subrequests in Keeper
Backport #119847 to 26.3: Handle a ZooKeeper `Multi` request without subrequests in Keeper
…t without subrequests in Keeper
A ZooKeeper
Multirequest whose subrequest list contains nothing but the terminator record parsed successfully and was preprocessed successfully: the loop over zero subrequests appended neitherSubDeltaEndnorFailedMultiDeltaand returnedZOK, which is enough for the entry to be written to the changelog and replicated to followers. At commit timeprocessreaddeltas.front()on that empty delta range - guarded only by achassert, which is compiled out in the release build - and the process terminated on the raft commit thread. The entry was already durable by then, so every restart replayed it and terminated again.processno longer relies on thechassert: an empty delta range now returns the empty (successful) multi response instead of being dereferenced, which is also the answer ZooKeeper gives such a request. The request is deliberately not refused while it is parsed - a client that builds a transaction from a list that turns out to be empty sends exactly this request (kazoodoes not special-case it), and refusing it there would answer that client by closing its session.processWatches, right next toprocess, already handled the empty range the same way.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed ClickHouse Keeper terminating when a client sent a
multirequest with no subrequests. Such a request was written to the changelog before it failed, so the termination repeated on every restart.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/119847]
Version info
26.10.1.49(included in26.10and later)26.9.1.1602,26.7.11.13,26.3.33.105