Repository navigation
Run one group of Keeper clusters at a time in test_keeper_snapshot_chunked_transfer - #118297
Conversation
…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]>
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.
💡 Noted, not blocking. |
|
Workflow [PR], commit [2ad3158] Summary: ✅ AI ReviewSummaryThis 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 |
|
cc @alesapin, could you review this? It is a tests-only change: |
_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]>
Changelog category (leave one):
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.pyregisters 18 long-lived servers (six independent 3-node Keeper clusters),test_concurrent.pyanother 10. They are the two heaviest files onIntegration 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) underpytest -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 atcluster.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 eb88742On this shard the sequential phase never runs, so the module would stop running altogether rather than run alone:
not has_error(ci/jobs/integration_test_job.py:1995);has_erroris set fromtest_result_parallel.is_error()(:1980-1987);--session-timeoutasserts statusERROR(:1401-1409);xdist.dsession.Interrupted: session-timeoutmarker 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
26.9.1.1353(included in26.9and later)