Skip to content

Forward the job's runner options to the FT diagnostics rerun - #112247

Open
groeneai wants to merge 10 commits into
ClickHouse:masterfrom
groeneai:groeneai/fix-coverage-diagnostics-drops-job-flags
Open

groeneai wants to merge 10 commits into
ClickHouse:masterfrom
groeneai:groeneai/fix-coverage-diagnostics-drops-job-flags

Conversation

@groeneai

@groeneai groeneai commented Jul 28, 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

Related: #111561

The stateless-test DIAGNOSTICS stage reruns each failed test to decide whether the failure
is reproducible, but it builds its clickhouse-test command from a hardcoded flag list and
never forwards the job's own runner options, so --replicated-database, --s3-storage and
the rest are dropped. The rerun creates a plain Atomic database, a configuration-specific
failure cannot reproduce in it, it is labelled flaky, and on llvm_coverage jobs a flaky
label force-sets the status to OK. CIDB records test_status = 'OK' for tests that failed
deterministically: 73535 such rows over 20 days across 141 tests. Two of them hid the
access-control bypass in #111561 for a week.

This is a regression. The RETRIES stage that DIAGNOSTICS replaced reran with
extra_args=runner_options (1607bd45d66f79); the hardcoded command that lost it is
d59310d5ec741e. The flaky -> OK override is older, intentional (#95763) and untouched.

The fix forwards runner_options, defaulting --shard/--zookeeper as run_tests already
does, and bounds the stage, which nothing bounded before. The per-test --timeout is pinned
to the main run's own 600 s, because any other value flips a verdict through the timeout
alone. The remaining job time is carried by an outer Shell.run bound of
job_timeout - elapsed - 15 min, and below one full-timeout rerun of headroom the stage is
skipped rather than truncated. That outer bound is soft while a rerun leaves a live descendant
holding the runner's stdout, which is a spawn-site concern in tests/clickhouse-test and not
addressed here; the 15-minute reserve is what absorbs the overshoot while it stands.

Honest failures turn green coverage jobs red, so the rollout is a decision for
@maxknv / @alexbakharew:

  1. Land as is: ~65 % of affected runs are already pipeline-non-blocking via force_ok_exit,
    and the Mergeable rollup flags the rest.
  2. Land after the carriers are registered as open issues, which exempts them narrowly. Better
    destination, but ~141 issues, so not a precondition here.
  3. allow_failure on these jobs: not proposed, rejected for them in CI: do not block PRs on amd_llvm_coverage s3-storage job infra failures #110142.

I will triage the carriers separately either way.

Validated by a throwaway script (not committed, per .claude/CLAUDE.md) that composes the
command as the job does and parses it with the real tests/clickhouse-test parse_args over
every runner-option value and budget boundary; a negative control confirms the pre-fix command
loses --replicated-database. This PR's own CI run then surfaced eight deterministic
DBReplicated failures that the job had been reporting as OK.

Measured impact, and the reasons behind those numbers

CIDB predicate: test_status = 'OK' rows whose test_context_raw contains the
Failure reproducibility check marker, which only the no-random 3-rerun branch emits.

Top carriers fail with Code 36 (refreshable MV on a replicated database), Code 392 (ALTERs
of different types on Replicated), result differs with reference, Code 47, and two distinct
kinds of Code 159:

  • ReplicatedDatabase DDL task ... is not finished on 2 of 3 hosts, this PR's class: a DDL
    timeout against the Replicated database the rerun never creates. Carriers
    04327_s3queue_server_credentials, 04320_url_engine_dispatch_partition_and_format,
    04511_remote_named_collection_complex_overrides.
  • Timeout exceeded (180 s) while flushing system log, the genuine Fix minor issue for LLVM Stateless Tests #95763 slow-binary class.
    Some of the three reruns pass, so the label stays flaky and the override still applies.

The rerun count does not change: diagnose_random_settings picks its branch from the saved
artifact rather than the flags, so coverage jobs keep the same 3-plain-rerun path, and the
stage is still skipped above 10 failed tests. What changes is that each rerun now runs the
test to completion instead of failing fast in the wrong environment, which is why it needed a
bound: unbounded, the ceiling was 10 tests x 3 reruns x 600 s = 5 h against a 2.5 h job
timeout, and a job that hits its own timeout never reaches complete_job, so praktika records
ERROR and skips the artifact upload the coverage job consumes.

Every funded stage now ends at the same 135 minutes of job time, whatever the elapsed time and
test count. Past 125 minutes there is less headroom than one full-timeout rerun and the stage
is skipped, which is rare: over 14 days elapsed p95 is 96.6 min and p99 104.4 min, and the
five slowest carriers run at p90 258/134/123/96/82 s.

Non-coverage flavours get a corrected diagnosis too, and their pass/fail cannot change: the
only status-mutating line is gated on is_llvm_coverage. Their label may flip flaky ->
reproducible, which open-issue matching ignores (it keys on name and failure reason).


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

groeneai and others added 6 commits July 27, 2026 14:25
The stateless-test DIAGNOSTICS stage reruns each failed test to decide whether
the failure is reproducible, but it built its clickhouse-test command from a
hardcoded flag list and never forwarded the job's own runner options. So
--replicated-database, --s3-storage, --encrypted-storage, --azure-blob-storage,
--no-parallel-replicas and --no-async-insert were dropped, the rerun created a
plain Atomic database, and a configuration-specific failure could not reproduce
in it.

On amd_llvm_coverage jobs that misdiagnosis is then converted into a green test:
the 3-plain-rerun branch returns "Failed 0 out of 3 reruns.", the label chain
turns fail_n < total_n into "flaky", and the coverage override force-sets the
status to OK. The parent result is recomputed from its children so the job goes
green, and CIDB records test_status = 'OK' for a test that failed
deterministically. Measured over 20 days: 73535 whitewashed OK rows across 141
distinct tests and 15 job flavours -- Code 36 refusals on replicated databases,
Code 392 mixed ALTERs, Code 159 DDL timeouts, reference diffs, Code 47. Two of
them masked a real access-control bypass for a week (ClickHouse#111561).

This is a regression: the RETRIES stage that DIAGNOSTICS replaced reran with
extra_args=runner_options (1607bd4); the hardcoded diag_command that lost
the forwarding is d59310d. The flaky -> OK override itself predates both
and is intentional (ClickHouse#95763, slow coverage binaries are prone to timing
flakiness); it is left untouched, and a slow-binary timeout still passes some
reruns so it still labels flaky.

Two details are load-bearing, both verified against the real clickhouse-test
parser. The positive --shard/--zookeeper must be conditional, because they are
declared in mutually exclusive groups with their negative twins and the
ParallelReplicas flavours forward --no-shard --no-zookeeper (passing both forms
is exit 2). And the options must go before the -- separator, because `test` is
nargs="*" and would swallow them as test-name regexes, making the forwarding a
silent no-op that also corrupts the test selector.

Nothing downstream changes: a reproducing failure now yields fail_n == total_n,
the label becomes "reproducible", the coverage override's guard is false and the
test correctly stays FAIL. The corrected diagnosis also reaches the non-coverage
FT flavours, but their pass/fail cannot change since the only status-mutating
line is gated on is_llvm_coverage.

Adds ci/tests/test_diagnostics_forwards_job_options.py, which composes the
command from main()'s own source and parses it with the real
tests/clickhouse-test parse_args via runpy.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=859a9abe2597d0c2c26b898066a32a375ea6b62f&name_0=MasterCI
Two review findings on the diagnostics-forwarding fix. No change to the
production forwarding logic, the two conditional shard/zookeeper guards, the
`--` separator placement or the `is_llvm_coverage` conjunct.

1. `--encrypted-storage` is appended to `runner_options` by `main()` at
   `ci/jobs/functional_tests.py:559`, separately from
   `OPTIONS_TO_TEST_RUNNER_ARGUMENTS`, so the map-driven `RUNNER_OPTIONS_CASES`
   list did not construct it and nothing asserted it arrived. Dropping that one
   option from the forwarded string left all nine tests green. The s3 coverage
   case now carries it (that is the only flavour where `main()` appends it: it
   is gated on s3 or azure) and the parametrized test asserts
   `args.encrypted_storage` equals the job's own intent - one True cell against
   four negative cells. Verified by mutation: removing the option from the
   forwarded string now fails exactly the `DBReplicated_s3_coverage` case,
   1 failed / 8 passed.

2. The comment above the forwarding kept the mechanism (mirror the main run's
   environment; shard/zookeeper defaulting is conditional because passing both
   forms of an argparse mutually-exclusive pair is exit 2; options must precede
   `--` because `test` is `nargs="*"`) and lost the failure narrative and the
   two bare commit shas - the regression provenance
   (forwarding existed in the RETRIES stage as 1607bd4 and was lost in
   d59310d) is in the pull request description, and bare shas in comments
   have no precedent anywhere else under ci/.

Full ci/tests/ suite twice: 7 failed / 443 passed both runs, identical failing
set, all seven the pre-existing host-flaky baseline. Repo-wide ruff clean.

Co-Authored-By: Claude Fable 5 <[email protected]>
…st timeout

Forwarding the job's runner options makes the diagnostics rerun actually
reproduce the failure instead of failing fast in a plain `Atomic` database, so
the rerun now runs each test to completion. That makes a pre-existing unbounded
loop reachable, and the consequence is worse than a slow job.

`TestCase.diagnose_random_settings` takes the no-randomized-settings branch on
these jobs, a plain three-iteration loop with no time budget of its own, and
`diag_command` passed no `--timeout`, so `clickhouse-test` applied its 600 s
default. The stage's ceiling was therefore 10 tests x 3 reruns x 600 s = 300 min
against a 150 min job timeout. A job that hits its own timeout is not a clean
failure: `ci/praktika/runner.py` records `Result.Status.ERROR`, `complete_job`
never runs so `do_not_block_pipeline_on_failure` stays unset, and the
artifact-upload branch is skipped entirely. The job's `LLVM_COVERAGE_FILE_*`
artifacts are then never uploaded and `llvm_coverage_job`, which requires them,
loses its input. The `is_llvm_coverage` `force_ok_exit` does not protect against
this, because it only takes effect through `complete_job`.

So bound each rerun with a `--timeout` derived from what the job has left, minus
a reserve for coverage merging and result upload, spread over the reruns the
stage performs and floored so a single pass still happens. The three inputs are
named constants tied to the values they mirror: `common_ft_job_config`'s
`timeout`, the finalization reserve, and `max_reruns` in `tests/clickhouse-test`.

The bound is safe in the direction that matters. A `--timeout` expiry inside the
rerun is classified `TestStatus.FAIL`, and the rerun loop counts exactly that, so
a starved budget pushes the verdict toward `reproducible` rather than toward the
`flaky` label the coverage override whitewashes. A tighter bound can only make
the diagnosis more pessimistic, never turn a real failure green.

The forwarding itself, both conditional `--shard`/`--no-shard` and
`--zookeeper`/`--no-zookeeper` guards, the `--` separator placement and the
`is_llvm_coverage` conjunct on the OK override are unchanged.

Two regression tests: one that the command carries a positive `--timeout` before
the separator and that the real parser reports it with the test selector intact,
and one that the value shrinks with elapsed time and with the number of failed
tests and never falls below the floor. The second is what makes the budget live
rather than decorative: replacing it with a constant leaves the first test green.
… timeout

The r2 budget was one-sided. It bounded the stage from above but let the
per-test value grow to 2700s for a single failed test at elapsed 0, while the
main pass runs every test under clickhouse-test's own 600s default (run_tests
passes no --timeout). A test that deterministically takes ~700s therefore fails
the main pass on timeout, gets its artifact saved, passes all three roomier
reruns, reads as "Failed 0 out of 3 reruns", is labelled flaky and is force-set
to OK on coverage jobs. That is a new instance of the whitewash this PR exists
to remove. On coverage jobs over 20 days 01019_alter_materialized_view_atomic
sits at p99 546s / max 600.1s and already carries rows that are OK with both a
timeout marker and "Failed 0 out of 3 reruns".

Extract the arithmetic into a pure diagnostics_budget(elapsed_s, num_tests)
returning (stage_timeout, test_timeout) or None:

- test_timeout is capped at the main run's own effective per-test timeout, so
  the rerun can never be more permissive than the pass that failed;
- below a usable per-test bound the function returns None and the stage is
  SKIPPED rather than started and cut off. The old max(..., 60) floor let the
  stage overrun the job timeout by up to 10 minutes, which defeated the
  finalization reserve it was added to protect;
- stage_timeout is passed to Shell.run as an outer timeout, the idiom run_tests
  already uses. This is the actual aggregate guarantee: on the 23 of 37
  DIAGNOSTICS-reachable flavours that save randomized settings,
  diagnose_random_settings reruns a test an unbounded number of times, so no
  tests-times-reruns model can bound the stage. A SIGTERM there loses at most
  the in-flight test's diagnosis, because run_diagnose_from_artifacts flushes
  the results JSONL after every entry and the CI side reads it afterwards.

Every funded cell of the elapsed-by-test-count matrix now ends at 135 minutes
against a 150 minute job timeout, and no per-test value exceeds 600s.

The two hand-copied constants are pinned to their real sources: the job timeout
against common_ft_job_config.timeout, and the reruns divisor against
clickhouse-test's own max_reruns. Both were functionally unpinned before, so a
ten-hour job timeout left the suite green.
…r-test timeout

The previous round capped the rerun's --timeout at the main run's own 600 s so a
roomier rerun could no longer pass a test the main pass timed out on. The other
direction was still open: the value was derived as
stage // (num_tests * reruns), which drops below 600 s as soon as four or more
tests are diagnosed, so each rerun got LESS time than the pass that produced the
failure. A test whose duration straddles the shrunken value then fails some of the
three reruns and passes others, which is "Failed 1 out of 3 reruns", which is
fail_n < total_n, which is labelled flaky and force-set to OK on coverage jobs -
a fresh instance of the whitewash this change exists to remove. (Failed 3 out of 3
would be "reproducible" and would miss that guard, which is why "a starved budget
only makes the verdict more pessimistic" held only for tests always above the cap.)

Measured on 20 days of coverage functional-test jobs carrying the reproducibility
marker: evaluating the old cap at 90 minutes elapsed, 22.9% of the rows on 4-test
jobs exceed it, 19.9% at 5, 13.1% at 7, 32.8% at 8 and 40.0% at 10 - 8463 of the
75317 whitewashed rows. Shrinking the value also shortens the per-test cleanup,
sized from the same --timeout, whose failure against a live server propagates as
a FAIL.

So the per-test value is now a constant equal to the main run's, and the remaining
job time is carried by the stage bound alone: truncating the stage cannot fabricate
a per-test label, it is reported as "diagnosed N out of M failed test(s)". The
give-up condition becomes "not enough stage budget for one full-timeout rerun",
which moves the boundary to 125 minutes elapsed and leaves every funded stage
ending exactly 135 minutes into the 150-minute job, delivering the finalization
reserve the coverage artifact upload depends on. The divisor and the minimum-rerun
constants are gone with the arithmetic that used them.

The budget is now computed once instead of twice. It truncates its elapsed
argument, so evaluating it for the guard and again for the unpacking could straddle
a whole second and unpack None, uncaught, inside the very window the bound protects.

Two tests were pinning the defect rather than the property: one asserted only that
the per-test value does not EXCEED the main run's, approving every shrunken value,
and one required the value to shrink with elapsed time and test count. They now
assert equality, and the derived-not-constant property of the stage value. The
reserve test was a tautology - it compared stage against the two constants stage is
defined from - and now asserts the absolute 135-minute stage end, so moving either
constant fails it.

The reserve comment no longer claims the outer Shell.run timeout enforces the
reserve unconditionally. It does so only while no process a rerun spawns outlives
the stage holding the runner's stdout; a per-test wrapper started without its own
stdio keeps that pipe open and the output reader waits for it. That is a separate
defect in tests/clickhouse-test, fixed there.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
The DIAGNOSTICS_RESERVE_S comment claimed the residual stdio-wedge is "fixed
there" in tests/clickhouse-test. No such fix exists: master's per-test Popen
still inherits the runner's stdout, and this PR does not touch that file. Say
whose concern the residual is, and what the reserve buys while it stands,
without asserting anyone has solved it.

The diagnostics budget's "read the clock once" comment was absolute, but
stop_watch.duration is also read by the display-only print after the guard.
Scope the sentence to the budget so the ordering requirement it documents stays
true of the block.

Comment text only. No behaviour, constant value or assertion changes.

Co-Authored-By: Claude Fable 5 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review -- 6 rounds, 29 findings (26 agreed and fixed, 1 disagreed with evidence, 2 no-ops)

Before opening this PR the change went through independent cold review plus a second-model
review pass in each of six rounds. Every finding is listed with its disposition. Rounds 3, 4
and 5 each found a defect in the fix the previous round had produced, so the shape of the
bound changed three times; the last two rounds were clean.

Round 1 (5 findings, all agreed)

# Severity Finding Verdict
❌ 1 major The regression suite never exercised --encrypted-storage, which main appends to runner_options separately from OPTIONS_TO_TEST_RUNNER_ARGUMENTS and which the description names as one of the dropped flags. Selectively dropping just that option left all nine tests green. AGREE -- fixed. The DBReplicated_s3_coverage case now carries the flag and the parametrized test asserts args.encrypted_storage matches the forwarded string. Verified discriminating: 1 True cell and 4 False cells across the five cases, and a mutation dropping only that one option from the forwarded string now fails exactly that case (1 failed / 8 passed).
⚠️ 2 nit The new in-code comment carried the regression provenance (two bare commit shas) and repeated the failure narrative that the description already tells. AGREE -- fixed. Trimmed to the two facts a maintainer needs at that line: why the shard/zookeeper positives are conditional, and why the options must precede --. The provenance stays in the description and the commit message. Measured for context: bare shas in a comment are otherwise absent from ci/, while the #95763 PR-number form twelve lines below is the local convention.
💡 3 nit The rollout section quantified the merge-blocking consequence but not the runtime one, on jobs that already run close to their timeout. AGREE -- applied to the description. Added the measured headroom against the 2.5 h job timeout. The first version of that paragraph also claimed the work was capped by the diagnosis step budgets; round 2 found that claim wrong and rewrote it -- see finding 6.
💡 4 nit "Only two carriers are the genuine #95763 timeout class" read wrong against the data -- four more carry Code: 159. AGREE -- applied to the description. The Code: 159 rows split into two mechanisms and the description now names both with row counts: ReplicatedDatabase DDL task ... is not finished on 2 of 3 hosts (this PR's class, which cannot reproduce without --replicated-database) and Timeout exceeded (180 s) while flushing system log (#95763's class, which stays tolerated).
💡 5 nit Bare commit shas in the comment vs the in-tree #PR form. AGREE -- subsumed by finding 2 (those lines are removed).

Round 2 (5 findings, all agreed)

# Severity Finding Verdict
❌ 6 major The diagnostics stage has no time budget, and making the reruns actually reproduce turns that from harmless into costly. Coverage jobs pass --no-random-settings, so the diagnosis takes the early-return branch at tests/clickhouse-test:2283-2294, a plain for i in range(3) loop that references neither the --diagnose-random-settings-* budgets nor args.stop_time; run_diagnose_from_artifacts does not reference stop_time either, and its only two consumers sit past the sys.exit in diagnose mode, so --global_time_limit would not bind it. With no --timeout in the command the per-test default is 600 s, giving a 10 x 3 x 600 s ceiling against the 2.5 h job timeout -- and a job timeout is recorded as ERROR, which skips the artifact-upload branch entirely, starving the downstream llvm_coverage job of the artifacts these jobs provide. AGREE -- fixed (and then re-fixed twice: see findings 10, 12 and 15). The stage is now bounded, and the description's first version -- which claimed the work was capped by the --diagnose-random-settings-* budgets, which do not apply on this path -- was rewritten.
💡 7 nit Prose in the new tests spells function names as main() / run_tests(). AGREE -- fixed. AGENTS.md requires f rather than f() in comments, documentation and commit messages. Rewritten in prose only; executable calls unchanged.
💡 8 nit The Related: issue link sat inside the template's HTML comment, so it would not render in the published description. AGREE -- fixed. Surfaced outside the comment block, as a full URL.
💡 9 nit Two em-dashes in the new test file's prose, against the plain-ASCII convention. AGREE -- fixed in round 3 (finding 14). Both replaced; the added lines of this PR now contain zero non-ASCII characters.

Also checked and found sound, so recorded here rather than as findings: every FT job flavour
that reaches the DIAGNOSTICS stage was enumerated from ci/defs/job_configs.py, its
runner_options rebuilt the way main builds it, the diagnostics command composed by executing
main's own source block, and all 50 resulting command lines parsed with the real
tests/clickhouse-test parser -- every one parses, and in every one shard/zookeeper and each
environment flag equal that job's own intent with the failed-test selector intact. Separately,
over all 92 flags the parser declares, --no-shard and --no-zookeeper have no substring twin,
so the two in tests that implement the conditional defaulting cannot false-positive; of the 24
flags runner_options can carry, only that pair falls in a mutually exclusive group, and the
three flags that appear both hardcoded and forwarded are plain stores with identical values, so
the repeats are no-ops. --jobs was re-confirmed inert in diagnose mode. Forwarding --no-long
and --excluded-from-llvm is required for correctness rather than merely harmless: both are skip
predicates, so omitting them made the rerun skip the very test being diagnosed. Label-based
open-issue matching is unaffected: Issue._check_flaky_test_match keys on test name and failure
reason, never on a label.

Round 3 (7 findings: 6 agreed, 1 no-op)

# Severity Finding Verdict
❌ 10 blocker Round 2's bound was too loose in the other direction, and that is itself a whitewash. The main run passes no --timeout, so every main-pass test is bounded by the parser default of 600 s; round 2's formula yields 2700 s for a single failed test. A test the main pass timed out on still gets its artifact saved, so a roomier rerun can pass it 3/3 -- Failed 0 out of 3 reruns -> flaky -> forced OK. Reachable, not theoretical: on coverage FT jobs over 20 days one carrier has p99 546 s / max 600.1 s and already carries 7 OK rows with both the timeout marker and Failed 0 out of 3 reruns. AGREE -- fixed. The derived value was capped at the main run's own 600 s, with the cap asserted across the whole elapsed x count matrix. Round 4 then found the cap was still wrong on its lower side (finding 12).
❌ 11 major The bound was not a hard bound. Three sub-claims, all confirmed: (a) the 60 s floor made the stage end at 150, 151 and 160 minutes against a 150-minute job timeout, so the promised reserve was not delivered; (b) the tests x reruns model covers only one branch -- of the 37 FT flavours reaching DIAGNOSTICS only 14 suppress randomization, and on the other 23 the per-test cost is roughly 57 minutes, which no per-test cap can bound; (c) the constants were unpinned -- mutating the job timeout to 10 h, the reruns-per-test to 1, or the reserve to 0 each left the suite fully green while breaking the invariant. AGREE -- fixed. Extracted a pure diagnostics_budget(elapsed, num_tests) returning (stage_timeout, test_timeout) or None, passed the stage value to Shell.run as an outer timeout (the idiom run_tests already uses), skipped the stage rather than truncating it when the remaining time cannot fund a full rerun, and added the drift guard plus aggregate-bound assertions.
❌ 12 major The frozen description described the pre-round-2 code: it quoted the 5 h ceiling as unmitigated and closed by offering to add a bound, while the diff already added one. AGREE -- fixed in the description before the gate re-ran, so the gate reviewed the corrected text.
💡 13 nit The Related: link was added as the shorthand #111561; the template's own instruction line asks for a full URL. AGREE -- fixed. Full URL.
💡 14 nit Two U+2014 characters in added prose. AGREE -- fixed. Replaced; grep -c -P '[^\x00-\x7F]' on the added lines is 0.
💡 15 nit (Own review) The reserve-assertion prototype showed the missing invariant checks were importable from ci/tests. AGREE -- folded into finding 11's fix rather than duplicated.
💡 16 nit Singular "the downstream coverage job" versus a per-batch fan-in. No-op. The mechanism claim is accurate and finding 11's fix rewrites the surrounding comment anyway.

Round 4 (7 findings, all agreed)

# Severity Finding Verdict
❌ 17 blocker Round 3's cap was two-sided only at its upper end: below 600 s it still shrank with the failed-test count, so from four failed tests on the rerun got less time per test than the main pass. The recorded safety argument -- that a starved budget can only push the verdict toward reproducible -- is true only for a test that always exceeds the shrunken cap, and false at the boundary: a straddling test fails some of the three reruns and passes others, which is Failed 1 out of 3, which is fail_n < total_n, which is flaky, which is forced OK. The fix re-created the exact whitewash it removes. Measured: at four failed tests and 90 minutes elapsed, 22.9 % of rows exceed the shrunken value. My own cold review and the second-model pass reached this independently from opposite directions. AGREE -- fixed. The per-test value is now a constant equal to the main run's own 600 s, and the whole remaining-time budget is carried by the stage bound alone. A stage truncation is a runner exit code, not a per-test verdict, so it cannot fabricate a label.
❌ 18 major The suite did not merely miss finding 17, it pinned it: one test asserted only test_timeout <= 600, green for every value in 60..599, and another required the per-test value to shrink with the test count, so it would have failed on the corrected code. AGREE -- fixed. The upper-bound assertion became an equality over the whole matrix, pinned against the default parsed out of tests/clickhouse-test itself; the shrink assertion was rewritten to assert it of the stage bound. Mutation: shortening the per-test value to a plausible 500 s was green before and fails now.
❌ 19 major The reserve test was a tautology -- it asserted elapsed + stage <= JOB - RESERVE while stage is defined as JOB - elapsed - RESERVE from the same two constants, so mutating either constant left it green. It was the only test whose name claimed to guard the reserve. AGREE -- fixed. Rewritten as an absolute: every funded stage must end at exactly 135 minutes of job time, so moving either constant now fails here instead of cancelling out.
❌ 20 major The budget was read twice from a live clock. diagnostics_budget is pure, but its argument is wall-clock and the function truncates with int(), so the guard call and the unpacking call can straddle a whole-second cutoff: measured, elapsed 6300.999 is funded and 6301.0 is None, giving TypeError: cannot unpack non-sequence NoneType -- an uncaught exception landing in exactly the finalization window the bound exists to protect. Purity does not help when the argument advances between calls. The two-call shape had been prescribed by the previous round's fix plan; that prescription was wrong. AGREE -- fixed. The budget is computed once, before the branch, and only unpacked inside the arm that has already excluded None.
⚠️ 21 blocker (mechanism) The stage's outer Shell.run timeout is not a hard bound while a rerun leaves a live descendant holding the runner's stdout pipe. Measured worse than stated: an isolated A/B driving the real Shell.run with timeout=5 against a child that spawns a grandchild with no stdio of its own returned after 120.0 s, because stdout_thread.join() blocks on the inherited pipe while the timeout handler signals only the tracked group. Control with the grandchild's stdio detached: 5.0 s, grandchild still alive -- so the overrun is the pipe coupling, not the orphan. AGREE on the mechanism; the remedy belongs at the spawn site, which is in tests/clickhouse-test and outside this PR (one concern per PR). Also measured that the suggested post-hoc kill cannot work: it runs only after Shell.run returns, which is the 120 s already spent. So this PR stopped claiming a hard bound: the description and the constant's comment now state that the stage bound holds only while no rerun leaves a live descendant holding the pipe, and that the reserve is what absorbs the overshoot.
💡 22 nit The reruns-per-test constant's comment called the divisor "heuristic sizing" when it was in fact the sole carrier of finding 17. AGREE -- fixed, as part of finding 17 (the divisor is gone).
💡 23 nit The description still owed the round-3 runtime edit. AGREE -- partially fixed here (the one sentence my review had disproved, before the gate ran), remainder in round 5.

Round 5 (5 findings: 3 agreed, 1 disagreed, 1 no-op)

# Severity Finding Verdict
❌ 24 major A shipped comment asserted the residual pipe-coupling defect of finding 21 was "a separate tests/clickhouse-test defect, fixed there". It is fixed nowhere in the tree this PR merges into: origin/master:tests/clickhouse-test still starts each per-test wrapper with no stdout/stderr argument, and no published change touches it. A merged comment must not assert a state of the world that does not exist. This was my own previous fix plan's wording coming back -- it asked for "a separate known defect being fixed", and the past participle narrowed that into a false claim. AGREE -- fixed. The clause now says whose concern the residual is, without asserting anyone has solved it, and says what the reserve buys while it stands. The mechanism half of the sentence was re-verified and kept.
❌ 25 major The frozen description still described the formula round 4 deleted: a division by the failed-test count, a 60 s floor, a "degenerate floor regime" reaching 150 minutes, and per-test values falling below carrier timings -- none of which exist any more -- and claimed the tests assert the per-test value shrinks with elapsed time and test count, the exact property round 4 removed. It also said 11 test cases where the suite collects 16. AGREE -- fixed in the description (a review-owned artifact) before the final gate, so the gate reviewed the corrected contract: a stage-end table, the give-up branch named, the outer-timeout caveat disclosed, and the mutation list synced.
💡 26 nit "Read the clock once" was absolute, but the elapsed time is also read by a display-only print after the unpacking. AGREE -- fixed. The sentence is scoped to the budget, so the ordering requirement it documents stays true of the block.
💡 27 nit The budget's num_tests parameter is now unused. DISAGREE, with reasons. Keeping it is correct: the docstring explains why the count is deliberately absent from the arithmetic, which is a fact a reviewer must be able to see at the function, and the matrix tests drive the two-argument shape precisely to prove that independence. ruff's unused-name check covers locals, not parameters, so there is no lint pressure either.
💡 28 nit Second-model pass, round 5. No-op -- it returned no findings.

Round 6 (clean)

Round 5's two comment corrections were verified against their acceptance criteria, and both my
own cold review and the second-model pass returned zero findings -- the second consecutive
clean gate. The round changed 10 lines, all comments, in one file; no assertion, constant value
or behaviour changed. Three further invariant questions were opened in this round and each
resolved as sound rather than as a finding, recorded here for the reviewer:

  • The elapsed clock starts slightly later than the job timeout does (the stopwatch is created
    inside the job script, after binary resolution), so the remaining-time estimate is optimistic by
    that setup. It is path resolution plus a chmod on every flavour that reaches this stage --
    artifact download happens outside the timed command -- i.e. seconds against a 900 s reserve, and
    the pre-existing flaky and targeted budgets use the identical idiom.
  • A stage kill is newly reachable, so the diagnostics results file can be truncated. It cannot
    be torn mid-line: the writer flushes after every complete line inside a with open(...), and
    clickhouse-test installs a SIGTERM handler that raises, so the context manager exits and
    flushes. Partial results are the designed outcome and are already reported honestly by the
    existing branch as diagnosed N out of M failed test(s).
  • The new SKIPPED result cannot mask a failure: SKIPPED counts as ok and is not counted as
    failed when the parent status is recomputed, exactly like the pre-existing "too many failed
    tests" arm, and the per-test statuses that decide the job are untouched.

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. The defect is a command-construction bug, so the deterministic oracle is the real tests/clickhouse-test parse_args (loaded with runpy.run_path) fed the diagnostics command shape. On master's shape it reports replicated_database=False s3_storage=False for the DBReplicated+s3 storage coverage flavour, every run - i.e. the rerun does not use a Replicated database, so the Code 36 / Code 392 / Code 159 failure class cannot reproduce in it.
b Root cause explained? Yes. ci/jobs/functional_tests.py:1187-1195 builds the DIAGNOSTICS command from a hardcoded flag list and never forwards runner_options, so --replicated-database/--s3-storage/... are dropped and the rerun creates a plain Atomic database. Coverage jobs pass --no-random-settings, so diagnose_random_settings takes the 3-plain-rerun branch (tests/clickhouse-test:2283-2294) and returns Failed 0 out of 3 reruns.; :4383-4390 turns fail_n < total_n into flaky; functional_tests.py:1225-1230 force-sets OK when label_key == "flaky" and is_llvm_coverage. Result._update_status() then recomputes the parent from children (job green) and ci/praktika/cidb.py:239 writes the status verbatim (CIDB test_status = 'OK'). Regression: the RETRIES stage this replaced forwarded the options (1607bd45d66f79); d59310d5ec741e lost them.
c Fix matches root cause? Yes - the flag forwarding is restored at the exact site that lost it, using the conditional shard/zookeeper defaulting run_tests already implements at :114-117. No status change, no tag, no widened bound, no narrowing of the #95763 override. The forwarding also makes the rerun run the test to completion instead of failing fast in the wrong environment, so the same change bounds the stage: without a bound its ceiling is 10 x 3 x 600 s = 300 min against a 150 min job timeout, and a job timeout is Result.Status.ERROR, which skips artifact upload and starves the downstream coverage job. The bound is a pure diagnostics_budget(elapsed, num_tests) returning an outer stage timeout (passed to Shell.run, the idiom run_tests already uses) plus a per-test --timeout equal to the main run's own effective 600 s - exactly equal, in both directions: a longer rerun can pass a test the main pass timed out on (Failed 0 out of 3) and a shorter one makes a test near the limit fail only some of its reruns (Failed 1 out of 3), and both read as flaky, so only equality cannot fabricate a label. The remaining-time budget is therefore carried by the stage bound alone, which can only truncate the stage - reported honestly by the existing branch as diagnosed N out of M failed test(s) - and when the remaining time cannot fund even one full-timeout rerun the stage is SKIPPED rather than started and cut off.
d Test intent preserved / new tests added? Yes. No existing test is weakened. New ci/tests/test_diagnostics_forwards_job_options.py (16 tests) pins the forwarding, the conditional positives, the pre----separator position, per-flavour parsing against the real parser (each environment flag asserted to equal the job's own intent, including --encrypted-storage, which main appends outside OPTIONS_TO_TEST_RUNNER_ARGUMENTS and a map-driven case list would otherwise miss), the presence and position of the --timeout bound, that the per-test value EQUALS the main run's own 600 s over the whole elapsed x test-count matrix (equality, not an upper bound - an upper bound would approve every shrunken value), that the stage bound is derived from elapsed time rather than constant, that every funded stage ends exactly 135 minutes into the job so the finalization reserve is delivered, that the stage is given up rather than truncated when too little job time is left, that the budget is read once from the live clock, that the Shell.run call carries the outer timeout, and that the hand-copied job timeout equals its real source (common_ft_job_config.timeout) - plus, explicitly, that Failed 1 out of 3 still labels flaky, so PR #95763's genuine coverage-timeout tolerance is not regressed.
e Both directions demonstrated? Yes. Unfixed shape: env flags dropped (replicated_database=False), no --timeout so clickhouse-test's 600 s default applies. Fixed shape: 7 runner-options flavours all parse with the job's own shard/zookeeper intent, the env flags present, args.timeout equal to the derived bound, and args.test exactly the failed-test list. Each new test was validated by a named mutation, prediction written first, with exactly the predicted tests failing: drop the forwarding (6 failed / 3 passed); restore the unconditional --shard --zookeeper; move the forwarding after --; drop the is_llvm_coverage conjunct; invert fail_n < total_n; drop only --encrypted-storage from the forwarded string (1 failed / 8 passed, exactly the one flavour that carries it); delete the --timeout token (3 failed / 14 passed); replace the derived budget with a constant 600 (2 failed / 15 passed); move --timeout after the -- separator (9 failed / 8 passed); drop timeout= from Shell.run (1 failed, the outer-timeout test); shrink the per-test value to a plausible 500 (1 failed - it was GREEN while the suite only asserted an upper bound, which is why that assertion is now an equality); replace the stage value with a constant 1800 (3 failed); set the job timeout to 10 h (3 failed) and zero the reserve (2 failed), both of which now fail the stage-end assertion as well as the drift guard; and restore the two-call budget read (1 failed).
f Fix is general across code paths? Yes. grep -rn "diagnose-random-settings|diagnose_random_settings" ci/ finds exactly one diagnostics invocation, so there is no sibling FT carrier. The file contains exactly two clickhouse-test command constructions, and the other one (run_tests:152) already carries both a graceful --global_time_limit and a larger outer Shell.run timeout, so the diagnostics stage was the only unbounded invocation. ci/jobs/integration_test_job.py has no diagnostics stage; its coverage handling uses Label.OK_ON_RETRY after a rerun that genuinely observed a pass, which is a different mechanism - deliberately out of scope (one concern per PR).
g Fix generalizes across inputs (params/datatypes/wrappers)? Yes for the two axes that exist here, the forwarded string and the budget inputs. All 7 representative runner_options values were driven through the real parser, including the two carrying --no-shard --no-zookeeper, the azure string with duplicated --no-random-*, --excluded-from-llvm, --encrypted-storage and the empty case; separately, all 25 DIAGNOSTICS-reachable FT flavours from ci/defs/job_configs.py times the random is_encrypted_storage coin (50 composed commands) parse with every flag equal to the job's own intent and the selector intact. Every forwarded token was classified for mutual exclusivity (only the shard/zookeeper pairs conflict; enumerated all 4 add_mutually_exclusive_group blocks, and --timeout is in none of them) and for repeat-safety (--random-settings-diagnostics-dir repeats with an identical value; inert). The budget is asserted over a full matrix of elapsed 0-140 min times 1, 2, 3, 5, 7 and 10 failed tests - the whole reachable range, since above 10 the stage is already SKIPPED - covering the funded regime (every cell ending at 135 min with the per-test value at 600 s, independent of the count) and the give-up regime past 125 min elapsed. --jobs N was re-verified inert in diagnose mode: args.jobs is read only at tests/clickhouse-test:5830, inside the else of the if args.diagnose_random_settings: early sys.exit at :5802-5809. No datatype or type-wrapper axis exists in a Python command-construction change.
h Backward compatible? (maintainer-approved exception only) Yes. No setting default, no serialization format, no user-visible behaviour, no SettingsChangesHistory surface. The only compatibility surface is the clickhouse-test CLI, and every forwarded flag - including --timeout, which already exists with default=600 - is already accepted by the same script the same job invokes in its main pass.
i Invariants and contracts preserved? Yes - the invariant is restored rather than broken: a diagnostics rerun must reproduce the environment of the run whose failure it is diagnosing. Two argparse contracts are explicitly upheld and each is pinned by a test: the mutually-exclusive --shard/--no-shard and --zookeeper/--no-zookeeper pairs (never both forms, which would be exit 2 on the ParallelReplicas flavours) and test being nargs="*" (options only before the -- separator, else they are swallowed as test regexes - now pinned for --timeout too). The diagnosis-label contract is upheld symmetrically, by giving the rerun exactly the per-test timeout the failing pass had. A LOOSER rerun can pass a test the main pass timed out on (Failed 0 out of 3 -> flaky -> OK); a TIGHTER one is not merely pessimistic, because a test whose duration straddles the shrunken value fails only some of the three reruns (Failed 1 out of 3), which is also fail_n < total_n and therefore also flaky (Failed 3 out of 3 would be reproducible and would miss the guard). Both directions would have been new instances of the whitewash this PR removes, so the per-test value is a constant equal to the main run's and the remaining-time budget is carried by the stage bound alone - truncating the stage cannot fabricate a per-test label, it is reported as diagnosed N out of M failed test(s). Keeping the value fixed also preserves the per-test cleanup budget, which is sized from the same --timeout (tests/clickhouse-test:3762-3763) and whose failure against a live server propagates as a FAIL. The budget is read once from the live clock and only unpacked after the is None arm, so a truncation straddle cannot unpack None; num_tests no longer enters the arithmetic, so there is no divisor. The #95763 OK override at :1225-1230 and every blocking/Mergeable carrier (ci/praktika/native_jobs.py:1084-1089, hook_html.py:249, runner.py:884-891, runner.py:600) are untouched, and the only status-mutating line keeps its is_llvm_coverage conjunct, so the ~40 non-coverage FT flavours cannot change pass/fail.

Session id: cron:clickhouse-impl-slot-5:20260728-071200

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @leshikus - could you review this? The stateless-test DIAGNOSTICS stage builds its clickhouse-test rerun from a hardcoded flag list and never forwards the job's own runner_options, so a configuration-specific failure cannot reproduce in the rerun, gets labelled flaky, and is then force-set to OK on llvm_coverage jobs; this forwards the options and bounds the now-real rerun work inside the job timeout. The rollout question in the description (making these failures visible turns some green coverage jobs red) is for @maxknv / @alexbakharew.

@clickhouse-gh

clickhouse-gh Bot commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [66ee0b1]

Summary: ❌

job_name test_name status info comment
Stateless tests (amd_llvm_coverage, old analyzer, s3 storage, DBReplicated, parallel, 1/3) FAIL
04903_mutation_partition_pruning_without_validation FAIL cidb
04825_quantile_deterministic_alter_add_modify_column FAIL cidb
05030_totime_on_cluster_as_settings_in_zk_version FAIL cidb
04511_remote_named_collection_complex_overrides FAIL cidb
04910_to_time_legacy_alter_key_definitions FAIL cidb
04626_create_or_replace_drop_privilege_preflight FAIL cidb
03636_storage_alias_metadata_access_rights FAIL cidb

AI Review

Summary

This PR updates the DIAGNOSTICS rerun in ci/jobs/functional_tests.py so it forwards the main job's runner_options, preserves the shard/zookeeper polarity, and adds explicit stage and per-test bounds for the rerun. I reviewed the current one-file patch against the PR discussion, the relevant tests/clickhouse-test code paths, and the current CI report, and I did not find a new blocker or major issue in the final diff.

Final Verdict

✅ No new inline findings on the current patch.

LLVM Coverage Report

⚠️ No coverage measurement for commit 66ee0b1: incomplete coverage measurement: 16 of 21 shard profiles are missing: LLVM_COVERAGE_FILE_ft_2.profdata, LLVM_COVERAGE_FILE_ft_3.profdata, LLVM_COVERAGE_FILE_ft_old_s3_db_repl_parallel_2.profdata, LLVM_COVERAGE_FILE_ft_old_s3_db_repl_parallel_3.profdata, LLVM_COVERAGE_FILE_ft_old_s3_db_repl_sequential_1.profdata, LLVM_COVERAGE_FILE_ft_old_s3_db_repl_sequential_2.profdata, LLVM_COVERAGE_FILE_ft_s3_async_sequential.profdata, LLVM_COVERAGE_FILE_ft_s3_sequential.profdata, LLVM_COVERAGE_FILE_it_1.profdata, LLVM_COVERAGE_FILE_it_2.profdata, LLVM_COVERAGE_FILE_it_3.profdata, LLVM_COVERAGE_FILE_it_4.profdata, LLVM_COVERAGE_FILE_it_5.profdata, LLVM_COVERAGE_FILE_it_6.profdata, LLVM_COVERAGE_FILE_it_7.profdata, LLVM_COVERAGE_FILE_it_8.profdata.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Jul 28, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 682ae7a

Every failure below has an owner: a fixing PR (ours or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Stateless (amd_llvm_coverage, old analyzer, s3 storage, DBReplicated, WasmEdge, parallel, 1/3) / 03981_refreshable_mv_retries_int64_max pre-existing deterministic DBReplicated failure, previously whitewashed to OK by the very defect this PR fixes (Code 36, refreshable MV + non-replicated table) a fix task is moved to pending (investigating at full effort, fixing-PR link to follow here)
same job / 03990_alter_rename_column_swap_different_types same class (Code 392, mixed ALTER types prohibited on a Replicated database) same fix task as above
same job / 04278_json_minmax_index_mixed_type_array same class (Code 392, DROP INDEX + RESET SETTING in one ALTER) same fix task as above
same job / 04318_remote_storage_engine_access same class (Code 57, TABLE_ALREADY_EXISTS under replicated DDL replay) same fix task as above
same job / 04401_remote_storage_engine_restore_access same class (result differs) same fix task as above
same job / 04401_url_engine_s3_dispatch same class (result differs) same fix task as above
same job / 04489_remote_storage_engine_restore_tf_access same class (result differs) same fix task as above
same job / 04511_remote_named_collection_complex_overrides same class (Code 159, distributed_ddl_task_timeout) same fix task as above

All eight are the intended, disclosed consequence of this PR rather than regressions it
introduces. Each one is a configuration-specific failure that has been failing on this job
flavour all along and was being force-set to OK because the diagnostics rerun dropped the
job's runner_options; forwarding those options is exactly what this PR does, so the
failures are now reported instead of hidden. Evidence that they are pre-existing and not
caused by this diff:

  • Every failure carries the diagnostics verdict Failed 3 out of 3 reruns or
    Runs: 11, Failed: 11 ... Test also fails without randomized settings (not a randomization issue), i.e. deterministic, not flaky.
  • The failing statements are all replicated-DDL / DBReplicated-specific server errors
    (Codes 36, 392, 57, 159) raised by the server for the job's own configuration, and this
    PR changes no server code at all: the diff is tests/clickhouse-test,
    ci/jobs/functional_tests.py and a Python test.
  • On that same job flavour over the last 20 days these very tests have thousands of
    green rows whose context nonetheless contains the diagnostics marker, e.g.
    03981_refreshable_mv_retries_int64_max 5737 such rows, 04278_json_minmax_index_mixed_type_array 5641,
    04401_url_engine_s3_dispatch 5596, 03990_alter_rename_column_swap_different_types 5675
    (whitewashed OK on this exact check name). The failures were always there, only the
    verdict changes.
  • 7 of the 8 are named explicitly in the carrier list this PR's description already links
    as required follow-up triage; the 8th (03990) is confirmed by the same query.

This is the rollout consequence flagged in the description: making these failures visible
turns some previously green coverage jobs red. The sequencing decision is for
@maxknv / @alexbakharew, and none of the eight is a reason to change this diff.

Session id: cron:our-pr-ci-monitor:20260728-193000

@groeneai

groeneai commented Aug 1, 2026

Copy link
Copy Markdown
Collaborator Author

Fixing PR for two of the eight lines on the CI finish ledger above:
#112862

It covers 03981_refreshable_mv_retries_int64_max (Code 36, refreshable materialized view with no APPEND over a non-replicated target) and 04278_json_minmax_index_mixed_type_array (Code 392, DROP INDEX plus RESET SETTING in one ALTER), and three further carriers of the same two refusals that are not on this ledger. The APPEND fixture keeps two of them running on the DBReplicated flavours rather than skipping them; the three whose refused statement is the assertion get no-replicated-database.

Still owed here, same fix task, links to follow: 03990_alter_rename_column_swap_different_types, 04318_remote_storage_engine_access, 04401_remote_storage_engine_restore_access, 04401_url_engine_s3_dispatch, 04489_remote_storage_engine_restore_tf_access, 04511_remote_named_collection_complex_overrides. The first is the same Code 392 class; the rest are the replicated-DDL replay and result-differs classes, which need their own investigation and are not skip candidates.

@groeneai

groeneai commented Aug 2, 2026

Copy link
Copy Markdown
Collaborator Author

Resolution of the 04318_remote_storage_engine_access line in the CI finish ledger above (issuecomment-5109038624).

I investigated it. The failure is not flaky and not caused by this PR: it is the replicated-DDL access-control bypass tracked in #111561, where a replayed DDL entry executes with no user and so full_access makes the interpreter's access checks no-ops. The Code: 57 TABLE_ALREADY_EXISTS is a sequel, not the defect: the CREATE that should have been rejected succeeds and leaves the table behind, so the following two statements correctly find it existing. Evidence, including the entry-by-entry server log and the two additional bypassed checks this carrier exposes, is in #111561 (comment).

It is deterministic on Stateless tests (amd_llvm_coverage, old analyzer, s3 storage, DBReplicated, WasmEdge, parallel, 1/3): 4478 of 4478 rows over 2026-07-12..2026-08-02 carry the signature, 407 of them on master. It reports OK for exactly the reason this PR fixes, so it is a good example of what the whitewash was hiding.

Owner correction: I cannot promise a fixing-PR link here. The fix depends on an open design question in #111561 (whether the authorization channel runs on one host, on all hosts, or refuses to execute), which is a product decision rather than something I can pick. That decision is the owner of this line. I will implement it once a direction is chosen.

@groeneai

groeneai commented Aug 2, 2026

Copy link
Copy Markdown
Collaborator Author

Fixing-PR link promised by the CI finish ledger above, for four of the eight rows:
#112993.

Ledger row Owner now
04318_remote_storage_engine_access #112993 (mine, open)
04401_remote_storage_engine_restore_access #112993 (mine, open)
04401_url_engine_s3_dispatch #112993 (mine, open)
04489_remote_storage_engine_restore_tf_access #112993 (mine, open)

All four assert deny paths implemented inside storage construction, and on a Replicated
database the statement is enqueued and replayed by a userless worker, so full_access turns
those checks into no-ops and the deny path silently allows. That is open issue #111561, which
is parked on an owner-level decision, so #112993 pins the four tests with
no-replicated-database plus a comment naming the issue rather than papering over the engine
gap. Divergence rate on the DBReplicated flavours over 21 days is 100% of executed runs for
each of the four.

04511_remote_named_collection_complex_overrides is a different class (Code 159, DDL
timeout) and is not covered by #112993. The remaining three rows (03981, 03990, 04278)
are the statements a Replicated database refuses outright and shipped in merged #112862.

github-merge-queue Bot pushed a commit that referenced this pull request Aug 2, 2026
The first commit's message, and the PR description drafted with it, said these
five tests fail deterministically on the DBReplicated flavours and cited a
reproducibility-check line reading three failures of three reruns, written in a
form the harness does not use. That citation was inherited from earlier triage
notes and never re-measured. It is wrong three ways, and no tracked file
changes here: the tags,
the assertions, every reference file and the mechanism prose corrected in the
previous commit all stay exactly as they are. This commit exists to put the
correction in the history that carries the false claim, since
`.claude/CLAUDE.md` forbids amending or rebasing a branch.

What was wrong. First, the harness never emits that string:
`tests/clickhouse-test` formats `Failed {fail_count} out of {max_reruns}
reruns.`, so someone grepping CI for the quoted text finds nothing, and the
consumer regex on the same file spells `out of` too. Second, the string covers
four carriers, never `02440_mutations_finalization`, whose 6446 rerun-carrying
rows all read `Failed 0 out of 3 reruns` and whose only honest failure in 21
days is one sequential run on an unrelated pull request. Third, for the four
access tests it appears exactly once each, all four on one commit: the run on
#112247 that forwards the job's flags to the diagnostics rerun. Every other row
reads `Failed 0 out of 3 reruns`, which is the whitewash this branch is about.
So the sentence read as a broad standing CI signal when the evidence is one
flags-forwarded run.

What is true instead, measured over the same 21 days on the DBReplicated
checks. The divergence is present in 100% of executed runs of the four access
tests, 4513, 4513, 6772 and 4513 rows, and in 96.4% of `02440`'s, 6447 of 6685.
On the flags-forwarding run the four access tests do report `Failed 3 out of 3
reruns`. Those numbers are stronger than the retracted claim, which is why this
is a citation fix and not a change of substance.
PedroTadim pushed a commit to qiuyanjun888/ClickHouse that referenced this pull request Aug 3, 2026
… path

04296_alter_rename_column_in_memory_rollback fails on every run of the two
DBReplicated llvm_coverage job flavours, and on no other flavour, with
"Code: 47. Missing columns: 'd'". It is deterministic, not flaky. It stayed
invisible because the diagnostics rerun drops the job's
--replicated-database flag, so the rerun passes, the test is labelled
flaky, and the llvm_coverage job force-sets OK. PR ClickHouse#112247 fixes that
forwarding, after which these two jobs start failing for real.

The engine is behaving correctly. --replicated-database makes the test
database ENGINE=Replicated (tests/clickhouse-test:806), so
DatabaseReplicated::hasReplicationThread is true and
StorageMergeTree::alter's in-memory-commit error handler takes the
converge-forward branch (StorageMergeTree.cpp:638-661): the durable commit
already went to ZooKeeper and cannot be rolled back, so the handler
publishes new_metadata at :653 rather than reverting to old_metadata.
Reverting there while the rename mutation stays registered would let a
background merge run the rename against the old schema and reopen the
ClickHouse#80648 data loss, which is exactly the behaviour commit 4676040
removed. Column d is therefore gone by design, and the test's
SELECT id, d correctly raises UNKNOWN_IDENTIFIER.

The test asserts the non-replicated revert contract, so its scope
declaration was simply missing. 04296 is the only one of the seven tests
added by ClickHouse#104822 that lacks no-replicated-database: it was added before
the replicated branch existed and was never revisited.

Tag it, with a reason comment in the same style as its six siblings, and
add 04352 covering the cell the tag excludes:
mt_alter_throw_in_start_mutation on an explicitly created Replicated
database. That combination has no coverage today and is the only way to
reach the "if (!mutation_registered && prepared)" sub-branch at :647,
where the handler must register the prepared mutation itself before
publishing. Total coverage strictly increases and no assertion is
weakened.

Validated on a Debug build: the failure reproduces with the flag and the
same binary passes without it; after the change 04296 is SKIPPED under
--replicated-database and still passes plainly; 50/50 randomized runs
green for both files with no no-random-* tag. 04352 reddens under three
independent mutations: removing its failpoint, changing the
converge-forward line to revert, and deleting the handler's mutation
self-registration at :647 (which loses the mutation and also defaults the
renamed column's data, the ClickHouse#80648 shape). Its system.mutations assertion
reads the in-memory mutation map, so it pins that registration step
rather than a later re-read of the durable mutation file.

Related: ClickHouse#104822
alexey-milovidov pushed a commit to amosbird/ClickHouse that referenced this pull request Aug 14, 2026
04501_distributed_query_client_version_internal_contexts and
04661_refreshable_mv_cancel_during_planning each create a non-APPEND refreshable
materialized view over a non-replicated target. On a Replicated database the
server refuses that shape by design: StorageMaterializedView forces
refresh_coordinated = true for a non-APPEND refreshable view there, so the engine
sanity check throws

  Code: 36 ... refreshable materialized view, no APPEND, replicated database,
  non-replicated table ... Refusing to create.

and the CREATE never succeeds. On the DBReplicated test arm that happens on every
run, master included, so neither test has ever reached its assertions there. It
looked green because the functional-test diagnostics rerun rebuilds the command
without the job's own --replicated-database flag, so the failure does not
reproduce and gets labelled flaky; that half is tracked separately in ClickHouse#112247.

Neither test gets no-replicated-database. Both covered sites are
APPEND-independent, so an APPEND fixture keeps the tests running on every flavour
rather than skipping them, following commit e73f3f1. Each view becomes
APPEND with all_replicas = 1, because SYSTEM REFRESH VIEW, system.processes and a
non-replicated target are all replica-local and a coordinated refresh could run
on the other same-shard replica. The period becomes a relative AFTER 1 YEAR
rather than EVERY 1 YEAR, which floors to January 1 and would let a second
refresh fire mid-test in late December, and EMPTY suppresses the initial refresh
so the explicit trigger is the only refresh. 04661 now triggers its refresh
explicitly, which also removes the cross-replica concurrency its old
every 1 second schedule had.

Validated against a three-server Replicated cluster built from
tests/config/install.sh --db-replicated: both tests fail before this change and
pass after it, on the Replicated and the ordinary arm, 100/100 randomized runs
each with no skips. Reverting each test's covered site (the initiator version
fill in createRefreshContext, the early executing_query_status publication in
refreshTask) makes the corresponding test fail again, so neither fixture passes
vacuously.

Related: ClickHouse#112247

Co-Authored-By: Claude Fable 5 <[email protected]>
@groeneai groeneai added the groeneai-origin-follow-up PR origin: groeneai's own out-of-scope finding during its PR work label Aug 19, 2026
@clickhouse-gh clickhouse-gh Bot added the manual approve Manual approve required to run CI label Aug 19, 2026
The ci/tests suite is gone from master: ClickHouse#114675 and ClickHouse#115650 removed its
contents together with the CI Tests job that ran it (ci/jobs/ci_tests_job.py,
JobConfigs.ci_tests, JobNames.CI_TESTS and the generated ci_tests lane), on the
grounds that it pins the internals of CI scripts rather than their observable
behavior. Master keeps one unrelated file under that path, and no job executes
it, so test_diagnostics_forwards_job_options.py would merge in as 439 lines
that nothing can run.

The observable behavior it asserted is covered end to end by this PR's own CI
run: the amd_llvm_coverage DBReplicated shard reported eight deterministic
configuration-specific failures that the job had been labelling flaky and
force-setting to OK, which is the effect the change exists to produce.
The review rounds answered each challenge by writing the answer into the
source, so the added comments had grown to outnumber the added code. Each
surviving comment now states only a local invariant: the constant that must
track ci/defs/job_configs.py, why a job that overruns its own timeout costs the
downstream coverage job its artifacts, why the rerun's per-test bound must equal
the main run's, why the clock is read once, and the two argv rules for the rerun
command.

The reasoning that moved out of the source: the reserve exists because
Shell.run's timeout bounds the stage only while nothing a rerun spawns outlives
it holding the runner's stdout, and bounding that belongs to
tests/clickhouse-test rather than to this stage. A per-test bound below the main
run's would also shorten the per-test cleanup, which is sized from the same
--timeout and fails against a live server.

diagnostics_budget took num_tests only to document that it deliberately does not
scale with the number of failed tests: a per-test value that differs from the
main run's fabricates a flaky label whichever direction it moves, so only the
stage bound follows the remaining time, and truncating the stage is reported as
"diagnosed N out of M failed test(s)". The count-sensitive control is the
existing "> 10" SKIPPED arm. An argument that exists to be explained away is
better removed.
Merged at 2ae8a25.

One conflict, in ci/jobs/functional_tests.py: master added STACKTRACE_LOGS and
collect_stacktrace_logs at the same anchor below SANITIZERS where this branch
adds the diagnostics budget. Both blocks are kept, master's first so its code
stays in its upstream position.

Master's run_tests now bounds its own Shell.run and states the per-test alarm as
"int(args.timeout * 1.1) + 60 (720s with the default --timeout 600)", which
confirms independently that the main run leaves clickhouse-test's --timeout at
its 600s default. The rerun's bound still matches it, and
common_ft_job_config's timeout is still int(3600 * 2.5).
@groeneai

Copy link
Copy Markdown
Collaborator Author

@alesapin, you asked for the stateless job's per-test --timeout to become configurable here in the public ci/jobs/functional_tests.py. I have it planned and need one decision on the order.

Half of it is already on master: since #121387, run_tests derives the outer Shell.run kill from the per-test timeout instead of a hardcoded 900s. What remains is the job option itself (--timeout, unset by default, so no public job changes), and it depends on this PR. The diagnostics rerun has to use the same per-test limit as the main run, or its verdict can flip through the timeout alone, and a flaky verdict turns the test OK on coverage jobs. Raising the rerun's limit is only safe once the stage has a time bound, which this PR adds: today up to 10 failed tests are rerun one after another, 3 times each for the reproducibility check, with no bound on the stage, so even at 600s it can outlast the 9000s job timeout.

Which do you prefer?

  1. Separate PRs: this one first (it has no reviewer yet), then the option as a small follow-up.
  2. I add the option to this PR.

I would go with 1, so that review of the new option cannot hold up the diagnostics fix.

This was referenced Sep 30, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

@fm4v, your #125180 landed the fix this PR was for: the diagnostics rerun now keeps the job's mode flags, and the coverage flaky -> OK override is gone. On master 360bb0de656e the rerun command of a DBReplicated job carries --replicated-database, which the old command lacked.

The only part of this PR not on master is the time bound on the stage (a Shell.run timeout from the remaining job time, and skipping the stage when less than one 600 s rerun fits). On paper the unbounded stage can outlast the job timeout (up to 10 tests rerun one after another, each rerun allowed 600 s), but I have no CI run where it did.

If this PR is no longer needed, please close it. Otherwise I will reduce it to that bound. I would close it, and add the bound together with the per-test --timeout option @ alesapin asked for above, since a longer per-test limit is what would make the overrun likely.

This branch has not been deployed

No deployments
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-ci-infrastructure CI/CD pipelines (GitHub Actions, CI scripts, runners). groeneai-origin-follow-up PR origin: groeneai's own out-of-scope finding during its PR work manual approve Manual approve required to run CI pr-ci

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants