Skip to content

Add test: max_execution_time arm of the new throw_if_cancelled check in DatabaseCatalog::undropTable is untested - #114095

Closed
clickgapai wants to merge 2 commits into
ClickHouse:masterfrom
clickgapai:qa-bot/coverage-pr113263
Closed

clickgapai wants to merge 2 commits into
ClickHouse:masterfrom
clickgapai:qa-bot/coverage-pr113263

Conversation

@clickgapai

@clickgapai clickgapai commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

Found via ClickGap automated review. Please close or comment if this is incorrect or needs adjustment.

This is a test-only PR — no source code changes. Please review: test quality, whether the claimed coverage gaps are real, and whether test output makes sense.

Adds test coverage for 1 untested code path, found during automated review of PR #113263.
That PR (1) The PR threads a throw_if_cancelled callback into DatabaseCatalog::undropTable and calls it inside the busy-wait that waits for the dropped table's StoragePtr to become unique; InterpreterUndropQuery::executeToTable builds the callback from Context::getProcessListElementSafe + `QuerySt

1. max_execution_time arm of the new throw_if_cancelled check in DatabaseCatalog::undropTable is untested
src/Interpreters/DatabaseCatalog.cpp:1531, src/Interpreters/InterpreterUndropQuery.cpp:82
Risk: The PR adds if (throw_if_cancelled) throw_if_cancelled(); to the busy-wait in DatabaseCatalog::undropTable; the callback is QueryStatus::throwIfKilled -> QueryStatus::throwProperExceptionIfNeeded, which has two arms: cancel_reason == CancelReason::TIMEOUT -> TIMEOUT_EXCEEDED and everything else -> QUERY_WAS_CANCELLED. The PR's own test only reaches the second arm via KILL QUERY. The first arm is reached from a different initiator (the background CancellationChecker thread, …
What's unique vs PR tests: 04726_kill_undrop_table_busy_wait.sh cancels the wait with an explicit KILL QUERY and asserts QUERY_WAS_CANCELLED. This test cancels the same wait through the query time limit: the cancellation is initiated by the background CancellationChecker rather than by a user query, and it asserts the other arm of throwProperExceptionIfNeeded (TIMEOUT_EXCEEDED). A change that honours only KILL QUERY passes the PR's test and fails this one.

Changelog category (leave one):

  • Not for changelog (changelog entry is not required)

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

Not applicable — test-only change.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

@clickgapai

Copy link
Copy Markdown
Contributor Author

Pre-PR Validation Gate (per ClickGap pipeline):

a) Deterministic repro? ✅
Test exercises the previously-uncovered branch and passes (correct behaviour).

b) Root cause explained? ✅
src/Interpreters/DatabaseCatalog.cpp:1531 — if (throw_if_cancelled) throw_if_cancelled(); inside while (!isSharedPtrUnique(dropped_table.table)); the timeout-initiated cancellation arm (src/Interpreters/ProcessList.cpp:633, cancel_reason == CancelReason::TIMEOUT) is never reached from this call site by any test.

c) Fix matches root cause? ✅
N/A for coverage gap — this PR adds a regression test, not a fix. Asserts current correct behaviour at the cited line.

d) Test intent preserved? / New tests added? ✅
New regression test added: 04837_undrop_table_busy_wait_timeout.sh.

e) Both directions demonstrated? ✅
Test passes (MATCH) on master proving current correctness; would fail if the cited branch regressed. Single-direction is the correct shape for a coverage gap test.

f) Fix is general, not a narrow patch? ✅
Test asserts the invariant at the cited line — covers the branch, not a specific input shape.

@zlareb1 zlareb1 added the can be tested Allows running workflows for external contributors label Aug 10, 2026
@clickhouse-gh

clickhouse-gh Bot commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [0d983a9]

Summary: ❌

job_name test_name status info comment
Stateless tests (arm_binary, parallel) FAIL
04357_distributed_alias_same_expression FAIL cidb
Stress test (arm_release) FAIL
Hung check failed, possible deadlock found FAIL cidb
Stress test (amd_tsan) ERROR

AI Review

Summary

This PR adds a stateless regression test for the TIMEOUT_EXCEEDED arm of InterpreterUndropQuery's throw_if_cancelled callback while DatabaseCatalog::undropTable is busy-waiting for the dropped table's StoragePtr to become unique. The current head also fixes the two earlier review concerns: the holder query is now gated on actual table reads before DROP, and the cleanup path handles the detached-metadata state after a timed-out UNDROP. I did not find a remaining correctness, coverage, or flakiness issue in the test as merged.

Final Verdict
  • Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Aug 10, 2026
@CLAassistant

CLAassistant commented Aug 10, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

system.processes visibility alone is too weak: executeQueryImpl inserts
the query into the process list before it resolves the table, so the DROP
could win the race and the SELECT would never hold the storage. Wait for
read_rows > 0 and elapsed > 1 instead.
@clickgapai
clickgapai force-pushed the qa-bot/coverage-pr113263 branch from 3c8d3f4 to 0d983a9 Compare August 10, 2026 19:05
@clickgapai

Copy link
Copy Markdown
Contributor Author

CI failure in Stress test (amd_tsan) appears to be unrelated breakage and is not related to this change. Let me know if you'd like me to merge master and retrigger CI.

@PedroTadim

Copy link
Copy Markdown
Member

This is going to be flaky, the stress tests already test this

@PedroTadim PedroTadim closed this Aug 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors pr-not-for-changelog This PR should not be mentioned in the changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants