Skip to content

Stable 25.3 Backport of #99628 - Fix TOCTOU race in vertical merge cancellation - #2817

Merged
zvonand merged 3 commits into
releases/25.3.14from
backports/releases/25.3.14/99628
Nov 19, 2026
Merged

zvonand merged 3 commits into
releases/25.3.14from
backports/releases/25.3.14/99628

Conversation

@blau-ai

@blau-ai blau-ai commented Nov 9, 2026

Copy link
Copy Markdown
Collaborator

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):

Fix a rare logical error exception during vertical merge when SYSTEM STOP MERGES and SYSTEM START MERGES are executed concurrently. (ClickHouse#99628 by @Daedalus-Icarus)

Documentation entry for user-facing changes

...

CI/CD Options

Exclude tests:

  • Fast test
  • Integration Tests
  • Stateless tests
  • Stateful tests
  • Unit tests
  • Performance tests
  • Aarch64 tests
  • All with ASAN
  • All with TSAN
  • All with MSAN
  • All with UBSAN
  • All with Coverage
  • All Regression
  • Disable CI Cache

Regression jobs to run:

  • Fast suites (mostly <1h)
  • Aggregate Functions (2h)
  • Alter (1.5h)
  • Benchmark (30m)
  • CAS (content-addressed storage; Antalya only)
  • ClickHouse Keeper (1h)
  • Iceberg (2h)
  • LDAP (1h)
  • OAuth (5m)
  • Parquet (1.5h)
  • RBAC (1.5h)
  • SSL Server (1h)
  • S3 (2h)
  • S3 Export (2h)
  • Swarms (30m)
  • Tiered Storage (2h)

Avogar and others added 2 commits November 9, 2026 11:05
Fix TOCTOU race in vertical merge cancellation

Conflicts committed as-is; the next commit resolves them:
- src/Storages/MergeTree/MergeTask.cpp (both modified)
Kept the PR's latched `cancelled` variable in `executeImpl`, using the release branch's `ctx->is_cancelled()`.
@blau-ai

blau-ai commented Nov 9, 2026

Copy link
Copy Markdown
Collaborator Author

Port-AL: cherry-pick conflicts resolved by AI

Conflicted files:

  • src/Storages/MergeTree/MergeTask.cpp (both modified)

Commits:

  • 486cbec: cherry-pick with the conflicts committed as-is

  • 168d5b0: resolution

  • Conflict: in MergeTask::ExecuteAndFinalizeHorizontalPart::executeImpl, HEAD had the old single-line if (ctx->is_cancelled() || !...pull(block)). The cherry-picked change replaced it with a latched bool cancelled.

  • Resolution: I removed the conflict markers and the old line, and kept the PR's version. The cancellation is read once and stored into merge_list_element_ptr->is_cancelled, so finalize throws reliably.

  • Why it fits: the release branch's ctx->is_cancelled lambda already includes the blocker and the TTL blocker, so it works with the new code.

  • Vertical merge hunk: the executeVerticalMergeForOneColumn change applied without conflict, and I left it as is.

@zvonand

zvonand commented Nov 19, 2026

Copy link
Copy Markdown
Member

@blau-ai

@blau-ai

blau-ai commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator Author

CI triage for #2817 (head 5b9f7f98a4)

Verdict: 4 failing checks, none caused by this PR. 2 are infra (runner killed), 2 are pre-existing and fail the same way on every recent releases/25.3.14 backport.

Check Classification PR-caused?
IntegrationTestsAnalyzerAsan / Integration tests (asan, old analyzer)-0 Infra: job SIGKILLed (exit 137) No
IntegrationTestsAnalyzerAsan / Integration tests (asan, old analyzer)-4 Infra: job SIGKILLed (exit 137) No
Grype Scan …/clickhouse-keeper (+ GrypeScan (keeper)) Pre-existing image CVEs No
DCO Pre-existing: backport commits have no Signed-off-by No (process)

The workflow run 44384219738 is still in progress (GrypeScan (server, -alpine) is pending), so this can still change.


1. Integration tests (asan, old analyzer), shards 0 and 4: infra, safe to re-run

No test failed for good in either shard. Every test that failed on its first attempt passed when the runner retried it, and then the runner process itself was killed.

Shard 0 (job):

21:11:24 Tests with FAILED state (2): {'test_parallel_replicas_over_distributed/...[test_multiple_shards_multiple_replicas-4-1]', 'test_keeper_reconfig_remove_many/test.py::test_reconfig_remove_2_and_leader'}
21:12:20 Tests with PASSED state (2): {<the same two tests>}
...
21:13:51 [gw6] [ 31%] PASSED test_recompression_ttl/test.py::test_recompression_multiple_ttls
21:15:40 Killed
21:15:40 Run action failed for: [Integration tests (asan, old analyzer)] with exit code [137]

Shard 4 (job):

21:10:42 Tests with FAILED state (4): {'test_https_replication/test.py::test_replication_after_partition', ... test_both_https, test_both_http, test_mixed_protocol}
21:12:22 Tests with PASSED state (4): {<the same four tests>}
...
21:33:15 Killed
21:34:00 Run action failed for: [Integration tests (asan, old analyzer)] with exit code [137]
21:39:05 ... Killed   pip install clickhouse-driver==0.2.8 numpy==1.26.4 pandas==2.0.3 jinja2==3.1.5

Next step: re-run the two failed jobs.

2. Grype Scan altinityinfra/clickhouse-keeper: pre-existing

Grype Scan Completed with 8 high/critical vulnerabilities. The already-merged #2857 on the same base reports exactly the same result for the keeper image (8 high/critical), and also for the -alpine server image. These CVEs come from the image and its dependencies. A one-function change in MergeTask.cpp can't add or remove them. They need fixing on the base branch's image, not in this PR.

3. DCO: pre-existing process issue

None of the 3 commits (486cbecb58 upstream merge, 168d5b0f99 conflict resolution, 5b9f7f98a4 base merge) has a Signed-off-by trailer. DCO also fails on #2884, #2858 and the merged #2857, so on this branch it doesn't block merging in practice. If you want it green, the commits would need a sign-off. That means rewriting history and force-pushing, which I'm not allowed to do, so it's up to you.


Summary: nothing here points at the backported fix. Re-run the two killed integration-test shards. Grype and DCO match the rest of the releases/25.3.14 backports.

@zvonand zvonand added the verified Approved for release label Nov 19, 2026
@zvonand
zvonand merged commit 970489a into releases/25.3.14 Nov 19, 2026
258 of 264 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants