Skip to content

Cancel background merges early in DROP DATABASE for ordinary shared merge tree#98161

Merged
alexey-milovidov merged 2 commits intoClickHouse:masterfrom
tiandiwonder:cancel_merge_when_drop
Feb 27, 2026
Merged

Cancel background merges early in DROP DATABASE for ordinary shared merge tree#98161
alexey-milovidov merged 2 commits intoClickHouse:masterfrom
tiandiwonder:cancel_merge_when_drop

Conversation

@tiandiwonder
Copy link
Copy Markdown
Contributor

@tiandiwonder tiandiwonder commented Feb 27, 2026

In InterpreterDropQuery::executeToDatabaseImpl(), currently flushAndPrepareForShutdown() is not override, so we depends StorageMergeTree::shutdown() to cancel background merges in executeToTableImpl() in sequence

So we override StorageMergeTree::flushAndPrepareForShutdown() to cancel background merges early in prepare stage in parallel.

            /// List the tables, then call flushAndPrepareForShutdown() on them in parallel, then call
            /// executeToTableImpl on them in sequence.

Note: we already override StorageReplicatedMergeTree::flushAndPrepareForShutdown() for replicated merge tree.

Changelog category (leave one):

  • Improvement

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

Cancel background merges early in DROP DATABASE for ordinary shared merge tree.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

@clickhouse-gh
Copy link
Copy Markdown
Contributor

clickhouse-gh bot commented Feb 27, 2026

Workflow [PR], commit [12d7923]

Summary:

@clickhouse-gh clickhouse-gh bot added the pr-improvement Pull request with some product improvements label Feb 27, 2026
@tiandiwonder tiandiwonder changed the title Speed up DROP DATABASE by cancelling background merge for ordinary shared merge tree Cancel background merges early in DROP DATABASE for ordinary shared merge tree Feb 27, 2026
@alexey-milovidov alexey-milovidov added this pull request to the merge queue Feb 27, 2026
Merged via the queue into ClickHouse:master with commit 78a7f5f Feb 27, 2026
291 of 292 checks passed
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Feb 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-improvement Pull request with some product improvements 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.

4 participants