Skip to content

Run one group of Keeper clusters at a time in test_keeper_snapshot_chunked_transfer - #118297

Merged
alexey-milovidov merged 2 commits into
ClickHouse:masterfrom
groeneai:keeper-snapshot-chunked-transfer-one-cluster-at-a-time
Sep 13, 2026
Merged

alexey-milovidov merged 2 commits into
ClickHouse:masterfrom
groeneai:keeper-snapshot-chunked-transfer-one-cluster-at-a-time

Conversation

@groeneai

@groeneai groeneai commented Sep 5, 2026 •

Copy link
Copy Markdown
Collaborator

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

...

Description

Requested by @ alexey-milovidov in #109173 (comment) ("the ... fix task is yours").

test.py registers 18 long-lived servers (six independent 3-node Keeper clusters), test_concurrent.py another 10. They are the two heaviest files on Integration tests (amd_asan_ubsan, db disk, 2/4) (214 modules, 258 files, 444 servers); the next heaviest registers 8. The runner container is capped at 59.77 GiB (--memory=64183296000) under pytest -n 3 --dist=loadfile, so one worker holds a whole module. On 26.8 it fails 26 of 758 runs of that check; 26.7 fails 0 of 825. In both collapses I read, a co-tenant's worker dies first ([gwN] node down: Not properly terminated) and this module's servers follow with connect-refused or RST: job 1, job 2.

An idle sanitizer server costs about as much memory as a busy one, so every instance stays registered (coverage unchanged) while only one group runs: the local-disk and S3 cluster pair sharing a snapshot chunk setting, two of the six. Rotating per cluster would stop three more sanitizer servers (1.4-3.0 GiB each) but raise phase changes from 2 to 7 at this parameter order, where two already cost ~83 s; your call if you would rather have the memory.

Measured on one ASAN build with docker stats: peak container working set 26.2 -> 13.3-14.2 GiB, sustained servers 18 -> 10, wall clock 492 -> ~575 s (+17%). The 18-server spike at cluster.start() is unchanged, since it cannot start a subset. The four pinned-release servers stay up throughout: a release Keeper aborts on a snapshot from the newer server it is clustered with (Unsupported snapshot version).

Why not is_sequential=True, as in eb88742

On this shard the sequential phase never runs, so the module would stop running altogether rather than run alone:

  • it is gated on not has_error (ci/jobs/integration_test_job.py:1995);
  • has_error is set from test_result_parallel.is_error() (:1980-1987);
  • a graceful --session-timeout asserts status ERROR (:1401-1409);
  • that xdist.dsession.Interrupted: session-timeout marker is present in all three jobs of this shard I measured: 26.7 at 7278.81 s, 26.8 at 7351.04 s and 7420.93 s, against a 7200 s budget.

That would remove the module's 9 passing tests along with its 26 failures, and it would change nothing on master, which never schedules this module on this shard.

This cuts demand, not the shard's own overrun; on the supply side #116591 (merged after the 26.8 cut) raises the release-branch set to 6 batches and #115785 would size workers from the job cgroup limit, neither overlapping this diff.


Workflow [PR]
Sync PR [sync-upstream/pr/118297]

Version info

  • Merged into: 26.9.1.1353 (included in 26.9 and later)

…unked_transfer

test.py registers 18 long-lived servers (six independent 3-node Keeper
clusters) and test_concurrent.py another 10. They are the two heaviest of
the 258 test files on Integration tests (amd_asan_ubsan, db disk, 2/4)
(214 modules, 444 servers in total); the next heaviest single file
registers 8. The job's runner container is capped at 59.77 GiB and runs
pytest -n 3 --dist=loadfile, so a single xdist worker holds an entire
cluster; when the co-workers also hold heavy modules the runner's memory
killer takes the worker down and the dead containers surface as
connect-refused, RST or "Cannot start ClickHouse" in whichever test was
running. The module fails 26 times in 758 runs of that check on 26.8
against 0 in 825 on 26.7.

An idle sanitizer server costs about as much resident memory as a busy
one. Every instance stays registered, so coverage is unchanged, and only
one group of clusters stays running: the local-disk and S3 pair that
share a snapshot chunk setting, two of the six. Rotating per cluster
instead of per group would stop three more sanitizer servers but raise
cluster restarts from 2 to 7 at this parameter order, and this shard
already overruns its 7200 s session timeout. use_keeper_phase recomputes
the wanted state from each container's live process state on every call
rather than remembering the previous phase: every test here stops a node
mid-test and restarts it later, so a test that fails in between leaves a
node of the current phase down and the next test needs it back.

Two properties the module previously got for free from cluster.start()
have to be re-established after a restart, and both were found by
observing the failures rather than by reading the code:

  - a phase's servers must come up together. A Keeper server started on
    its own waits out keeper_server.startup_timeout (180 s) for a quorum
    only its peers can form, while start_clickhouse blocks on readiness,
    so the starts run concurrently.
  - a cluster's first server must hold leadership. It has the top
    priority and the others start as followers, and no test kills it, so
    pinning leadership there (via the rqld four-letter command) keeps a
    test's kill of a lagging node from removing the leader; a
    re-election drops the writes then in flight and surfaced as
    kazoo ConnectionLoss inside fill_test_tree.

The four servers running a pinned release are excluded from the rotation
and stay up for the whole module: a release Keeper aborts at startup on a
snapshot written by the newer server it is clustered with ("Unsupported
snapshot version", "Manual intervention is necessary for recovery"), so
restarting one is unrecoverable. They are also the only non-sanitizer
servers here, at 0.16-0.27 GiB each against 1.4-3.0 GiB.

Measured locally on one ASAN build (master d1adb9f, build id
05FA8FDC83C1C7051AA42F9DC4EDAA98B469E4B0), sampling docker stats over the
module's containers: peak sum of container working set falls from
26.21 GiB to 13.29-14.18 GiB over six green runs and sustained concurrent
servers from 18 to 10, for +17% module wall clock (492 s to ~575 s
median). Both arms ran on that one binary; the before arm was re-measured
after the shared build snapshot was refreshed mid-campaign, so the
comparison is not across binaries. The 18-server spike at cluster.start()
itself is unchanged, because add_instance has no deferred-start knob and
cluster.start() cannot start a subset; what goes away is sustained
residency, which is where the peak actually occurred.

Related: ClickHouse#109173

Co-Authored-By: Claude Opus 5 <[email protected]>
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-request PR origin: a maintainer pinged or directed groeneai labels Sep 5, 2026
@groeneai

groeneai commented Sep 5, 2026

Copy link
Copy Markdown
Collaborator Author
Internal second-model review (no blocker; 1 major agreed and fixed, 3 nits noted)

Cold own review plus an independent second-model pass, over two rounds; the second round returned no findings on the tree published here.

❌ Blockers: none.

⚠️ Agreed and fixed before publishing. The text promised "one Keeper cluster at a time" while a group keeps two independent clusters up (small is node1-3 and node7-9, and each parameter uses one of them). The code is deliberately coarse; the title, description and commit message were what was wrong, and all three now say "group" and state the per-cluster alternative with its cost. Two figures in the commit message were wrong as well, and are corrected against a re-measurement from the job's own module list: the shard holds 258 test files with the next heaviest registering 8 add_instance calls, and the memory comparison is now the same-binary arm (26.2 to 13.3-14.2 GiB, +17% wall clock).

💡 Noted, not blocking. start_keeper_phase_only is a specialization of use_keeper_phase and the fixture could call the general helper instead; _wait_serving_requests's timeout governs only the connect-refused path, because wait_until_connected keeps its own 30 s default, as every pre-existing call in this module already does; the outgoing group is stopped sequentially while the incoming one starts concurrently, which is most of the +17%.

@clickhouse-gh

clickhouse-gh Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [2ad3158]

Summary: ✅


AI Review

Summary

This PR restructures the Keeper snapshot integration tests so only one phase/group of Keeper clusters stays running at a time, while preserving the existing test coverage through explicit phase switches. I reviewed the current diff and the surrounding helper code, re-checked the prior timeout finding against the current tree, and did not find any remaining correctness or coverage regressions.

Final Verdict

✅ No new findings. The previously reported _wait_serving_requests timeout issue is fixed in the current head, and the PR is in good shape from the review side.

@groeneai

groeneai commented Sep 5, 2026

Copy link
Copy Markdown
Collaborator Author

cc @alesapin, could you review this? It is a tests-only change: test_keeper_snapshot_chunked_transfer keeps all 18 registered servers but leaves only one group of Keeper clusters running at a time, which cuts the module sustained footprint from 26.2 GiB to 13.3-14.2 GiB on the 59.77 GiB amd_asan_ubsan, db disk, 2/4 job where it fails 26 of 758 runs on 26.8.

@clickhouse-gh clickhouse-gh Bot added the comp-testing Test content only (no production code). label Sep 5, 2026
_wait_serving_requests retried keeper_utils.wait_until_connected on a refused
connect until its own deadline, but let the helper's 30 s default bound the wait
for the "This instance is not currently serving requests" answer. That answer is
not startup-only: MonitorCommand returns it whenever KeeperDispatcher is not
active, which is checkInit() && hasLeader() && !isRecovering(), so a cluster that
has not elected a leader yet gives it. The helper raises a plain Exception there
rather than an OSError, so the retry loop did not cover it either, and a phase
needing more than 30 s to settle failed although its caller allowed 180 s and the
leadership wait right after it allows 180 s of its own and drives the election
with rqld.

Measured against the previous commit with a stub keeper_utils: given a 3 s caller
budget the not-serving wait ran 30.1 s and raised "30.0s timeout", so the caller's
budget was ignored in both directions. With the remaining budget threaded through,
that case ends at 3.0 s, the refused-connect retry still stops at the caller's
deadline, and the budget handed down shrinks across retries (180.0, 179.5, 179.0).
An ASan run of the module logs timeout=179.999998 for the phase waits while the
module's own direct wait_until_connected calls keep the 30 s default.

Reported by the AI review on the pull request.

Related: ClickHouse#109173

Co-Authored-By: Claude Opus 5 <[email protected]>
@alexey-milovidov alexey-milovidov self-assigned this Sep 13, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Sep 13, 2026
Merged via the queue into ClickHouse:master with commit 5f46b05 Sep 13, 2026
174 checks passed
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-synced-to-cloud The PR is synced to the cloud repo label Sep 13, 2026
@clickhouse-gh clickhouse-gh Bot added comp-keeper ClickHouse Keeper (Raft-based coordination layer; ZooKeeper replacement) and ZooKeeper client lib... and removed comp-testing Test content only (no production code). labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors comp-keeper ClickHouse Keeper (Raft-based coordination layer; ZooKeeper replacement) and ZooKeeper client lib... groeneai-origin-request PR origin: a maintainer pinged or directed groeneai pr-ci pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants