Skip to content

Fix MATERIALIZE INDEX/PROJECTION mutation stuck after DROP#98369

Merged
alexey-milovidov merged 2 commits intomasterfrom
fix-materialize-index-race-with-drop
Mar 1, 2026
Merged

Fix MATERIALIZE INDEX/PROJECTION mutation stuck after DROP#98369
alexey-milovidov merged 2 commits intomasterfrom
fix-materialize-index-race-with-drop

Conversation

@alexey-milovidov
Copy link
Copy Markdown
Member

Summary

  • Fix MATERIALIZE INDEX and MATERIALIZE PROJECTION mutations getting stuck with "Unknown index" / "No such projection" exceptions when the index or projection is dropped before the mutation finishes executing
  • This can happen in replicated environments or after KILL MUTATION followed by DROP INDEX/DROP PROJECTION
  • The fix makes MutationsInterpreter::prepare gracefully skip materialization when the target no longer exists, instead of throwing

Closes #38643

Changelog category:

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

Changelog entry:

Fix MATERIALIZE INDEX and MATERIALIZE PROJECTION mutations getting stuck when the index or projection is dropped before the mutation finishes.

🤖 Generated with Claude Code

…n is dropped

`MATERIALIZE INDEX` and `MATERIALIZE PROJECTION` mutations could get stuck
with "Unknown index" or "No such projection" exceptions if the index or
projection was dropped before the mutation finished executing. This can
happen in replicated environments or after `KILL MUTATION` followed by
`DROP INDEX`/`DROP PROJECTION`.

The fix makes `MutationsInterpreter::prepare` gracefully skip
materialization when the target index or projection no longer exists in
the metadata, instead of throwing an exception.

Closes #38643

### Changelog category:
- Bug Fix (user-visible misbehavior in an official stable release)

### Changelog entry:
Fix `MATERIALIZE INDEX` and `MATERIALIZE PROJECTION` mutations getting stuck when the index or projection is dropped before the mutation finishes.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@clickhouse-gh
Copy link
Copy Markdown
Contributor

clickhouse-gh bot commented Mar 1, 2026

Workflow [PR], commit [6c1cb40]

Summary:

@clickhouse-gh clickhouse-gh bot added the pr-bugfix Pull request with bugfix, not backported by default label Mar 1, 2026
Copy link
Copy Markdown
Member Author

@alexey-milovidov alexey-milovidov left a comment

Choose a reason for hiding this comment

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

This looks alright.

@alexey-milovidov alexey-milovidov self-assigned this Mar 1, 2026
@alexey-milovidov alexey-milovidov added this pull request to the merge queue Mar 1, 2026
Merged via the queue into master with commit e72ef2d Mar 1, 2026
148 checks passed
@alexey-milovidov alexey-milovidov deleted the fix-materialize-index-race-with-drop branch March 1, 2026 23:58
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-synced-to-cloud The PR is synced to the cloud repo label Mar 2, 2026
@clickgapai
Copy link
Copy Markdown
Contributor

Hi — this PR may need backporting to release branches 26.3, 26.2, 26.1, 25.12, 25.11, 25.10, 25.9, 25.8, but no backport label was found.

Why: This fixes stuck mutations (issue #38643 from 2022) in MutationsInterpreter, which is core MergeTree code present in all stable branches. The bug affects both replicated and non-replicated tables and can block mutation progress indefinitely.

If this should be backported, consider adding pr-must-backport or a version-specific label (e.g. v26.3-must-backport). Ignore this if backporting is not applicable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-bugfix Pull request with bugfix, not backported by default 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.

MATERIALIZE INDEX may stuck due to race with DROP INDEX

3 participants