Skip to content

Fix flaky test test_refreshable_mv in DROP DATABASE with Replicated databases - #97138

Merged
alexey-milovidov merged 1 commit into
masterfrom
fix-drop-database-tmp-inner-tables
Feb 17, 2026
Merged

alexey-milovidov merged 1 commit into
masterfrom
fix-drop-database-tmp-inner-tables

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Feb 17, 2026 •

Copy link
Copy Markdown
Member

Summary

PR #97057 introduced table sorting in DROP DATABASE to drop tables in reverse dependency order. It classified .inner_id.* and .inner.* tables as "inner" (to be dropped after their parent MV), but missed .tmp.inner_id.* and .tmp.inner.* tables.

These temporary tables are created by refreshable materialized views during the table-swap phase of a refresh. StorageMaterializedView::dropInnerTableIfAny drops both the main inner table and the temporary one. Without classifying the temporary tables as inner, the sort could place the MV before its temp inner table, causing dropInnerTableIfAny to attempt dropping the temp table via a new InterpreterDropQuery that goes through the replicated DDL path and fails with:

Code: 80. DB::Exception: It's not initial query. ON CLUSTER is not allowed for Replicated database.

The fix adds .tmp.inner_id.* and .tmp.inner.* patterns to the inner table classification in the DROP DATABASE sort comparator.

Fixes #92642

CI report: https://play.clickhouse.com/play?user=play&run=1#U0VMRUNUIGNoZWNrX3N0YXJ0X3RpbWUsIGNoZWNrX25hbWUsIHRlc3RfbmFtZSwgcmVwb3J0X3VybApGUk9NIGNoZWNrcwpXSEVSRSAxCiAgICBBTkQgY2hlY2tfc3RhcnRfdGltZSA+PSBub3coKSAtIElOVEVSVkFMIDI0IEhPVVIKICAgIEFORCAoaGVhZF9yZWYgPSAnbWFzdGVyJyBBTkQgc3RhcnRzV2l0aChoZWFkX3JlcG8sICdDbGlja0hvdXNlLycpKQogICAgQU5EIHRlc3Rfc3RhdHVzICE9ICdTS0lQUEVEJwogICAgQU5EICh0ZXN0X3N0YXR1cyBMSUtFICdGJScgT1IgdGVzdF9zdGF0dXMgTElLRSAnRSUnKQogICAgQU5EIGNoZWNrX3N0YXR1cyAhPSAnc3VjY2VzcycKICAgIEFORCBjaGVja19uYW1lIE5PVCBMSUtFICdsaWJGdXp6ZXIlJwogICAgQU5EIGNoZWNrX25hbWUgIT0gJ0NsaWNrSG91c2UgS2VlcGVyIEplcHNlbicKICAgIEFORCBjaGVja19uYW1lIE5PVCBMSUtFICdJbnRlZ3JhdGlvbiB0ZXN0cyAoYW1kX21zYW4lJwogICAgQU5EIGNoZWNrX25hbWUgTk9UIExJS0UgJ0ludGVncmF0aW9uIHRlc3RzIChhbWRfbGx2bV9jb3ZlcmFnZSUnCk9SREVSIEJZIGNoZWNrX3N0YXJ0X3RpbWUgREVTQw==

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

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

...

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.6 [email protected]

Version info

  • Merged into: 26.2.1.825

…d databases

The sort introduced by #97057 classified `.inner_id.*` and `.inner.*`
tables as inner, but missed `.tmp.inner_id.*` and `.tmp.inner.*` tables.
These temporary tables are created by refreshable materialized views
during the table-swap phase of a refresh. `dropInnerTableIfAny` drops
both the main inner table and the temporary one. Without classifying the
temporary tables as inner, the sort could place the MV before its temp
inner table, causing `dropInnerTableIfAny` to attempt dropping the temp
table via a new `InterpreterDropQuery` that goes through the replicated
DDL path and fails with "It's not initial query. ON CLUSTER is not
allowed for Replicated database."

CI report: https://play.clickhouse.com/play?user=play&run=1#U0VMRUNUIGNoZWNrX3N0YXJ0X3RpbWUsIGNoZWNrX25hbWUsIHRlc3RfbmFtZSwgcmVwb3J0X3VybApGUk9NIGNoZWNrcwpXSEVSRSAxCiAgICBBTkQgY2hlY2tfc3RhcnRfdGltZSA+PSBub3coKSAtIElOVEVSVkFMIDI0IEhPVVIKICAgIEFORCAoaGVhZF9yZWYgPSAnbWFzdGVyJyBBTkQgc3RhcnRzV2l0aChoZWFkX3JlcG8sICdDbGlja0hvdXNlLycpKQogICAgQU5EIHRlc3Rfc3RhdHVzICE9ICdTS0lQUEVEJwogICAgQU5EICh0ZXN0X3N0YXR1cyBMSUtFICdGJScgT1IgdGVzdF9zdGF0dXMgTElLRSAnRSUnKQogICAgQU5EIGNoZWNrX3N0YXR1cyAhPSAnc3VjY2VzcycKICAgIEFORCBjaGVja19uYW1lIE5PVCBMSUtFICdsaWJGdXp6ZXIlJwogICAgQU5EIGNoZWNrX25hbWUgIT0gJ0NsaWNrSG91c2UgS2VlcGVyIEplcHNlbicKICAgIEFORCBjaGVja19uYW1lIE5PVCBMSUtFICdJbnRlZ3JhdGlvbiB0ZXN0cyAoYW1kX21zYW4lJwogICAgQU5EIGNoZWNrX25hbWUgTk9UIExJS0UgJ0ludGVncmF0aW9uIHRlc3RzIChhbWRfbGx2bV9jb3ZlcmFnZSUnCk9SREVSIEJZIGNoZWNrX3N0YXJ0X3RpbWUgREVTQw==

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

clickhouse-gh Bot commented Feb 17, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [3b405f7]

Summary: ✅

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

Labels

post-approved Approved, but after the PR is merged. pr-ci 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.

Flaky test: test_refreshable_mv/test.py::test_refreshable_mv_in_replicated_db

3 participants