Skip to content

Cherry pick #119847 to 26.6: Handle a ZooKeeper Multi request without subrequests in Keeper - #120667

Merged
robot-ch-test-poll3 merged 15 commits into
backport/26.6/119847from
cherrypick/26.6/119847
Sep 18, 2026
Merged

robot-ch-test-poll3 merged 15 commits into
backport/26.6/119847from
cherrypick/26.6/119847

Conversation

@robot-clickhouse

Copy link
Copy Markdown
Member

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-pick locally.
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:

  • delete the pr-cherrypick label from the PR
  • delete this branch from the repository

You also need to check the Original pull-request for pr-backports-created label, and delete if it's presented there

The PR source

The PR is created in the CI job

alexey-milovidov and others added 13 commits September 13, 2026 20:01
`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]>
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
@robot-clickhouse robot-clickhouse added pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only! do not test disable testing on pull request pr-critical-bugfix labels Sep 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do not test disable testing on pull request pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only! pr-critical-bugfix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants