Skip to content

Fix inner table drop hang - #114302

Closed
vitlibar wants to merge 2 commits into
ClickHouse:masterfrom
vitlibar:fix-inner-table-drop-hang
Closed

vitlibar wants to merge 2 commits into
ClickHouse:masterfrom
vitlibar:fix-inner-table-drop-hang

Conversation

@vitlibar

@vitlibar vitlibar commented Aug 11, 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 into CHANGELOG.md):

Fix inner table drop hang

Fixed DROP TABLE ... SYNC of a materialized view (and other tables with inner tables, like TimeSeries and window views) hanging unkillably and blocking all DDL on the same table name while another query holds a reference to an inner table: the wait for the inner tables is now interruptible by KILL QUERY and no longer holds the DDL guard.

@clickhouse-gh

clickhouse-gh Bot commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [ad77581]


AI Review

Summary

This PR makes DROP TABLE ... SYNC for tables with inner tables killable and moves the synchronous inner-table wait out from under the parent table's DDL guard, which avoids the deadlock between a waiting DROP and another query that still holds an inner-table reference. I did not find a remaining correctness, concurrency, or test-coverage issue in the current diff, and the added stateless tests cover both the killability regression and the DDL-guard deadlock scenario.

Final Verdict

✅ No new blocking issues found.

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Aug 11, 2026
The inner-table drop context is a copy of the global context and had no
process list element, so KILL QUERY could not interrupt the synchronous
wait for the inner table of a materialized view (or window view, or
TimeSeries table) to be finally dropped while another query still held
a reference to it.
…guard

The synchronous wait for the inner tables of a materialized view (or a
window view, a TimeSeries table, a MaterializedPostgreSQL table) to be
finally dropped used to run under the DDL guard of the table's name. A
query holding references to the inner tables and blocking on that DDL
guard would deadlock with the waiting DROP. Now the inner drops do not
wait (a new skip_sync_wait flag of executeDropQuery), their ids are
collected via a new virtual IStorage::getInnerTableIds, and the DROP
waits for them after the DDL guard is released.
@vitlibar
vitlibar force-pushed the fix-inner-table-drop-hang branch from 238948a to ad77581 Compare August 11, 2026 13:11
@vitlibar
vitlibar marked this pull request as ready for review August 11, 2026 13:41
@alexey-milovidov alexey-milovidov added the blocker This issue / pr blocks a new release label Aug 11, 2026
@azat

azat commented Aug 11, 2026 •

Copy link
Copy Markdown
Member

Interesting, are you sure that it will help with stress hungs? https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=114143&sha=c57b5d86a48a852c094213e4b284beb727cf1aa1&name_0=PR&name_1=Stress%20test%20%28amd_tsan%29

AFAICS it will simply allow to cancel the DROP and do not wait for it, but the table will still be in the dropping queue

And AFAIU the fix for this is #113397

Am I missing something?

@vitlibar

Copy link
Copy Markdown
Member Author

And AFAIU the fix for this is #113397

Yes, #113397 is better

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants