Skip to content

Stable 26.3 Backport of #99628 - Fix TOCTOU race in vertical merge cancellation - #2813

Merged
zvonand merged 2 commits into
stable-26.3from
backports/stable-26.3/99628
Nov 10, 2026
Merged

zvonand merged 2 commits into
stable-26.3from
backports/stable-26.3/99628

Conversation

@zvonand

@zvonand zvonand commented Nov 9, 2026

Copy link
Copy Markdown
Member

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:08
Fix TOCTOU race in vertical merge cancellation

Conflicts committed as-is; the next commit resolves them:
- src/Storages/MergeTree/MergeTask.cpp (both modified)
Applied the final cancellation-latching form of the fix directly, since stable-26.3 lacked the earlier partial fix; also fixed the misplaced `{` at line 1278.
@zvonand

zvonand commented Nov 9, 2026

Copy link
Copy Markdown
Member Author

Port-AL: cherry-pick conflicts resolved by AI

Conflicted files:

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

Commits:

  • a36ad3c: cherry-pick with the conflicts committed as-is

  • f6a1d26: resolution

  • src/Storages/MergeTree/MergeTask.cpp conflicted because stable-26.3 lacked an earlier partial fix that the source PR builds on.

  • I applied the PR's final logic directly: the cancellation is latched into the per-task is_cancelled flag, so finalize reliably throws.

  • The latching is in both executeImpl and executeVerticalMergeForOneColumn.

  • The reviewer's finding is addressed: the if (...) { line at 1278 is now split so the { is on its own line.

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown

Workflow [PR], commit [f6a1d26]

@zvonand

zvonand commented Nov 10, 2026

Copy link
Copy Markdown
Member Author

@blau-ai

@blau-ai

blau-ai commented Nov 10, 2026

Copy link
Copy Markdown
Collaborator

CI triage for f6a1d26a28: 4 failing checks, none caused by this PR

Check Verdict
Stateless tests (amd_debug, sequential) Pre-existing / infra (network to public S3)
Stateless tests (amd_debug, distributed plan, s3 storage, sequential) Same test, same cause
AST fuzzer (amd_debug) Not PR-related: known analyzer/planner LOGICAL_ERROR
DCO Expected on backports (unsigned upstream commit)

The PR changes only src/Storages/MergeTree/MergeTask.cpp and adds 04041_vertical_merge_stop_start_race. No failure goes through vertical merges. Every other stateless suite that ran is green: amd_debug parallel, ubsan, asan 1-4/4, and distributed plan s3 parallel.


1 & 2. Stateless tests: 03271_s3_table_function_asterisk_glob (both amd_debug sequential suites)

Error on processing query: Timeout exceeded while receiving data from server. Waited for 300 seconds, timeout is 300 seconds.
(query: SELECT * FROM s3('https://clickhouse-public-datasets.s3.amazonaws.com/wikistat/original/*', NOSIGN) LIMIT 1 FORMAT Null;)
  • Classification: infra / pre-existing. The test lists a large public internet bucket (-- Tag no-fasttest: Depends on AWS), and the query hung for 300 s on the S3 listing.
  • Evidence: the same test fails in the same two suites on the unrelated sibling backport Stable 26.3 Backport of #102156 - Fix Nullable(X)->Y cross-type ALTER MODIFY COLUMN #2711 (f436b1bc), whose report lists 03271_s3_table_function_asterisk_glob as FAIL in both amd_debug, sequential and amd_debug, distributed plan, s3 storage, sequential. The result is the same no matter what the PR changes.
  • Next step: none for this PR. It's safe to re-run or ignore. A separate fix would be to skip or mark this test broken on Altinity runners that have slow or limited egress to clickhouse-public-datasets.

3. AST fuzzer (amd_debug): server abort

gdb backtrace in job.log:

Thread 767 "TCPHandler" received signal SIGABRT
#6  DB::handle_error_code (... code=49 ...)            # LOGICAL_ERROR
#11 DB::GlobalPlannerContext::createColumnIdentifier   src/Planner/PlannerContext.cpp:39
#12 prepareBuildQueryPlanForTableExpression            src/Planner/PlannerJoinTree.cpp:485
#13 DB::buildJoinTreeQueryPlan

PlannerContext.cpp:39 throws Column identifier {} is already registered.

4. DCO


Bottom line: nothing in this CI run points to a problem in the backported MergeTask.cpp change. Most sanitizer suites (tsan/msan/arm) were excluded through the CI/CD options in the PR body, so this run gives no tsan coverage of this race fix. If you want that coverage before merging, enable the tsan stateless suites.

Evidence: result_pr.json for this SHA and for #2711, AST fuzzer job.log (gdb section), and gh pr checks on #2696/#2711. No local build or test re-run was needed.

@zvonand
zvonand merged commit e441a98 into stable-26.3 Nov 10, 2026
273 of 281 checks passed
@zvonand zvonand added the verified Approved for release label Nov 10, 2026
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.

4 participants