Skip to content

Backport #108810 to 26.6: Fix segfault in StreamingStorageRegistry - #109173

Merged
clickhouse-gh[bot] merged 3 commits into
26.6from
backport/26.6/108810
Sep 5, 2026
Merged

clickhouse-gh[bot] merged 3 commits into
26.6from
backport/26.6/108810

Conversation

@robot-ch-test-poll4

@robot-ch-test-poll4 robot-ch-test-poll4 commented Jul 2, 2026 •

Copy link
Copy Markdown
Contributor

Original pull-request #108810

This pull-request is a last step of an automated backporting.
Treat it as a standard pull-request: look at the checks and resolve conflicts.
Merge it only if you intend to backport changes to the target branch, otherwise just close it.

The PR source

The PR is created in the CI job

Version info

  • Merged into: 26.6.5.54

@robot-ch-test-poll4 robot-ch-test-poll4 added pr-backport Changes, backported to release branch. Do not use manually - automated use only! pr-critical-bugfix labels Jul 2, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jul 2, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [BackportPR], commit [61d63a9]

Summary: ✅

@alexey-milovidov alexey-milovidov self-assigned this Sep 4, 2026
@alexey-milovidov

Copy link
Copy Markdown
Member

🕵 @groeneai, investigate the failure: https://github.com/ClickHouse/ClickHouse/actions/runs/33922619574/job/101188237791 and provide a fix in a separate PR. If the fix is already in progress, link it here.

The job Integration tests (amd_asan_ubsan, db disk, old analyzer, 6/6) failed at the job level (Job killed, exit code [137], no per-job report uploaded) right after test_keeper_snapshot_chunked_transfer/test.py::test_recover_after_s3_read_error_during_transfer failed. The same test fails on the 26.8 release branch (2026-09-02, 2026-09-03) and on unrelated PRs, and the same shard errors on many unrelated PRs including the sibling backports #118067 and #118068. This backport is a 4-line null check in StreamingStorageRegistry::shutdown and does not touch Keeper.

@groeneai

groeneai commented Sep 5, 2026

Copy link
Copy Markdown
Collaborator

Investigated. Two separate failures here, and neither is caused by this backport.

1. exit 137 on old analyzer, 6/6. This is the 26.6 result-loss class I root-caused on 2026-08-31: #116721 (comment). The two levers I put to you there (backport #112984, or is_sequential on the heaviest module) are still open and nothing has landed since that changes them, so there is no in-progress fix for this shard to link.

This tree reproduces the signature. Five of the six old-analyzer shards uploaded results (768 to 1126 test rows each); 6/6 uploaded none, which is why there is no report. The freeze is measurable in the job's own log: 2337 lines carry both praktika's read timestamp and the runner's forward timestamp, the p99 gap is 0 s, and exactly two lines exceed 60 s. [gw2] node down was read at 23:26:32 and forwarded at 23:37:50 (678 s), and the FAILED line 164 s. PYTHONUNBUFFERED=1 is set, so that is not buffering. Then 22 min of silence to the SIGKILL.

#117412 and #117202 cannot be the fix on this branch: 26.6 starts the integration runner with --cgroupns=host and no CI_DIND_* at all (ci/defs/job_configs.py:168, and the job's own docker run line), so the /docker leaf those PRs budget does not exist here. Container memory budget exceeded occurs 0 times in the log, and gdb 0 times. 26.7 and 26.8 are configured the same way; only master has #112984's containment.

One free item that is new since 08-31: #117564 is merged on master, and scope="session" is still present in all three of its files on 26.6, 26.7 and 26.8. v26.6-must-backport on it reaches all three. On this shard it only removes test_distributed_over_distributed's leak, so I am not claiming it fixes the kill; it is correct on its own merits and it is the only lever I can act on without the decision above.

2. test_recover_after_s3_read_error_during_transfer. The 26.8 failures look like my own regression.

On this tree the FAILED line is the report of the crashed worker, not an assertion: node down precedes it by 8.5 min, the log has no traceback, and 6/6 uploaded no rows, so CIDB has nothing for it here.

The 26.8 failures you cite are real and separate: 26 failures over 16 trees in 45 days, every one on Integration tests (amd_asan_ubsan, db disk, 2/4). Classified once each: 9 fail at cluster startup or Keeper connection, 5 in the module's own assertions, 4 elsewhere, 1 in the Docker API, 7 carry no context. test_recover_from_snapshot_sent_by_old_leader is 16 of the 26, and wait_until_connected alone is the top single site at 6.

Two controls:

  • that check name does not exist on master (0 rows in 14 days, against 76 to 98 trees on each of 26.7 and 26.8), so master's zero is exposure and not health;
  • 26.7 runs the same check with the same module mix at comparable exposure and fails 0 of 825, while 26.8 fails 26 of 758.

The 26.8-vs-26.7 delta for this module is 7 commits, and two of them are mine. #113992 (merged 2026-08-19) rewrote the old-leader read path of test_recover_from_snapshot_sent_by_old_leader, which is the test behind 16 of the 26 failures, and #114055 (merged 2026-08-12) changed the catch-up wait in helpers/keeper_utils.py, which is where wait_until_connected lives. 26.7 has neither and fails 0; master has both but never runs the exposing shard. The remaining delta is #113903 and #108473 in the two helpers.

So I am treating my own #113992 as the prime suspect rather than the test being generically flaky. That is a suspect and not yet a proven cause, so I am not sending a speculative change: a fix task is created, and I will post the fixing-PR link here when it opens.

@alexey-milovidov

Copy link
Copy Markdown
Member

🕵 Thanks for the investigation. Agreed that neither failure is caused by this backport (a null check in StreamingStorageRegistry::shutdown). I merged the current 26.6 into the branch to trigger a fresh CI run; the 6/6 shard kill stays tracked in your #116721 thread, and the test_keeper_snapshot_chunked_transfer fix task is yours. Nothing else to change here; the merge is for automation.

@clickhouse-gh
clickhouse-gh Bot merged commit 5c53835 into 26.6 Sep 5, 2026
39 checks passed
@clickhouse-gh
clickhouse-gh Bot deleted the backport/26.6/108810 branch September 5, 2026 10:51
@groeneai

groeneai commented Sep 5, 2026

Copy link
Copy Markdown
Collaborator

Fix: #118297.

Two corrections to what I posted earlier in this thread, both of which my own measurements refuted:

  1. I said I was treating my Route old-leader reads through Raft in the Keeper compat snapshot test #113992 as the prime suspect. It is not the cause. 15 of the 26 failures are in test_recover_from_snapshot_sent_by_old_leader, which it did change, but 11 are in tests it never touched (test_recover_with_chunk_size_larger_than_snapshot x7, test_recover_after_s3_read_error_during_transfer x3, test_recover_after_interrupted_transfer[remote_disk] x1), and in both multi-failure trees a different module's xdist worker died first ([gwN] node down: Not properly terminated). The wait_until_connected line it added is the earliest line in that test that touches the network, so it is a detector, not a cause.
  2. I said 26.7 runs the same check with the same module mix. That is wrong. Extracted from each job's own pytest argv, 26.7's 2/4 runs 202 modules and 26.8's runs 214, with only 86 shared: both release branches still carry the 302-row dur > 60000 duration table, so most suites are packed round-robin over the branch's own file list and a different file list repacks every shard.

What it actually is: the module registers 18 long-lived servers, the heaviest of the shard's 258 test files, inside a job capped at 59.77 GiB running pytest -n 3 --dist=loadfile. Both collapses I read start with a co-tenant module's worker dying, after which this module's servers report connect-refused or RST. The PR keeps every instance registered and keeps only one group of clusters running at a time: measured with an ASAN build, peak container working set falls from 26.2 GiB to 13.3-14.2 GiB and sustained concurrent servers from 18 to 10, for +17% module wall clock.

It reduces this module's demand rather than closing the shard's 7200 s overrun, and it does not need a CI-config change. #116591 raising the release-branch set from 4 to 6 batches landed after the 26.8 cut, so 26.8 does not have it; whether to backport that, and whether to label this PR for 26.8, are your call.

groeneai added a commit to groeneai/ClickHouse that referenced this pull request 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]>
pull Bot pushed a commit to sowelswl/ClickHouse that referenced this pull request Sep 13, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-backport Changes, backported to release branch. Do not use manually - automated use only! pr-critical-bugfix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants