Repository navigation
Run a stateless flaky check in the merge queue - #110308
Conversation
A PR's green CI describes the master of its last run, not of its merge. PR #108548 merged on 2026-07-13 with CI last run on 07-01; on 07-03 master merged #108511, which added materialize_statistics_on_insert to the settings randomizer in tests/clickhouse-test. The PR's new test 02346_text_index_bug108519_qcc_skip_index then failed on master whenever the randomized setting was drawn (~40% of runs) and kept master red for ~7 hours until #110260 pinned auto_statistics_types at the table level. The merge queue already builds the exact merged state (Build (amd_binary)) but ran no stateless tests on it. Add "Stateless tests (amd_binary, flaky check)" to MergeQueueCI: it reruns the PR's new/changed stateless tests on the merge group state (the PR merged with the current master), so a semantic conflict with post-CI master changes bounces the PR from the queue instead of breaking master. The job self-skips when the PR changes no tests. Merge-queue runs use a reduced budget (20 iterations / 20 min instead of 50 iterations / 45 min): the PR CI already ran the full flaky check, and a randomized setting drawn with probability 0.4 per run escapes 20 iterations with probability 0.6^20 ~= 4e-5. Changed-file detection in merge-queue runs now uses the linked PR's paginated files list (PR_NUMBER is 0 there, and the commits API caps a merge commit's file list at 300 entries), and the changed-files fetch fails closed in merge-queue runs so a GitHub API failure cannot silently skip the check. Incident: #108548 Follow-up fix it required: #110260 Co-Authored-By: Claude Fable 5 <[email protected]>
|
Workflow [PR], commit [66dfd5d] Summary: ✅ AI ReviewSummaryThis PR adds a merge-queue stateless flaky check that reruns PR-touched stateless tests on the merge-group state, tightens merge-queue changed-file discovery, and bounds the merge-queue flaky-check runtime. High-level verdict: the main workflow wiring looks reasonable, but one remaining selector gap still lets the new drift guard self-skip on realistic stateless-fixture-only changes, so the advertised coverage is not complete yet. Findings
Tests
Final VerdictStatus: |
…umber
In `GH.get_changed_files`, a merge-queue run with an unparseable merge group
head ref left `linked_pr_number` at 0, so the code fell through to
`repos/{repo}/commits/{sha}`, whose file list is capped at 300 entries. On a
large PR that can silently drop changed test files and turn the merge-queue
flaky check into a false green.
A merge-queue entry always corresponds to exactly one PR, so a missing linked
PR number is a real fault, not a skip condition. Fail closed (raise) on a
strict call instead of falling back to the capped commits API; the tolerant
non-strict path is preserved for master/release-style callers.
AI review: #110308
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…xhausts its budget The flaky-check time budget was computed as `max(FLAKY_CHECK_TIME_LIMIT - elapsed, 0)`, but `run_tests` interprets `global_time_limit == 0` as "pass no `--global_time_limit`" - i.e. no cap at all, and no outer `Shell.run` timeout either. Once setup consumes the whole budget (more likely under the tighter 20-minute merge-queue limit) the run becomes unbounded, defeating the latency bound the reduced budget exists to enforce. Floor the budget at a small positive value (60s) so a positive `--global_time_limit` is always passed and the run stays bounded, mirroring the existing targeted-check floor. AI review: #110308 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…on-test PRs The `SKIPPED` exit in `functional_tests.py` happens only after the job has been scheduled, restored `CH_AMD_BINARY`, and entered the stateless-test container, so a source-only PR still paid that startup cost even though there were no stateless tests to rerun - breaking the "non-test PRs pay nothing" contract. Add a minimal `workflow_filter_hooks` entry (`should_skip_merge_queue_job`) to `MergeQueueCI` that filters the flaky check at config time when the PR changes no stateless tests, so such a PR never schedules the runner. The hook is the merge-queue counterpart to the `flaky` branch of `should_skip_job`, kept deliberately minimal so it can never skip the build/style/fast-test jobs the queue always needs. Its skip condition matches the in-job selection (both use `Targeting.get_changed_tests`), so the config-time skip and the early exit never disagree. A filtered job reports `SKIPPED`, which already counts as success for the merge-ready status. AI review: #110308 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Addressed the three AI-review majors (each as its own commit, with unit tests):
Tests: |
|
|
||
| targeter = Targeting(info=_info_cache) | ||
| targeter.job_type = Targeting.STATELESS_JOB_TYPE | ||
| if not targeter.get_changed_tests(): |
There was a problem hiding this comment.
Targeting.get_changed_tests() is narrower than "all changed stateless tests": it only returns paths it can map back to a concrete root-level test name. That means a PR that changes an auxiliary fixture under tests/queries/0_stateless/ can still be treated as "no changed tests" here.
For example, tests/queries/0_stateless/data_parquet/02716_data.parquet is consumed by tests/queries/0_stateless/02716_parquet_invalid_date32.sh, but get_changed_tests() ignores that path entirely, so this hook filters the merge-queue flaky check out. The job then goes green without ever rerunning the modified test surface on the merge-group state, which reintroduces a false-green path for the exact drift this PR is meant to catch.
Please either teach the targeting logic to map helper/data-file changes back to their owning stateless tests, or conservatively keep the merge-queue flaky check enabled whenever a changed path under tests/queries/0_stateless/ cannot be resolved to a concrete test name.
There was a problem hiding this comment.
Fixed in 66dfd5d by mapping auxiliary fixtures back to their owning test(s) in Targeting.get_changed_tests — the shared selector both the config-time skip and the in-job selection use, so they stay in sync.
Fixtures carry the owning test's five-digit prefix by convention, so the prefix narrows the candidates to the NNNNN_* tests at the suite root (a handful of files, never the whole suite). Among those, the ones whose body references the fixture by name are preferred, with a conservative fallback to all prefix siblings when the reference is built dynamically. Only real tests are emitted, so a fixture-only PR reruns the affected surface without ever fabricating a zero-match pattern (which would make clickhouse-test exit 1, the failure mode PR #104097 fixed).
Your exact example now resolves: data_parquet/02716_data.parquet → 02716_parquet_invalid_date32. Covered by new tests in ci/tests/test_find_tests.py (subdirectory fixture, root-level orphan, unmappable fixture, and the end-to-end get_changed_tests path). As a side effect this also fixes a latent gap where four-digit-prefixed root tests (4060_*, 4061_*) were skipped by the old \d{5} regex.
There was a problem hiding this comment.
This is still reproducible for auxiliary stateless files that do not carry a five-digit test prefix.
_tests_owning_data_file returns [] immediately when os.path.basename(fpath) does not match r"(\d{5})" in ci/jobs/scripts/find_tests.py:129-131, so a fixture-only diff like tests/queries/0_stateless/data_mysql_dump/dump1.sql still produces no selected tests. 02286_mysql_dump_input_format.sh consumes that file at tests/queries/0_stateless/02286_mysql_dump_input_format.sh:8-24, but the current tree still makes Targeting.get_changed_tests return [] for a diff containing only data_mysql_dump/dump1.sql, which means should_skip_merge_queue_job keeps skipping the merge-queue drift guard for that PR shape.
The fix still needs a conservative path for unmappable files under tests/queries/0_stateless/ (for example, keep the job enabled and fall back to a broader rerun) instead of treating them as “nothing to rerun”.
The merge-queue flaky check (and the regular flaky check it is built on)
selected tests via `Targeting.get_changed_tests`, which only mapped a changed
path back to a test when the path was itself a test source or a supporting
file with a same-named sibling test. A data fixture consumed by a test — either
a root-level orphan like `02995_settings_26_4_1.tsv` or, worse, one nested in a
subdirectory like `data_parquet/02716_data.parquet` (which the old
`\d{5}`-after-prefix regex did not even consider) — resolved to no test. A PR
that changed only such a fixture was therefore treated as "no changed tests",
so `should_skip_merge_queue_job` skipped the drift guard and the merge group
never reran the affected test surface: a false green for the exact drift this
check exists to catch.
Map auxiliary fixtures back to their owning test(s). Fixtures carry the owning
test's five-digit prefix by convention, so the prefix narrows the candidates to
the `NNNNN_*` tests at the suite root (a handful of files, never the whole
suite); among those, prefer the ones whose body actually references the fixture
by name, and fall back to all prefix siblings only when the reference is
constructed dynamically. Only real tests are emitted, so a run never fabricates
a zero-match pattern (which would make `clickhouse-test` exit 1, the failure
mode `PR #104097` fixed). Because both the config-time skip and the in-job
selection call `get_changed_tests`, they stay in sync automatically.
As a side effect this also fixes a latent gap: root-level tests with a
four-digit prefix (`4060_*`, `4061_*`), which the old `\d{5}` regex skipped, are
now selected.
Tests: `ci/tests/test_find_tests.py` covers the subdirectory fixture, the
root-level orphan, unmappable fixtures, and the end-to-end `get_changed_tests`
path.
|
Addressed the remaining AI-review Major (fixture-only changes could false-green the drift guard), commit
Now every changed path under The reviewer's example now resolves: Tests: |
alexey-milovidov
left a comment
There was a problem hiding this comment.
Sounds good, let's try.
…umber
In `GH.get_changed_files`, a merge-queue run with an unparseable merge group
head ref left `linked_pr_number` at 0, so the code fell through to
`repos/{repo}/commits/{sha}`, whose file list is capped at 300 entries. On a
large PR that can silently drop changed test files and turn the merge-queue
flaky check into a false green.
A merge-queue entry always corresponds to exactly one PR, so a missing linked
PR number is a real fault, not a skip condition. Fail closed (raise) on a
strict call instead of falling back to the capped commits API; the tolerant
non-strict path is preserved for master/release-style callers.
AI review: ClickHouse#110308
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…xhausts its budget The flaky-check time budget was computed as `max(FLAKY_CHECK_TIME_LIMIT - elapsed, 0)`, but `run_tests` interprets `global_time_limit == 0` as "pass no `--global_time_limit`" - i.e. no cap at all, and no outer `Shell.run` timeout either. Once setup consumes the whole budget (more likely under the tighter 20-minute merge-queue limit) the run becomes unbounded, defeating the latency bound the reduced budget exists to enforce. Floor the budget at a small positive value (60s) so a positive `--global_time_limit` is always passed and the run stays bounded, mirroring the existing targeted-check floor. AI review: ClickHouse#110308 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…on-test PRs The `SKIPPED` exit in `functional_tests.py` happens only after the job has been scheduled, restored `CH_AMD_BINARY`, and entered the stateless-test container, so a source-only PR still paid that startup cost even though there were no stateless tests to rerun - breaking the "non-test PRs pay nothing" contract. Add a minimal `workflow_filter_hooks` entry (`should_skip_merge_queue_job`) to `MergeQueueCI` that filters the flaky check at config time when the PR changes no stateless tests, so such a PR never schedules the runner. The hook is the merge-queue counterpart to the `flaky` branch of `should_skip_job`, kept deliberately minimal so it can never skip the build/style/fast-test jobs the queue always needs. Its skip condition matches the in-job selection (both use `Targeting.get_changed_tests`), so the config-time skip and the early exit never disagree. A filtered job reports `SKIPPED`, which already counts as success for the merge-ready status. AI review: ClickHouse#110308 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Run a stateless flaky check in the merge queue
Related: #108548
Related: #110260
Related: #108511
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
A PR's green CI describes the
masterof its last run, not of its merge. #108548 merged on 2026-07-13 with CI last run on 07-01; on 07-03mastermerged #108511, which addedmaterialize_statistics_on_insertto the settings randomizer intests/clickhouse-test. The PR's new test02346_text_index_bug108519_qcc_skip_indexthen failed onmasterwhenever the randomized setting was drawn (~40% of runs) and keptmasterred for ~7 hours until #110260 pinnedauto_statistics_typesat the table level. The flaky check would have caught this with near certainty — it just last ran against amasterthat did not have the randomizer yet.The merge queue already builds the exact merged state (
Build (amd_binary)) but ran no stateless tests on it. This PR addsStateless tests (amd_binary, flaky check)toMergeQueueCI: it reruns the PR's new/changed stateless tests on the merge group state (the PR merged with the currentmaster), so a semantic conflict with post-CImasterchanges bounces the PR from the queue instead of breakingmaster. The job self-skips when the PR changes no tests, so non-test PRs pay nothing.Details:
rerun_count20 instead of 50 and a 20-minute instead of 45-minute time limit, since the PR CI already ran the full flaky check and this rerun is a drift guard. A randomized setting drawn with probability 0.4 per run escapes 20 iterations with probability 0.6^20 ≈ 4e-5.--sequential-test-runsscales along, as it is derived fromrerun_count.PR_NUMBERis 0 in amerge_groupevent (onlyLINKED_PR_NUMBERis parsed from the queue ref), and the previously used commits API caps a merge commit's file list at 300 entries.store_data.pynow fails closed in merge-queue runs (as it already did for PR runs), so a persistent GitHub API failure cannot silently turn the flaky check into a skip. Master/release workflows keep the tolerant behavior..github/workflows/merge_queue.ymlis regenerated withpraktika yaml.A
SKIPPEDresult (no tests to run) counts as success for the merge-ready status, same as in PR CI.Version info
26.7.1.967(included in26.7and later)