Skip to content

Revert "Revert "Cancel vector similarity index builds when a merge or mutation is cancelled"" - #123739

Merged
Algunenano merged 3 commits into
masterfrom
revert-123588-revert-123062-cancel-merge-vector-index-on-drop
Oct 6, 2026
Merged

Algunenano merged 3 commits into
masterfrom
revert-123588-revert-123062-cancel-merge-vector-index-on-drop

Conversation

@Algunenano

@Algunenano Algunenano commented Oct 3, 2026 •

Copy link
Copy Markdown
Member

Reverts #123588


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

Version info

  • Merged into: 26.10.1.1683-master (included in 26.10 and later)

@Algunenano Algunenano self-assigned this Oct 3, 2026
@clickhouse-gh

clickhouse-gh Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [66ab027]

Summary: ✅


AI Review

Summary

This PR re-enables cancellation of long-running vector_similarity index builds during merges and mutations, then adds a follow-up guard so the new throwing cancellation predicate cannot interrupt transaction finalization. The core code changes look directionally right, but I still cannot approve the PR because the regression evidence is incomplete: the new merge test can pass without ever proving that a running build was cancelled, and the mutation-side hook added in MutateTask still has no focused reproducer.

Findings
  • ⚠️ Majors
    • [tests/queries/0_stateless/05294_drop_table_cancels_vector_index_merge.sh:33-41] [dismissed by author -- https://github.com/Revert "Revert "Cancel vector similarity index builds when a merge or mutation is cancelled"" #123739#discussion_r4174389286] The PR promises that DROP TABLE SYNC interrupts an in-flight vector_similarity merge, but this test still passes when no cancellation ever happens: the polling loop can time out silently, wait $optimize_pid does not fail the .sh test on its own, and elapsed < 30 is also true when OPTIMIZE TABLE ... FINAL simply finished before DROP TABLE. That leaves the main contract unproven while CI stays green.
      Suggested fix: make the poll timeout fail explicitly, assert that system.merges observed the target merge in progress, and assert that the background OPTIMIZE ends with the expected cancellation exception after DROP TABLE SYNC.
    • [src/Storages/MergeTree/MutateTask.cpp:3898-3912] [dismissed by author -- https://github.com/Revert "Revert "Cancel vector similarity index builds when a merge or mutation is cancelled"" #123739#discussion_r4174389293] The PR restores mutation-side cancellation by wiring the same predicate into the mutation thread group, but there is still no regression test that rebuilds a vector_similarity index through a mutation entrypoint and then cancels it. A future refactor can break KILL MUTATION / MATERIALIZE INDEX cancellation while all CI remains green because the only new test exercises the merge path.
      Suggested fix: add a small stateless reproducer that forces a vector_similarity rebuild via MATERIALIZE INDEX or another mutation path and then cancels it, asserting that the mutation aborts promptly.
Final Verdict
  • Status: ⚠️ Request changes
  • Minimum required actions:
    • Make tests/queries/0_stateless/05294_drop_table_cancels_vector_index_merge.sh prove it observed and cancelled a live merge, rather than accepting a fast successful OPTIMIZE.
    • Add mutation-path regression coverage for the new MutateTask cancellation hook.

LLVM Coverage Report

Measured on commit 66ab027.

Metric Baseline Current Δ
Lines 88.30% 88.20% -0.10%
Functions 92.10% 92.10% +0.00%
Branches 79.70% 79.70% +0.00%

Changed lines: Changed C/C++ lines covered: 87/88 (98.86%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Oct 3, 2026
Comment thread src/Storages/MergeTree/MutateTask.cpp Resolved
@clickhouse-gh clickhouse-gh Bot added the comp-vector-index Vector similarity index in MergeTree: ANN/HNSW index build/query, usearch integration, vector ind... label Oct 3, 2026
@clickhouse-gh

clickhouse-gh Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 66ab027fa with master b5d7e18bb (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Compile time of recompiled translation units

123 translation units recompiled, 799 s compile time in total, 123 of them have a recent master baseline.

Job report

@Algunenano
Algunenano marked this pull request as ready for review October 5, 2026 13:16
Algunenano and others added 2 commits October 5, 2026 16:54
`afterCommit` and `rollback` are `noexcept`. With the merge thread group now having a throwing cancellation predicate, a cancelled merge could throw `ABORTED` from a read in `afterCommit` and terminate the server. Block cancellation checks in the transaction finalization and rollback paths.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Algunenano

Copy link
Copy Markdown
Member Author

Fix included in 66ab027. It could only happen in private due to some operations we do there in certain scenarios. As you can see we were already blocking other sources of exceptions in the code to prevent this very issue

@Algunenano
Algunenano added this pull request to the merge queue Oct 6, 2026
Merged via the queue into master with commit 50da1b5 Oct 6, 2026
149 checks passed
@Algunenano
Algunenano deleted the revert-123588-revert-123062-cancel-merge-vector-index-on-drop branch October 6, 2026 15:51
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-vector-index Vector similarity index in MergeTree: ANN/HNSW index build/query, usearch integration, vector ind... 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.

2 participants