Skip to content

CAS: replica HTTP dies on green-path soak after relink NETWORK_ERROR storm #2233

Closed

Description

@alsugiliazova

✅ I checked the Altinity Stable Builds lifecycle table, and the Altinity Stable Build version I'm using is still supported.

Type of problem

Bug report - something's broken

Describe the situation

On a two-replica ReplicatedMergeTree over a shared CAS pool, the green-path CAS soak (phase 1: inserts/merges/mutations, no chaos) loses a replica after two successful checkpoints. HTTP to that replica starts resetting or refusing connections. The dying INSERT is deterministic for --seed 1: op_id=102, target=0.

This is an availability failure, not a pool-corruption failure. cas-fsck at the last successful checkpoint and in the failure dump is clean (dangling=0, unreachable=0, stale_edge=0). There is no <Fatal>, no core dump, and (on the regression topology, which does not set a 28g mem_limit) no OOM: Docker still reports the container healthy while the published HTTP port is already dead.

Every clickhouse-server.err.log error on both replicas is the CAS relink confirm refusal:

Code: 210. NETWORK_ERROR
Source … did not prove it still holds the manifest it offered for part … by relink;
the relink is abandoned and the fetch will be retried later.

#2219 documents that this throw is a designed retry-later outcome and should not be logged at Error. That issue also states that replication still converges and lag stays flat. Soak phase 1 disagrees on availability: under the same refusal storm a replica stops answering HTTP, so the cluster is not merely noisy — it is no longer queryable on that node.

This issue:

  • Kills replica HTTP during green-path CAS replication (no injected faults)
  • Reproduces on both the upstream utils/ca-soak compose (PR #2073) and the cas/soak port in clickhouse-regression
  • Leaves the CAS pool consistent (fsck dangling=0)
  • Is not explained by a bad soak port: Python diffs vs PR [WIP] CAS draft (adopting to CI/CD, not for review / merge) #2073 are only helpers.cluster env wiring (CA_SOAK_*, chaos restart of clickhouse-server); phase 1 does not use chaos

How to reproduce the behavior

Environment

  • Version: 26.6.2.20000.altinityantalya
  • Build type: release, ARM (build_arm_release)
  • Package: PR #2159 187e06612862e0000e7ac0431ced66ded8283bea
    • https://altinity-build-artifacts.s3.amazonaws.com/PRs/2159/187e06612862e0000e7ac0431ced66ded8283bea/build_arm_release/clickhouse-common-static_26.6.2.20000.altinityantalya_arm64.deb
  • Also seen on the same PR at f76335f4d1a3933d80fe9812e47eca3f61eaa686
  • Topology: 2 replicas, one RustFS CAS pool, ClickHouse Keeper (upstream compose) or ZooKeeper (cas/soak soak_env)

A one-row relink smoke on the same cluster does work (INSERT on replica 1, SELECT on replica 2 returns the row). The failure needs the soak write rate (many small parts, overlapping fetches).

Steps (upstream harness, PR #2073)

  1. Mount the 26.6 CAS-capable binary at build/programs/clickhouse (the compose bind-mounts it over /usr/bin/clickhouse in clickhouse/clickhouse-server:25.8).

  2. From utils/ca-soak:

docker compose up -d
# wait until http://localhost:8123/ping and :8124/ping answer
PYTHONPATH="$(pwd)" python3 -m soak.run --seed 1 --phase 1 --ops 200 --checkpoint-every 50
  1. Same shape via the regression port:
cd cas/soak
./regression.py --local --with-analyzer \
  --clickhouse-binary-path '<the same .deb URL>' \
  --suite phase1 --seed 1

Expected behavior

Phase 1 should finish 200 ops with checkpoints at 50 / 100 / 150 / 200. Both replicas should keep answering HTTP. Relink confirm refusals may happen and should retry (see #2219); they must not take a replica offline.


Actual behavior

On release builds

Checkpoints 50 and 100 succeed (dangling=0). Immediately afterwards the driver dies:

[soak.run] checkpoint OK: … dangling=0 stale_edge=0 dryrun_count=0
[soak.run] checkpoint GC PHASES [Node(localhost:8123)]: GC PHASES rounds=48 …
[soak.run] checkpoint GC PHASES [Node(localhost:8124)]: unavailable (node unreadable, …)
TRANSPORT FAILURE: [Errno 54] Connection reset by peer
  # regression soak_env: clickhouse1 HTTP resets; clickhouse2 still answers `1`
  # upstream compose: Connection refused after the peer exits / stops listening

Failure dump (failure.json / soak stdout):

"op_id": 102,
"last_op": {"op_id": 102, "type": "insert", "target": 0, "param": 52792},
"error": "TRANSPORT FAILURE: …",
"fsck": { "dangling": 0, "unreachable": 0, "stale_edge": 0 }

clickhouse-server.err.log on both replicas is dominated by:

<Error> ca_soak.ca_stress (…): … processQueueEntry …:
Code: 210. DB::Exception: Source … did not prove it still holds the manifest
it offered for part 20260818_3_3_0 by relink; the relink is abandoned and the
fetch will be retried later. (NETWORK_ERROR)

4. DB::DataPartsExchange::Fetcher::relinkPartToDisk(...)
5. DB::DataPartsExchange::Fetcher::fetchSelectedPart(...)
7. DB::StorageReplicatedMergeTree::fetchPart(...)
8. DB::StorageReplicatedMergeTree::executeFetch(...)

Observed counts on the PR #2073 compose run with the 187e0661… binary: 278 such errors on ch1, 214 on ch2, plus 5× Code: 1000 on each. Zero <Fatal> lines.

On the cas/soak topology (no 28g mem_limit): both containers stayed Up (healthy) while host curl :8123/ping was already Connection reset and :8124 still returned 1. Docker healthcheck ≠ HTTP alive.


Root cause analysis

Not fully pinned. The throw site is intentional taxonomy row 3 in DataPartsExchange.cpp:

throw Exception(ErrorCodes::NETWORK_ERROR,
    "Source {} did not prove it still holds the manifest it offered for part {} by relink; "
    "the relink is abandoned and the fetch will be retried later",
    fetch_uri.getHost(), part_name);

CasRefLedger::confirmExactRef returns Unknown when the source ref lane is not quiescent (lane_state != Ready, pending work, or leader_active). The receiver then abandons that relink and the replicated-queue retries later. #2219 is about logging that as Error.

What soak adds: under a burst of small parts the retry loop and confirm HTTP (cas_confirm) run concurrently with live inserts. Something on the source replica then stops serving HTTP (reset / refuse) without a Fatal. Candidates to investigate, not confirmed:

  • Confirm / fetch HTTP on the source replica saturating or wedging the server HTTP path (healthcheck inside the container can still pass while the published port resets)
  • Retry amplification: NETWORK_ERROR is in the retry-later class, so a busy lane produces a storm of relinkPartToDisk attempts against a source that is itself writing
  • Memory: upstream compose sets mem_limit: 28g per node. On a 16 GiB Docker Desktop VM a lowered 4g cap cgroup-OOM-killed ch2 after the relink storm had already started; the regression soak_env run (no such cap) still lost HTTP without OOM. Treat OOM as a possible aggravator, not the primary explanation

Additional context

Related

  • #2219 — same exception, scoped to log severity; claims no replication/availability impact
  • PR #2159 — CAS on antalya-26.6 (binary under test)
  • PR #2073 — utils/ca-soak harness (cas-gc-rebuild)

Notes

  • Phase 1 sets transport_resilient=False, so the first HTTP reset ends the soak. That is harness policy; the replica going dark is the product bug
  • Single-row relink smoke (CREATE + INSERT + SYSTEM SYNC REPLICA + SELECT) passes on the same binary and compose
  • Local logs from the PR [WIP] CAS draft (adopting to CI/CD, not for review / merge) #2073 run: utils/ca-soak/logs/phase1_upstream_187e066.log and utils/ca-soak/logs/archive_4g/ch{1,2}.err.log on the machine that reproduced it

Activity

  1. DimensionWieldr commented on Aug 20, 2026

    @DimensionWieldr
    Collaborator

    Was not able to reproduce this on ARM runner in clickhouse-regression CI: https://github.com/Altinity/clickhouse-regression/actions/runs/32292821417

    The run passed phase 1.

    I'm going to run all phases and scenarios and report back results.

  2. filimonov commented on Aug 20, 2026

    @filimonov
    Member

    Adjudicated against the current cas-gc-rebuild head (functionally identical to the 187e0661/f76335f4 snapshots — nothing in src/ changed since 2026-08-05).

    The refusal storm is known, designed behavior (same finding as #2219). confirmExactRef rule 3 is a table-scoped, wait-free quiescence snapshot: any pending ref-lane work on the source refuses every confirm with Unknown, so a continuously-writing source refuses most relink confirms. Fail-closed by design — the confirm is zero-I/O so a peer cannot amplify it into work on the writer; the receiver abandons, the queue backs off (≤60 s) and eventually byte-fetches. Measured on 2026-07-29: ~248k refusals in 32 min, peak 9,219/min, zero correctness or availability consequence. Open follow-ups tracked: log demotion (#2219), proven/refused ProfileEvents, naming the refusing rule, and a per-ref refinement of rule 3 (the actual availability fix).

    The causal claim does not reproduce. Exact recipe (PR #2073 compose, fresh pool, --seed 1 --phase 1 --ops 200 --checkpoint-every 50, release binary at head), on a 91 GiB bare-metal Linux host: all four checkpoints green (dangling=0), op 102 uneventful, PHASE1 OK, both replicas answering /ping throughout — while generating 207,627 refusals on ch1 + 85,912 on ch2, ~1000× the issue's counts. A 90-minute phase-3 soak with 112k refusals is also on record, green. The storm does not kill HTTP; the replica death is a separate variable.

    Likelier explanations for the observed death:

    1. VM-level OOM: mem_limit: 28g × 2 on a 16 GiB Docker Desktop VM — the VM's OOM killer SIGKILLs the server process with no cgroup event, no <Fatal>, no unhealthy container. "Connection refused after the peer exits" matches exactly.
    2. Healthcheck coverage: in the PR [WIP] CAS draft (adopting to CI/CD, not for review / merge) #2073 compose only ch1 has a healthcheck; "healthy container, dead HTTP" on ch2 is vacuous — Docker was never asked. (Harness gap, now in the backlog.)
    3. Harness labeling: phase 1 = one attempt (transport_resilient=False), checkpoints don't gate on HTTP health, and TRANSPORT FAILURE is the driver's else-branch catch-all — the headline string classifies "something non-query threw", it diagnoses nothing.

    The abandoned-relink path was audited for fd/socket/thread leaks: none (both HTTP buffers drained and returned to the pool before the throw; the precommit released by SCOPE_EXIT).

    One server-side lead not excluded, if the process was still alive when 8123 reset: all listeners share one Poco thread pool capped at max_connections, and Poco has a documented defect (comment in base/poco/Net/src/TCPServerDispatcher.cpp) where a saturated shared pool silently drops accepted sockets — reset for the client, nothing above Warning in the log. Refusals feed it indirectly: they degrade relinks into byte fetches, which do hold interserver threads. Shape-match, not proof.

    To settle it, capture on a re-run:

    • did the server process survive; did native (9000) and interserver (9009) ports still answer when 8123 reset;
    • dmesg inside the Docker Desktop VM (Out of memory: Killed process ... clickhouse-serv);
    • Warning lines "Got an exception while starting thread for connection" in clickhouse-server.log;
    • fd/thread counts vs max_connections at death; system.replicated_fetches (byte-fetch spike);
    • the two logs referenced in the issue (phase1_upstream_187e066.log, archive_4g/ch{1,2}.err.log) — not present on the shared machine.

    Bottom line: the storm part is the known #2219 behavior with tracked follow-ups; "storm kills replica HTTP" is counter-evidenced at 1000× scale and does not reproduce. Pending the data above, the death is most consistent with VM-level OOM on an undersized Docker Desktop VM.

  3. filimonov commented on Aug 20, 2026

    @filimonov
    Member

    TLDR version: problem with HTTP - can't reproduce (need artifacts from your run), others are known behavior. some minors noted to backlog.

    UPD: checking if can be connected to #2243

  4. DimensionWieldr commented on Aug 20, 2026

    @DimensionWieldr
    Collaborator

    Follow-up to the ARM CI phase-1 pass (run 32292821417).

    On a dedicated aarch64 box, I ran cas/soak --suite all --seed 1 --with-analyzer against the same package as this issue:

    https://altinity-build-artifacts.s3.amazonaws.com/PRs/2159/187e06612862e0000e7ac0431ced66ded8283bea/build_arm_release/clickhouse-common-static_26.6.2.20000.altinityantalya_arm64.deb

    Host: Ubuntu 24.04, 8 vCPU, 31 GiB RAM, 180 G disk. Topology is cas/soak/soak_env_arm64 (2 replicas, one RustFS pool, ZooKeeper). --reuse-env left the stack up after failure.

    Where Result
    This laptop, amd64 .deb of the same SHA phase 1 pass (relink NETWORK_ERROR storm present; HTTP stayed up)
    GH Actions ARM, this arm64 .deb phase 1 pass (~19m; same storm; HTTP stayed up)
    Dedicated aarch64 box, this arm64 .deb unit OK, phase 1 OK (26m), phase 2 FAIL (14m 38s). Phase 3 and scenarios did not start.

    Phase 2 died on the HTTP-availability failure, not pool corruption:

    TRANSPORT FAILURE: [Errno 104] Connection reset by peer
    op_id=52  last_op={type=insert, target=1, param=13207}
    last_fault={t_offset=529s, target=ch1, action=restart, duration_s=40}
    fsck: dangling=0 unreachable=1 stale_edge=0 exit_code=0  (fsck_status=settled)
    

    The driver retried INSERT op_id=50 through 39 transport failures (Connection refused / Connection reset by peer) before giving up. This is phase 2, so there was an injected clickhouse1 restart ~9 minutes in — not the green-path-only recipe in the issue body.

    After the suite exited, Docker still reported both ClickHouse containers Up (healthy) and OOMKilled=false. Native protocol and HTTP were already dead:

    • curl :8123/ping / :8124/ping → connection failed
    • clickhouse client on clickhouse1 → Code: 210 Connection refused (localhost:9000)

    So: phase 1 still does not reproduce the green-path HTTP death here, including on a real ARM host. Phase 2 did leave both replicas unqueryable while cgroup healthchecks stayed green — same availability signature as this issue, under chaos rather than green-path load.

  5. DimensionWieldr commented on Aug 20, 2026

    @DimensionWieldr
    Collaborator

    Phase 3 on the same dedicated aarch64 box (--seed 1, same 187e066 arm64 .deb, --phase3-duration 4h, default --workers 6) failed at 43m, still in steady (chaos had not started).

    Not the HTTP-death signature. Both /ping endpoints stayed up. The driver died on:

    Code: 252 TOO_MANY_PARTS — 3001 parts, avg 28 KiB, on clickhouse2 (INSERT into ca_soak.ca_stress). Merges could not keep up with inserts on my 8-vCPU host.

    Doesn't seem like a CAS issue, I'll run again with less workers so as not to overload the machine.

  6. filimonov commented on Aug 20, 2026

    @filimonov
    Member

    The phase-2 death is solved from the post-mortem bundle: it is a bug in the cas/soak port in Altinity/clickhouse-regression, not a server availability bug. After a chaos fault the server is simply never started again.

    Evidence (from the bundle):

    • docker ps: both ClickHouse containers run tail -f /dev/null as PID 1, and the healthcheck is literally test: echo 1, so "healthy" is unconditional — both come from cas/soak/soak_env_arm64/clickhouse-service.yml:25-27; the server is exec'd into the container by the harness at env-up.
    • docker inspect: both containers were restarted by chaos (ch2 StartedAt 19:08:40Z, ch1 19:10:00Z — the t_offset=529 fault) — created at 18:58Z, i.e. same containers, restarted in place.
    • Server logs: exactly one Starting ClickHouse and one Ready for connections per node for the whole run; ch2's log ends at 19:08:39Z — one second before its container's StartedAt. No second start was ever attempted.
    • Host pings: docker-proxy accepts and resets — nothing behind it. Both replicas ended serverless because each took a fault.

    The bug — cas/soak/soak/chaos.py:111-128, _ensure_clickhouse_daemon (called from apply_fault after every CH KILL/RESTART, chaos.py:153 and :163):

    probe = subprocess.run(
        ["docker", "exec", container, "bash", "-c", "test -f /tmp/clickhouse-server.pid"], ...)
    if probe.returncode == 0:
        return

    The guard tests pidfile existence as a server-aliveness probe. The container filesystem survives docker restart / docker kill && docker start (same container, same writable layer), and a SIGKILLed server does not remove its pidfile — so after every chaos fault the stale pidfile makes the probe return 0 and the function no-ops. The guard was written to be a no-op on the upstream compose (where the entrypoint starts the server), but the chosen discriminator false-positives on the port's own topology.

    Fix (in clickhouse-regression):

    # aliveness, not existence:
    "test -f /tmp/clickhouse-server.pid && kill -0 $(cat /tmp/clickhouse-server.pid) 2>/dev/null"

    and rm -f /tmp/clickhouse-server.pid before launching the daemon. Two adjacent gaps worth the same pass: the echo 1 healthcheck in clickhouse-service.yml:27 (and the twin in cas/soak/soak_env/) should be a real probe (HTTP /ping), and it is worth checking why the driver's recovery HTTP wait (cas/soak/soak/cluster.py:296) did not surface the serverless node for ~349 s (t=529 fault → driver death at 878 s).

    For contrast, the same fault shapes on the upstream PR #2073 harness (where the server IS the container entrypoint, so docker restart restarts it by construction) pass: phase 2 with ch1/restart/40s, ch1/kill/42s, ch1/kill/36s and a ch2 restart completed green, both replicas answering throughout.

    Scope note: this closes the phase-2/dedicated-box signature only. The original green-path phase-1 laptop failure remains unreproduced (four green runs across three hosts/arches at this point, including ~1000× the refusal volume) — the environmental suspects from the earlier comment still stand for that one.

  7. DimensionWieldr commented on Aug 21, 2026

    @DimensionWieldr
    Collaborator

    Seems like there are a few race conditions and other bugs in the soak tests on regression raising false positives. I've been fixing them, hopefully it doesn't take too long. 🤞

    UPDATE:

    Phase 3 passes after some fixes to the cas soak regression suite. Going to rerun Phase 2 to see if that was caused by test bugs as well. Then going to run soak scenarios.

    UPDATE 2:

    Rerun of Phase 2 passed on both AMD and ARM.

    Soak scenarios have a lot of bugs. Hard to tell what is a test harness bug and what's a real CAS implementation issue, will report back after some more fixes. For now there are 11 scenarios out of 45 failing, and about half seem to be real issues.

  8. added a commit that references this issue on Aug 21, 2026
  9. DimensionWieldr commented on Aug 22, 2026

    @DimensionWieldr
    Collaborator

    Scenario suite (AMD) after harness fixes

    Green-path HTTP death from this issue still has not reproduced. Phases 1–3 already pass on AMD and ARM. This is the scenario cards on AMD after the remaining harness FAILs were fixed (d13f46cb3 in clickhouse-regression).

    Binary PR #2159 187e066 — 26.6.2.20000.altinityantalya amd64
    Command --suite scenarios --seed 1 --scenario all --scenario-scale ci
    Result 32 PASS / 5 FAIL / 8 INCONCLUSIVE (4h 8m)
    Logs https://gist.github.com/DimensionWieldr/178e972ddee1dcaa06b2b802b0a41e5b

    FAIL — CAS

    Card Finding
    S01 RSS grew 0.98 GiB on a 0.50 GiB blob (Build::putBlob String copy). Pool/fsck clean. Known.
    S08 11461 / 20000 tiny-part inserts failed Code 210 (uploadFromSource UNCERTAIN / mount lease not held). Not TOO_MANY_PARTS. Remaining inserts + fsck succeeded (dangling=0).
    S13 Kill round 10: ch1 never came back (Connection refused for the rest of the card; heal timeout 300s). Replica agreement / fsck inconclusive because the node stayed down.
    S28 Concurrent wide inserts themselves PASS (replicas agree, fsck clean). 14 Failed GC rounds, all S3_ERROR Timeout on soak_pool/gc/state. RustFS write error rate ~33% in that window.
    S42 Under injected allocation faults: 9543 statements failed Code 210 UNCERTAIN (ref-log append / stageManifest / mount fence dropped) rather than only MEMORY_LIMIT_EXCEEDED. GC still had Failed rounds after disarm. CASRefNeedsRecovery=0 this run.

    INCONCLUSIVE — not CAS (card/infra reach)

    Card Why
    S06 / S21 Column-subset vs full-scan CASBlobGet — both 0 (cache/inline at ci).
    S07 Manifest hard cap not reachable via SQL (kMaxManifestEntries=1M).
    S10 Patch-part setting accepted; 0 patch parts still visible (likely merged before poll). DELETE oracle passed.
    S20 Follower CASRootCompareSwap=0 — counter may not be per-node.
    S23 1-/10-server idle baselines; compose is fixed at 2.
    S29 Non-direct-blob file too small at ci to attribute RSS.
    S38 Could not resolve a unique life-id under cas/ns/stream/ for the late-PUT injection.

    I ran ARM scenario but the disk filled during S13 (RustFS volume ~157G on a 180G disk). Suite process died mid-fsck. Will rerun ARM on a larger disk or with a pool cap.

  10. filimonov commented on Sep 14, 2026

    @filimonov
    Member

    Closing as not reproduced / superseded. The green-path HTTP death never reproduced, including the reporter's own AMD and ARM runs (phases 1–3 pass); the phase-2 death was a cas/soak harness bug in clickhouse-regression (server not restarted after a chaos fault), fixed there.

    The refusal storm is designed behaviour; its logging and error class are fixed (#2219, NO_REPLICA_HAS_PART in antalya-26.6).

    The scenario residue landed in antalya-26.6 via #2300: S28/S42 (GC round classification, retries, error_code in cas_gc_log) and the S01 lever in 2975ced; S08/S13 are the port-exhaustion class, tracked by #2243 (closed) and #2332 (open).

    Anything left from the scenario cards should go to #2332 or a fresh issue with the card's artifacts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

CASantalyaantalya-26.6bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions