Skip to content

Revert "Revert "CI: run the full test suite only when review threads are resolved"" - #130509

Merged
alexey-milovidov merged 8 commits into
masterfrom
revert-130368-revert-114729-ci-gate-on-unresolved-review-threads
Nov 12, 2026
Merged

alexey-milovidov merged 8 commits into
masterfrom
revert-130368-revert-114729-ci-gate-on-unresolved-review-threads

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

Reverts #130368


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

Version info

  • Merged into: 26.11.1.2141-master (included in 26.11 and later)

@mintlify

mintlify Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated
ClickHouse-docs 🟢 Ready View Preview Nov 12, 2026, 6:43 PM

@clickhouse-gh

clickhouse-gh Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [de9c1b2]

Summary: ✅


AI Review

Summary

Restores the review-thread CI gate, preserves restrictive label filtering, defers bug-fix validation during limited runs, and stabilizes job digests against host-memory differences. The three previous findings are addressed. One new operational issue remains: failures while establishing the gate expand testing to the full pipeline.

Findings

⚠️ Majors

  • ci/jobs/scripts/workflow_hooks/review_threads.py:257–264: A failed thread query returns successfully without storing KV_UNRESOLVED_COUNT; should_skip_job treats the missing value as zero and admits the full pipeline. The marker-write failure at lines 275–280 does the same despite already knowing that blocking threads exist. With a change to src/Interpreters/Context.cpp and one blocking thread, a throwaway probe reproduces both failures: the filter admits 117 jobs instead of 30, including integration, stateless and performance jobs. A final merge block cannot recover the resources spent. Propagate the query exception and fail configuration when the marker cannot be posted, after the existing retries.
Missing context / blind spots
  • ⚠️ The review skill excludes .github/workflows/*. Automatic reconciliation and infrastructure-retry YAML were therefore outside this review; a separate workflow review and live rerun would validate that portion.
Final Verdict

Status: ⚠️ Request changes. Fail configuration on thread-query or marker-write failure instead of enabling the full test suite.

@alexey-milovidov

alexey-milovidov commented Nov 10, 2026 •

Copy link
Copy Markdown
Member Author

Some people suspected, that resolving a single thread on GitHub reruns the CI. It shouldn't rerun it, instead, it should continue the checks that were previously blocked, if they are now unlocked. Let's make sure it works this way.

But I can't fully trust this evidence, so please take care...

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Nov 10, 2026
@clickhouse-gh
clickhouse-gh Bot requested review from leshikus and maxknv November 10, 2026 13:42
@Algunenano

Copy link
Copy Markdown
Member

@alexey-milovidov Should we add #130491 to this PR? It should fix issues with forks not picking up the re-review correctly

alexey-milovidov and others added 2 commits November 10, 2026 14:09
`BINARY_DOCKER_COMMAND`, `LIMITED_MEM`, `KEEPER_DIND_MEM` and the
`CI_DIND_*` budgets put byte counts derived from `Utils.physical_memory`
into `run_in_docker`, and the job config (including `run_in_docker`) is
hashed into the job digest. The digest is computed in "Config Workflow",
whose runner has a slightly different amount of memory from run to run,
so every build and most tests got a new digest - a cache miss - even on
a rerun of the same commit. Checked by computing the digests of the `PR`
workflow with the physical memory differing by 4 MB: 102 of 178 jobs
changed before, none after.

Example: run 42383050264 (PR #126334), attempt 2 rebuilt all ~30 builds
that had succeeded in attempt 1 for the same merge commit, because their
digests changed (e.g. `Build (amd_debug)`: `...-a08a` -> `...-3ed4`).

Mask byte counts (10+ digits) in `run_in_docker` before hashing. The job
still applies the limits computed on its own runner.

Related: #130509 (comment)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The jobs of a run are fetched with `--paginate`, so a `PR` run (more than
100 jobs) gives several JSON documents. The `finish_window` filter ran
per document and printed an empty window for the page without
"Finish Workflow", so the window bounds started with a newline and the
`created_at <= $to` comparison never matched the
"Failed: review threads only" marker. Every run held by the
unresolved-review-threads gate was then retried as an infrastructure
failure ("job-level heuristic") - a whole rerun that changes nothing,
because the threads are still unresolved.

Example: run 42383050264 (PR #126334, 7 unresolved threads) was rerun by
the 2026-11-07 16:46 tick although its marker was posted inside the
"Finish Workflow" window. Slurp the pages before selecting the job.

Related: #130509 (comment)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@clickhouse-gh clickhouse-gh Bot added the comp-ci-infrastructure CI/CD pipelines (GitHub Actions, CI scripts, runners). label Nov 10, 2026
@alexey-milovidov

Copy link
Copy Markdown
Member Author

Yes, let's add.

@alexey-milovidov

Copy link
Copy Markdown
Member Author

I checked what resolving a thread does. Resolving a thread does not rerun CI. rerun_on_review_threads.yml re-runs the PR workflow only when no blocking thread is left. Resolving one of several threads does nothing. But while #114729 was live, gated PRs did get pointless full reruns that rebuilt everything. That is what people noticed. There were two bugs, both fixed in this PR:

1. Gated runs were retried as infrastructure failures (fixed in 01ea835)

retry_infra_failures.yml is supposed to skip a run when its Finish Workflow failed only because of the gate. The job list is fetched with --paginate, and a PR run has more than 100 jobs, so the list arrives as several JSON documents. The finish_window filter ran once per document and printed an empty line for the page without Finish Workflow. The time bounds then started with \n, so created_at <= $to never matched the Failed: review threads only marker. Every gated run was retried by the "job-level heuristic", even though the threads were still unresolved.

Example: https://github.com/ClickHouse/ClickHouse/actions/runs/42383050264 (#126334, 7 unresolved threads) was re-run at 2026-11-07 16:46 by the retry tick, although its marker (16:14:51) was inside the Finish Workflow window (16:14:00 to 16:14:59). I replayed the exact jq on the real API data: the marker is not found as the code was written, and is found with the pages slurped.

2. A rerun of the same commit misses the cache for builds and most tests (fixed in e682f70, older than this PR, affects all CI caching)

The rerun path relies on cached jobs being skipped, but that did not happen. BINARY_DOCKER_COMMAND, LIMITED_MEM, KEEPER_DIND_MEM and the CI_DIND_* budgets put byte counts from Utils.physical_memory into run_in_docker. run_in_docker is part of the job config hashed into the job digest. The digest is computed in Config Workflow, whose runner has a slightly different amount of RAM each run, so the digests change. In attempt 2 of the run above, every build got a new digest (e.g. Build (amd_debug): 94d088273842e3df43f1-a08a -> -3ed4) on the same merge commit 853d4a836, and all ~30 builds were rebuilt.

I computed the digests of the PR workflow with the physical memory differing by 4 MB: 102 of 178 jobs changed before the fix, 0 after. The fix masks byte counts (10+ digits) in run_in_docker before hashing. Each job still applies the limits computed on its own runner. The digest format changes, so expect one cache miss right after merge.

Impact while the gate was live (2026-11-07 to 2026-11-10)

I looked at all 185 PR-workflow reruns triggered by github-actions[bot]:

  • 97 rebuilt builds that had already succeeded: 2326 builds, ~34,000 runner-minutes.
  • 52 of those rebuilt and unlocked nothing.
  • The useful part, unlocking the skipped tests after the threads were resolved, was ~5800 jobs (~217,000 runner-minutes).

Remaining issues, not fixed here

  • Code Review has no digest config, so every rerun (including the one after the threads are resolved) repeats the AI review. This costs time and tokens, and it can post a new [Blocker] thread that blocks the PR again.
  • The two [Major] review threads above (label-based build filtering in the limited pipeline, and fork PRs missing from the shared-head guard) are about the gate code itself and still need a look.

CI status at 01ea835: green. Style check, Code Review, Review Threads and Mergeable Check pass. Builds and tests are skipped as unaffected by a CI-only change. CH Inc sync is pending. The fixes take effect only after merge: retry_infra_failures.yml runs from the default branch, and the digest change applies to future PR runs.

@alexey-milovidov alexey-milovidov self-assigned this Nov 10, 2026
alexey-milovidov and others added 2 commits November 10, 2026 21:49
With unresolved review threads, `should_skip_job` returned "run" for every
allowlisted build and preliminary job before the label rules, so a label
that restricts the pipeline was ignored: with `do not test` and a change to
`src/Interpreters/Context.cpp`, one unresolved thread grew the run from 1
job to 30 (29 builds), `ci-performance` from 14 to 30, and `no-fast-tests`,
`ci-llvm-coverage` and `ci-build` got back the jobs they skip.

Let the allowlisted jobs go on to the same decisions as in a full run, so a
limited run is the intersection of the allowlist and the full run. This
replaces the per-rule exceptions (coverage, `ci-llvm-coverage`, small PRs),
and the `notes` parameter of `_coverage_family_decision` they needed.

Checked with a throwaway script over all `PR` workflow jobs and eight
label sets: before, the limited run had jobs the full run skips; after,
none, and nothing outside the allowlist.

Related: #130509 (comment)
`commits/<sha>/pulls` returns nothing for a commit that lives in a fork, and
`workflow_run.pull_requests` is empty for fork PRs. So a completed `PR` run of
a fork PR was never reconciled ("No PR associated with the event"), and only
the scheduled poll could re-run the skipped jobs. The same lookup made
`retry_infra_failures.yml` skip fork PRs, and made the shared-head-commit
checks (`shared_sha_prs`, `other_open_prs_on_head`) blind to fork PRs.

Resolve the PR of a run by its head branch instead, and find the other PRs
with a given head commit with a search by the commit as well.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 1e22b7a)
The unresolved-review-threads gate skips the per-arch Bugfix Validation
jobs, so for a bug-fix PR with a functional or integration regression test
`new_tests_check.check` found no `OK`/`XFAIL` result and failed. Then
`Mergeable Check` said `Failed: Workflow Post Hook` instead of
`Failed: review threads only`, and `retry_infra_failures.yml` retried the
run, which is exactly the pointless rerun the gate exclusion is for.

When `KV_PIPELINE_LIMITED` is set, defer this verdict to the full run. The
gate keeps the merge blocked until then. The other checks (no new tests at
all, the unit validator refuting the test) are unchanged.

Related: #130509

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…t-114729-ci-gate-on-unresolved-review-threads

# Conflicts:
#	ci/jobs/scripts/workflow_hooks/filter_job.py
Comment on lines +257 to +264
except Exception as e:
# Fail toward more testing: without the thread state the full suite
# runs as before. The merge gate in can_be_merged.py re-checks at
# finish time and fails close there.
print(
f"WARNING: failed to fetch the review threads state [{e}] - the full CI suite will run"
)
return

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Major] Fail configuration when the gate state cannot be established

Returning successfully here leaves KV_UNRESOLVED_COUNT unset, which should_skip_job interprets as zero. A thread-query failure therefore enables the full pipeline despite unresolved blocking threads. The same expansion happens at lines 275–280 when the marker write fails, even though the hook has already confirmed that blocking threads exist. In a throwaway probe with a change to src/Interpreters/Context.cpp and one blocking thread, either failure made the filter admit 117 jobs instead of 30, including integration, stateless and performance jobs.

This turns a GitHub API failure into an expensive CI run, defeating the gate's resource-saving purpose; failing closed at finish time cannot recover those resources. After the existing API retries are exhausted, propagate the thread-query exception and fail the config hook on a marker-write failure, so a retry can establish the gate before scheduling the test suite.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not a problem. We expect that AI models can be unavailable, and in case of any error, we run the full test suite.

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Nov 12, 2026
Merged via the queue into master with commit 1ad277e Nov 12, 2026
204 checks passed
@alexey-milovidov
alexey-milovidov deleted the revert-130368-revert-114729-ci-gate-on-unresolved-review-threads branch November 12, 2026 22:12
@robot-ch-test-poll robot-ch-test-poll added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 12, 2026

This branch was successfully deployed

1 active deployment
staging - docs — de9c1b29 Deployed Nov 12, 2026 by mintlify[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-ci-infrastructure CI/CD pipelines (GitHub Actions, CI scripts, runners). pr-not-for-changelog This PR should not be mentioned in the changelog pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants