Skip to content

Fix DROP DATABASE hung check caused by ignore_drop_queries_probability - #98333

Merged
alexey-milovidov merged 1 commit into
masterfrom
fix-drop-database-hung-check
Feb 28, 2026
Merged

alexey-milovidov merged 1 commit into
masterfrom
fix-drop-database-hung-check

Conversation

@alexey-milovidov

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

Copy link
Copy Markdown
Member

Summary

  • The ignore_drop_queries_probability handler in executeToTableImpl modifies query_for_table.sync and query_for_table.kind via non-const reference. Since query_for_table is shared across loop iterations in executeToDatabaseImpl, these modifications persist: after one table triggers the probability check, all subsequent tables get sync=false and potentially kind=Truncate instead of Drop.
  • This causes tables to be truncated instead of dropped, detachDatabase to fail with DATABASE_NOT_EMPTY, and the query to hang forever in waitTableFinallyDropped.
  • Fix: save original kind/sync before the loop and restore them at the beginning of each iteration.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=98251&sha=d83ec181cd967fac3fe0d13985b408c549b20d68&name_0=PR&name_1=Stress%20test%20%28amd_tsan%29
#98251

Test plan

  • Verified fix compiles
  • CI stress test should no longer show hung check failures from DROP DATABASE stuck in waitTableFinallyDropped

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

Version info

  • Merged into: 26.3.1.167

…e loop

The `ignore_drop_queries_probability` handler in `executeToTableImpl` modifies
`ast_drop_query.sync` and `ast_drop_query.kind` via non-const reference. Since
`query_for_table` is passed by reference from the loop in `executeToDatabaseImpl`,
these modifications persist across iterations: after one table triggers the
probability check, all subsequent tables get `sync=false` and potentially
`kind=Truncate` instead of `Drop`.

This causes:
1. Tables to be truncated instead of dropped, leaving them in the database
2. `detachDatabase` to fail with `DATABASE_NOT_EMPTY` since tables remain
3. The database gets re-attached, but the query waits forever in
   `waitTableFinallyDropped` for already-dropped tables whose data cannot
   be cleaned up

Fix: save the original `kind` and `sync` values before the loop and restore
them at the beginning of each iteration.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=98251&sha=d83ec181cd967fac3fe0d13985b408c549b20d68&name_0=PR&name_1=Stress%20test%20%28amd_tsan%29

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

clickhouse-gh Bot commented Feb 28, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [a52facf]

Summary: ✅

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The fix is good.

@alexey-milovidov alexey-milovidov self-assigned this Feb 28, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Feb 28, 2026
Merged via the queue into master with commit 944b624 Feb 28, 2026
287 of 288 checks passed
@alexey-milovidov
alexey-milovidov deleted the fix-drop-database-hung-check branch February 28, 2026 22:35
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Feb 28, 2026
alexey-milovidov added a commit that referenced this pull request Mar 1, 2026
Fix DROP DATABASE hung check caused by ignore_drop_queries_probability
@clickgapai

Copy link
Copy Markdown
Contributor

Hi @alexey-milovidov — the changelog category for this PR might need a look.

Current: CI Fix or Improvement (changelog entry is not required)
Suggested: Bug Fix (user-visible misbehavior in an official stable release)

Why: The code fixes a bug where DROP DATABASE could hang due to ignore_drop_queries_probability modifying query parameters (sync/kind) that should remain constant across multiple table drops. This is a user-visible bug fix, not a CI-only issue.

Could you verify this is correct? Ignore if the current category is intentional.

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

Labels

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.

3 participants