Repository navigation
Revert "Revert "Correct nightly coverage selection and share PR test manifests"" - #122111
Conversation
|
Workflow [PR], commit [2c4057e] Summary: ✅ AI ReviewSummaryThis revert-of-revert re-enables coverage-based targeted selection for PR stateless jobs and adds nightly/export smokes plus selection manifests. The query optimization itself looks reasonable, but the current head still has multiple CI-correctness gaps: targeted stateless results are still cacheable on inputs the digest cannot represent, mixed CIDB failures can be downgraded to Findings❌ Blockers
|
| Metric | Baseline | Current | Δ |
|---|---|---|---|
| Lines | 88.20% | 88.10% | -0.10% |
| Functions | 91.80% | 91.70% | -0.10% |
| Branches | 79.50% | 79.40% | -0.10% |
Changed lines: Uncovered code analysis did not run: No coverable C/C++ source files changed (contrib/ is excluded from coverage).
Newly covered: +187 lines in 53 files (-123 lines lost coverage) · Details
| if job.parameter.startswith( | ||
| ( | ||
| "amd_asan_ubsan, db disk, distributed plan,", | ||
| "amd_tsan, s3 storage,", |
There was a problem hiding this comment.
This narrows the PR TSan matrix down to the s3 storage configuration only. Before the revert, the selected-test lanes still kept both the plain amd_tsan jobs and the amd_tsan, s3 storage jobs; after functional_tests_pr_jobs filters out every sanitizer lane below, the default TSan functional environment disappears from PR CI entirely and only the S3-flavored job remains.
That is a real coverage loss: regressions that reproduce only in the ordinary TSan setup now get no PR-level TSan signal unless they happen to be covered by the separate changed-test flaky check. Please keep the plain amd_tsan configuration in stateless_tests_sanitizer_pr_jobs as well, or explain why the s3 storage lane is intended to replace it completely.
| ) | ||
| print(f"[selected tests] {len(tests)} tests to run: {tests}") | ||
|
|
||
| if not tests: |
There was a problem hiding this comment.
With the old selected-tests path gone, this branch now trusts the selector to always return at least one real test. But Targeting.get_changed_tests only maps files under tests/queries/0_stateless, so a PR that changes only the targeted-check harness itself (ci/jobs/functional_tests.py, find_tests.py, coverage_selection.py, etc. — including this one) produces changed=[], coverage_lines=[], and usually previously_failed=[] on the first attempt.
In that case we hit this SKIPPED exit and the only PR sanitizer lanes that exercise targeted mode never actually run clickhouse-test on the very selector/harness changes they are supposed to validate. The old STATELESS_HARNESS_SMOKE_TESTS fallback existed exactly to avoid that blind spot. Please restore a small deterministic smoke list for harness/selector changes, or otherwise guarantee that targeted jobs execute at least one real test when their own pipeline changes.
The snapshot query counted `uniqExact(test_name)` over the whole 14-day window of `checks_coverage_lines`: 3.5 billion rows and 57 GB, about 6 s on an idle server. Every targeted stateless job of every PR runs it, so while the per-test coverage export was inserting (2026-09-24 18:00-20:00 and 2026-09-25 02:00-04:00 UTC) it exceeded the 60 s timeout on all five attempts. 190 of the 199 "Failed to load test selection" errors since the selector was merged were this query, and as `Stateless tests (amd_asan_ubsan, db disk, distributed plan, targeted)` is a core blocking job, each of them skipped the rest of the PR pipeline. This is why #118223 was reverted in #122110. Now the distinct `check_start_time` values of the window are listed first (only that column is read, about 0.3 s), and exported tests are counted for the newest three timestamps at a time, filtered by the primary key, until every shard has `coverage_run_count` healthy snapshots. On live CIDB data the result is identical to the old query at every cutoff tried, and it reads 6-10 GB of `test_name` instead of 57 GB, in 1.4-2.3 s instead of about 6 s. Example failure: https://s3.amazonaws.com/clickhouse-test-reports/PRs/122067/925c788e633f3e3fd2f31f3cd68b916ceb728a3e/pr/stateless_tests_arm_asan_ubsan_targeted/job.log (#122067)
Count exported tests for five timestamps per query, give the snapshot queries a 180 s timeout instead of the default 60 s, and enable the query cache for them: they only read settled exports, so every job and pull request gets the same result. On live CIDB data a repeated lookup reads 0 rows and the result is unchanged. If a CIDB request of the test selection still times out on every attempt, the targeted stateless job is now `SKIPPED` instead of `ERROR`, so it no longer skips the jobs waiting for the core blocking jobs. It adds a workflow warning and a comment, and is not cached, so a rerun or the next commit selects again. Other selection failures remain errors. `CIDB` raises the new `CIDBTimeoutError` for this case, and the PR summary table now also lists skipped jobs that carry a comment, so such a skip is visible instead of silently green.
| @@ -1990,9 +857,9 @@ def _parse_diff_lines(diff_text: str) -> list: | |||
| old_line += 1 | |||
| elif line.startswith("+"): | |||
| changed.add((current_file, old_line)) # insertion point in old file | |||
There was a problem hiding this comment.
For a brand-new source file hunk (@@ -0,0 +... @@), old_line is 0 here and _parse_diff_hunk_ranges also records (0, 0). build_candidate_query later turns that into line_end >= 0 AND line_start <= 0, but stored coverage is 1-based, so a PR that only adds a new src/ / programs/ / base/ file produces no precise coverage candidates at all.
Because this PR removed the old broad fallback, targeted selection can now end up empty (or only run unrelated stale failures) for brand-new production code. Please special-case -0,0 hunks to map to the added new-line range, or at least clamp new-file additions to line 1 before building the coverage predicate.
|
|
||
| print(f"WARNING: CIDB {error} - attempt {retry}/{retries}") | ||
| if retry >= retries: | ||
| if timed_out: |
There was a problem hiding this comment.
CIDBTimeoutError is documented and consumed as "every attempt timed out", but timed_out here only reflects the last retry. A sequence like ConnectionError, ConnectionError, ReadTimeout now raises CIDBTimeoutError, and functional_tests.py converts that mixed CIDB failure into SKIPPED instead of ERROR, letting downstream PR jobs proceed.
Please accumulate an all_timed_out flag across retries and raise CIDBTimeoutError only when every failed attempt was a client-side timeout.
| # `find_tests.py` selects the targeted tests from CIDB and reads | ||
| # `Info`, so both modules decide which tests this job runs. | ||
| "./ci/praktika/cidb.py", | ||
| "./ci/praktika/info.py", |
There was a problem hiding this comment.
Targeted stateless jobs now always execute python3 -m ci.jobs.scripts.test_selection_smoke, and the rerun-cutoff path in find_tests.py depends on Info.run_attempt / workflow_start_time, which are populated in ci/praktika/_environment.py. Neither file is covered by this digest.
That means a PR that only changes test_selection_smoke.py or _environment.py can reuse a cached targeted result and never exercise the selector path it actually modified. Please add both files to common_ft_job_config.digest_config.include_paths.
| "ci/jobs/scripts/job_hooks/llvm_coverage_hook.py", | ||
| # Exports per-test coverage and runs the post-export selector smoke. | ||
| "ci/jobs/scripts/functional_tests/export_coverage.py", | ||
| "ci/jobs/scripts/coverage_selection.py", |
There was a problem hiding this comment.
coverage_selection.py imports SELECTION_CONFIG directly, and the nightly/export smoke path uses that module too. A PR that only changes ci/jobs/scripts/test_selection_config.py still makes _has_coverage_pipeline_changes return false here, so the whole amd_llvm_coverage* / LLVM Coverage family is skipped as "coverage identical to master" even though the selector thresholds and timeouts it runs with have changed.
Please add test_selection_config.py (and any other selector-contract inputs that must rerun coverage jobs) to _COVERAGE_PIPELINE_PATHS.
The targeted stateless jobs ran `test_selection_smoke` before every selection. It checks the selection code, not the pull request, so it only needs to run when a pull request changes that code: `Targeting.SELECTION_SOURCES`. If the changed files are unknown it still runs.
| "ci/jobs/scripts/test_selection_config.py", | ||
| "ci/jobs/scripts/test_selection_manifest.py", | ||
| "ci/jobs/scripts/test_selection_smoke.py", | ||
| "ci/praktika/cidb.py", |
There was a problem hiding this comment.
SELECTION_SOURCES is the contract for "changes that must run test_selection_smoke before targeted selection", but selection_code_changed, get_changed_tests, and selection_cutoff all read through Info, and this PR adds new Info.workflow_start_time / Info.run_attempt carriers without listing ci/praktika/info.py here.
A future PR that changes only those proxies will rerun the selector with different semantics but skip the smoke, so the per-attempt cutoff invariant can regress silently. Please include ci/praktika/info.py here as well (and, if _environment.py remains an independent selection input, the carrier that feeds it too).
Nothing read the results of these, so they only cost code and CPU in every targeted job: - `_extract_domain_keywords` and the `semantic_keyword_matches` it filled in. - The `shadow` rankings, three extra `rank_candidates` calls per job for the entry-count experiments. - The expanded targeted matrix: it was built and then discarded, because `expanded_targeted_matrix` was off. Removes `targeted_matrix` and `rollout_targeted_jobs`. The generated workflows are unchanged. - `_stored_path`, which had no callers. - The offline replay tool `evaluate_test_selection.py`, which no CI job ran, and with it the entry-count experiments in `rank_candidates` (`entry_mode`, `entry_count_bonus_bound`), which only it and the shadow rankings used. Production scoring was `entry_mode="disabled"` and does not change.
| results=results, | ||
| ) | ||
| skipped.set_comment("CIDB timeout in test selection, rerun to test") | ||
| skipped.complete_job(do_not_cache=True) |
There was a problem hiding this comment.
Only the CIDB-timeout skip is marked do_not_cache=True here, but the normal targeted path still publishes an ordinary cache-success record. That is not a safe cache key anymore: the selected test list now depends on the PR diff, selection_cutoff() / run attempt, and CIDB failure history, while Praktika still reuses this job purely by repository-file digest.
The result is that once one PR produces a green Stateless tests (..., targeted) record, another PR with the same repo digest can reuse it from the shared cache and skip its own targeted execution entirely. Please make targeted stateless jobs uncached (digest_config = None) or force do_not_cache=True for every targeted exit, not only the timeout case.
…t-118223-nightly-coverage-test-selection # Conflicts: # ci/defs/job_configs.py # ci/jobs/scripts/find_tests.py
…est-selector Master re-landed ClickHouse#118223 (74c90e9, ClickHouse#122111), which restores Targeting.selection_test_name and ci/jobs/scripts/test_selection_smoke.py and drops DIRECT_CALL_MAX_DEPTH: - ci/jobs/scripts/find_tests.py: selection_pattern builds on selection_test_name again, as before the revert, instead of repeating its normalization. DIRECT_CALL_MAX_DEPTH stays removed. - ci/jobs/scripts/test_selection_smoke.py: the two selector checks are back. The targeted job runs this suite when find_tests.py changes. Re-validated on the merged tree: the smoke suite passes 16/16 and each selector check fails under its mutation; every one of the 15,806 stateless test sources is selected alone by its selector from every name shape a producer emits, through the real run_tests command line, bash and the tests/clickhouse-test matcher. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ted job ClickHouse#122111 made the targeted stateless and integration jobs SKIP instead of ERROR when a test-selection CIDB request times out on every attempt (`CIDBTimeoutError`). The first selection read, the strict previously-failed lookup in `Targeting.get_previously_failed_tests_with_info`, re-wrapped any exception as a plain `RuntimeError`, so a timeout there lost its class before reaching either `except CIDBTimeoutError` handler and the shard still ERRORed ("Failed to load test selection" in the stateless job, an uncaught exception in the integration job). On a `pr-bugfix` PR that drops `Bugfix validation` and fails `Finish Workflow / Post Hooks`. Re-raise `CIDBTimeoutError` unchanged in strict mode. Every other failure (a refused connection, an answered non-OK response) stays wrapped and keeps failing the job, as ClickHouse#114730 intends. Best-effort mode is unchanged. CIDB shows 3 such errors, all on 2026-09-24/25 during the CIDB overload ClickHouse#122111 targets (PRs ClickHouse#118823, ClickHouse#117436, ClickHouse#114865). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Related: #118223
Related: #122110
Related: #122067
This re-lands #118223 (precise-coverage test selection inside each targeted stateless job), which was reverted in #122110, together with fixes for the reason of the revert.
Why it was reverted
Targeted stateless jobs failed with
Failed to load test selection: CIDB query failed ... Read timed out (read timeout=60), for example in #122067 (job log).Stateless tests (amd_asan_ubsan, db disk, distributed plan, targeted)is a core blocking job, so each such failure skipped the rest of the PR pipeline.In CIDB, 190 of the 199
Failed to load test selectionerrors between the merge and the revert came from the coverage snapshot query inTargeting.coverage_snapshots. It computeduniqExact(test_name)over the whole 14-day window ofchecks_coverage_lines: 3.5 billion rows and 57 GB (test_nameis 288 of the table's 304 GiB), about 6 s on an idle server. Every targeted job of every PR ran it, and the failures clustered at 2026-09-24 18:00-20:00 and 2026-09-25 02:00-04:00 UTC, when the per-test coverage export inserts about 240 million rows. Under that load all five 60 s attempts timed out.Changes on top of the reverted PR
load_snapshotsincoverage_selection.py): first the distinctcheck_start_timevalues of the window (only that column is read, about 0.3 s), then the exported tests are counted for five timestamps per query, filtered by the primary key, newest first, until every shard hascoverage_run_counthealthy snapshots. At six cutoffs on live CIDB data the result is identical to the old query, with 6-10 GB oftest_nameread instead of 57 GB and 1.4-2.3 s instead of about 6 s.use_query_cache = 1(TTL 1 h): they only read settled exports, so all jobs and PRs get the same result. A repeated lookup reads 0 rows. They also get a 180 s timeout per attempt instead of 60 s (CIDB.queryaccepts atimeout).CIDBTimeoutError), the targeted job endsSKIPPEDinstead ofERROR, so it no longer skips the jobs that wait for the core blocking jobs. It adds a workflow warning and the commentCIDB timeout in test selection, rerun to test, and it is not cached. The PR summary table now also lists skipped jobs that carry a comment, so the skip is visible. Other selection failures remain errors.test_selection_smokeruns in a targeted job only when the PR changes the selection code (Targeting.SELECTION_SOURCES), not in every PR._extract_domain_keywords), theshadowrankings (three extrarank_candidatescalls per job whose output nothing read), the expanded targeted matrix that was built and discarded becauseexpanded_targeted_matrixwas off, the entry-count experiments, and the offline replay toolevaluate_test_selection.py. Production ranking and the generated workflows are unchanged.Validation
python3 -m ci.jobs.scripts.test_selection_smokepasses, including new tests for the snapshot walk and forCIDBTimeoutError.ci/, so its own targeted jobs select no tests and do not reach the coverage path. That path was run locally against the live public CIDB endpoint with the diff of Use text and token skip indexes for IN with transform_null_in = 1 (Human alternative for #112785) #121375: the snapshot lookup took five queries and about 0.8 s, with the query cache enabled.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Workflow [PR]
Sync PR [sync-upstream/pr/122111]
Version info
26.10.1.741-master(included in26.10and later)