Skip to content

Split amd_llvm_coverage old-analyzer parallel stateless job into batches - #108970

Merged
maxknv merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/batch-coverage-old-analyzer-parallel
Jul 1, 2026
Merged

maxknv merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/batch-coverage-old-analyzer-parallel

Conversation

@groeneai

@groeneai groeneai commented Jun 30, 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

The Stateless tests (amd_llvm_coverage, old analyzer, s3 storage, DatabaseReplicated, WasmEdge, parallel) job runs the whole stateless suite un-batched under coverage instrumentation. It is the slowest job in CI: the main test run alone takes about 1h40m to 2h10m (DatabaseReplicated forces nproc to 40% of cores, and coverage binaries are 3-5x slower), and with the post-run random-settings diagnosis and log collection the total job wall-clock reaches about 2h20m.

These runs are frequently recorded as a job-level error (exit 125, grpc: the client connection is closing: context canceled, then docker.sock: EOF) even though every test passes. In the two representative reports below the cancel fires during the post-run log-collection phase, after All tests have finished. No queries hung., so there are no individual test FAILs. This is the worst coverage shard by volume: 85 such job-level errors across 81 distinct PRs in the last 30 days, all with the same teardown signature. The exact cause of the context-cancel is under investigation with CI infra; it is not the praktika job timeout (9000s, the job runs under it) and not a GitHub job timeout.

This splits the variant into LLVM_FT_OLD_S3_DB_REPL_WASM_NUM_BATCHES (3) batches via the existing {batch}/{total} parametrization, matching the 3-batch regular coverage FT and 8-batch coverage IT pattern already in use. Each shard runs about 1/3 of the suite. Each batch uploads its own *.profdata artifact; the coverage aggregator (merge_llvm_coverage.sh) merges *.profdata by glob, so no aggregation change is needed. The LLVM_FT_ARTIFACTS_LIST (which the aggregator requires) and the generated workflow YAML are updated accordingly. The sequential sibling is unchanged.

Representative CI reports (full suite passed, 0 individual test failures, container connection severed during post-run log collection):

Version info

  • Merged into: 26.7.1.343 (included in 26.7 and later)

The "Stateless tests (amd_llvm_coverage, old analyzer, s3 storage,
DatabaseReplicated, WasmEdge, parallel)" job runs the whole stateless suite
un-batched under coverage instrumentation. It is the slowest job in CI: the
main test run alone takes about 1h40m to 2h10m (DatabaseReplicated forces
nproc to 40% of cores, and coverage binaries are 3-5x slower). After the run,
the post-run random-settings diagnosis and profdata merge push the total job
wall-clock past the runner lease, and the container is torn down mid-job
(exit 125, "grpc: the client connection is closing: context canceled"),
recorded as a job-level error even though all tests pass.

Split this variant into LLVM_FT_OLD_S3_DB_REPL_WASM_NUM_BATCHES (3) batches,
matching the existing 3-batch regular coverage FT and 8-batch coverage IT
pattern. Each shard runs about 1/3 of the suite and finishes well inside the
lease. The coverage aggregator merges *.profdata by glob, so the per-batch
profdata files are picked up with no aggregation change.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes (the failure mechanism). CIDB: 85 job-level error rows across 81 distinct PRs in 30d on this exact variant, all with zero individual test FAIL and the identical exit 125 / grpc: the client connection is closing: context canceled teardown. Job logs (PRs #108806/#108556/#108553/#108214/#108377/#103219) all show the main run alone at 5796s-7811s (1h36m-2h10m), then teardown during/after the post-run diagnosis. The slowness is deterministic; the kill is the runner-lease teardown it triggers.
b Root cause explained? This variant runs the whole stateless suite un-batched under coverage instrumentation. DatabaseReplicated caps concurrency at nproc*0.4 and coverage binaries run 3-5x slower, so the main run alone is ~1h40m-2h10m. The post-run random-settings diagnosis + profdata merge push total wall-clock past the runner lease, the container is torn down (exit 125), and CIDB records a job-level error even though all tests pass. It is by far the slowest coverage shard; the sequential sibling (far fewer tests) is unaffected.
c Fix matches root cause? Yes. Root cause is excessive wall-clock; the fix shortens it by splitting the variant into 3 batches (~1/3 of the suite each), so each shard finishes inside the lease. Raising the timeout cannot help because the runner instance itself is reclaimed.
d Test intent preserved / new tests added? Yes. No test is modified, skipped, or weakened. The same tests run, now spread over 3 shards; total coverage is identical (aggregator merges all batches' *.profdata).
e Both directions demonstrated? Validated as a CI-config change, not a test repro (running a 2h coverage job locally is not feasible; same as the merged IT-batching PR #108564). praktika Validator.validate() passes for all 18 workflows (the Config Workflow check), YAML regeneration succeeds, and the artifact provides/requires graph is consistent (3 new provides ↔ 3 new LLVM_ARTIFACTS_LIST entries the aggregator requires). The variant now expands to 3 batch jobs; the sequential sibling is unchanged.
f Fix is general across code paths? N/A (CI job-config change, not a code bug). Scoped to the single worst-offending variant (85/30d). The ParallelReplicas, parallel sibling has the same mechanism but a shorter main run (~1h15m) and far fewer errors (11/30d); left out to keep this PR focused and can get the same treatment if it continues.
g Fix generalizes across inputs? N/A (CI job-config change, not a code bug).
h Backward compatible? N/A (CI-only). No server behavior, setting, or on-disk/wire format changes.
i Invariants and contracts preserved? Yes. The coverage-artifact contract is upheld: each batch uploads its own *.profdata (filename already includes the batch suffix); merge_llvm_coverage.sh merges *.profdata by glob, so per-batch files are picked up with no aggregation change. LLVM_FT_ARTIFACTS_LIST and the generated YAML are updated so the aggregator waits for all 3 batches.

Session id: cron:clickhouse-worker-slot-9:20260630-171600

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @maxknv @leshikus — could you review this? It splits the amd_llvm_coverage, old analyzer, s3 storage, DatabaseReplicated, WasmEdge, parallel stateless job into 3 batches. That variant is the slowest job in CI (main run alone ~1h40m-2h10m un-batched), so its total wall-clock overruns the runner lease and the container is torn down mid-job (exit 125, "context canceled") and recorded as a job-level error even though all tests pass: 85 such errors across 81 PRs in 30d. Batching matches the existing 3-batch coverage FT / 8-batch coverage IT pattern; the aggregator merges *.profdata by glob so no aggregation change is needed.

@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Jun 30, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [fd755a3]

Summary: ✅


AI Review

Summary

This PR splits the slow Stateless tests (amd_llvm_coverage, old analyzer, s3 storage, DatabaseReplicated, WasmEdge, parallel) job into three 1/3-style batches and updates the LLVM Coverage artifact graph to wait for the three new *.profdata artifacts. I found no correctness issues: existing review threads were empty, Validator.validate passed for all workflows, regenerated master.yml and pull_request.yml match the checked-in YAML exactly, the three new jobs provide artifacts that are all present in LLVM_FT_ARTIFACTS_LIST, and the fetched Praktika report had no failed jobs.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Jun 30, 2026
@maxknv

maxknv commented Jun 30, 2026 •

Copy link
Copy Markdown
Member

@groeneai, is there a link with the CI report where the problem occurred? If there is a failure in CI, always add a link to the report; it should be available in the CIDB table.

@groeneai

Copy link
Copy Markdown
Collaborator Author

@maxknv

maxknv commented Jul 1, 2026

Copy link
Copy Markdown
Member

It's ok to split into more batches as the job runs for almost 2h already. But it does not appear to be a root cause of this error. CI does not "reclaim" runners while the job is running.
cc @alexbakharew

@maxknv
maxknv enabled auto-merge July 1, 2026 10:31
@maxknv
maxknv self-requested a review July 1, 2026 10:31
@maxknv
maxknv added this pull request to the merge queue Jul 1, 2026
Merged via the queue into ClickHouse:master with commit 0bd6e92 Jul 1, 2026
176 checks passed
@groeneai

groeneai commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator Author

You're right, and I've dropped the "runner reclaimed mid-job" wording from the description.

Re-reading the two representative job logs, the context canceled fires in the post-run phase, after All tests have finished. No queries hung., with zero test FAILs:

  • 108806 (start 09:41:40, cancel 12:02:14, ~2h20m): finishes tests at 11:50:17, then random-settings diagnosis + stop the 3 servers + the fatal-error greps, then the "Collect logs" step runs jeprof/flamegraph.pl over the jemalloc heaps from 11:54:48; the cancel lands mid-jeprof at 12:02:14, immediately followed by docker.sock: EOF and exit 125.
  • 103219 (~1h52m): same shape, cancel during the post-run random-settings diagnosis.

It isn't the praktika job timeout (common_ft_job_config.timeout = 3600*2.5 = 9000s; the job ran ~8.4k s under it, and the error path recorded is Job killed, exit code [125], not praktika's TIMEOUT status). And no timeout-minutes is emitted for a 2.5h job (yaml_generator only emits it above 6h), so it isn't a GitHub job timeout either. So the container connection is being severed by something outside the job script during post-run log collection, and I can't pin the exact source from these logs. Deferring to alexbakharew on the infra side.

Either way the split stands on its own merit as you noted: shorter per-shard wall-clock means the post-run collection finishes much sooner, well before whatever is closing the connection.

@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jul 1, 2026
pull Bot pushed a commit to Spencerx/ClickHouse that referenced this pull request Aug 5, 2026
This parametrization is being killed at the shared 9000s functional-test timeout
with tests still unrun, so the job reports error with no failing test and the
author sees an unattributable red. Over the 7 days to 2026-08-04 there were 16
such kills, all in a 25s band at 9016-9041s, hitting master twice and 14 PRs by
10 authors, 12 of them from other contributors. The prior 7 days had 5, so the
rate is rising.

The cause is per-shard volume, not a hang and not one slow test. Successful-run
p50 wall time on the slower of the two shards grew from about 5300s (2026-07-04)
to about 6800s (2026-08-04). A least-squares fit over those 32 daily p50 values
gives about +51s/day, leaving roughly six weeks of headroom on p50 and two on
p99 against the cap.

Wall time responds to sharding. Fitting wall time against summed per-test time
over 1671 successful runs gives wall_s = 255 + 0.08979 * sum_test_s with
r = 0.9722, so effective concurrency is about 11x and only about 255s is
unshardable setup and teardown. Back-substituting the measured per-shard
test-seconds reproduces the measured wall times to within 0.8%. Projected at 3
batches, using the measured crc32 bucket shares, the worst shard lands at a p50
of about 4671s (52% of the cap) and its growth slope falls to about 35s/day.

I raised the batch count rather than the timeout: a larger budget lets a genuine
hang burn hours, against the fail-fast intent of ClickHouse#106183 and ClickHouse#107602, and it
treats the cap instead of the volume. No new mechanism is introduced.
Job.ParamSet already emits {batch}/{total_batches} into the job name and
ci/jobs/functional_tests.py already forwards --run-by-hash-total and
--run-by-hash-num to clickhouse-test. Precedent: ClickHouse#108970 split
amd_llvm_coverage the same way, and amd_tsan, s3 storage, parallel already
uses 3.

The sequential sibling is deliberately left alone: it had 0 runs above 8000s in
the same window (p50 5555/6201), so splitting it would spend runners on a
problem that does not exist.

Partition integrity was verified over all 13230 selectable files in
tests/queries/0_stateless using the same crc32(filename) % total predicate as
tests/clickhouse-test: 6596 + 6634 at 2 batches, 4461 + 4417 + 4352 at 3. Both
sum to 13230 with the union equal to the full set, so no test is lost or
duplicated. The no-batch tag is used by 0 test files.

The workflow YAML is generated, not hand-edited. Note that praktika yaml runs
git add on its output, so a bare git diff reads clean while the generated files
have changed; scope must be checked with git diff HEAD.

Closes: ClickHouse#113164
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…erage-old-analyzer-parallel

Split amd_llvm_coverage old-analyzer parallel stateless job into batches
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 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.

4 participants