Repository navigation
Drop for detached tables - #105499
Drop for detached tables#105499UberDever wants to merge 96 commits into
Conversation
b545c7c to
d418cf8
Compare
|
For my understanding, why is the feature being "revived" (PR title)? |
It is the revival of this closed PR #62490 |
|
Workflow [PR], commit [9e81f53] Summary: ❌
AI ReviewSummaryAdds experimental Missing context / blind spots
Findings❌ Blockers
Tests
Final Verdict❌ Block. Guarantee background-task shutdown on all reconstruction exits, move the lifetime barrier before reconstruction, and preserve the drop-only privilege contract. Add the focused regression coverage above. |
00d41ad to
314d0ff
Compare
1817d25 to
9ad6fd0
Compare
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 565/598 (94.48%) · Uncovered code |
…rop_detached_tables-v2 # Conflicts: # docs/en/sql-reference/statements/detach.md # docs/en/sql-reference/statements/drop.md
…d_tables-v2' into morlovsky/feature/drop_detached_tables-v2
…p_detached_tables-v2
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Object file sizes119 object files changed (+131.86 KiB total), 0 added.
711 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only Slowest function optimization changes (ThinLTO)Median per-function time ratio to the master baseline:
Compile time of recompiled translation units1223 translation units recompiled, 7993 s compile time in total, 1223 of them have a recent master baseline. |
…rop_detached_tables-v2
…rop_detached_tables-v2 Resolve the conflict with the move of the settings changes history into the setting declarations (ee6b44f): the history records this PR added to `SettingsChangesHistory.cpp` now live as trailing arguments of the `DECLARE` of each setting. - dropped PR record [email protected]: no such setting in the merged declarations - retargeted PR record [email protected] to 26.10 (settings-history check rule) Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Resolve include overlaps and retain the updated DatabaseOrdinary::setMergeTreeEngine declaration alongside detached-table support. Related: ClickHouse#105499
Include `detached` in `ASTDropQuery::updateTreeHashImpl` with one assertion in the existing hash test. Move detached-table documentation into `ParserDropQuery::getDocumentation` and remove direct generated-page edits. Related: ClickHouse#105499
Resolve overlapping includes and experimental settings while preserving `DROP DETACHED TABLE`. Remove the deleted `StatementFactory.h` and `registerStatements.h` includes from `ParserDropQuery.cpp`. Related: ClickHouse#105499 CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=105499&sha=8060d5ccee3e7193cda8da0cd1ab6e6a22cc0681&name_0=PR
Preserve per-file startup drop-queue detection together with detached-table UUID recovery. Related: ClickHouse#105499
Record the experimental setting under the current release. Preserve integration startup exceptions and remove unrelated arithmetic and table-name helper changes. CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=105499&sha=c97f269a03c6d5e4e4f7963ec35d6f7bb3a22560&name_0=PR&name_1=Style%20check Related: ClickHouse#105499
Drop inner tables within the replicated metadata transaction after cancellable preparation. Reject existing UUID mappings when recovering dropped metadata. Add replicated `TimeSeries` and UUID collision regressions. Update the cancellation fixture for the current `samples` schema and verify data retention. Validated the build, 16 integration cases, four stateless tests, the tree-hash test, startup recovery, and compiled statement documentation. Related: ClickHouse#105499 CI: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=105499&sha=c97f269a03c6d5e4e4f7963ec35d6f7bb3a22560&name_0=PR&name_1=Style%20check
| auto detached_table | ||
| = createTableFromAST(*detached_create, table_id.getDatabaseName(), data_path, getContext(), LoadingStrictnessLevel::FORCE_RESTORE) | ||
| .second; |
There was a problem hiding this comment.
createTableFromAST runs before prepareDropDetachedTable, so the second storage is constructed before waitDetachedTableNotInUse has released the old one. StorageMergeTree immediately calls initializeDirectoriesAndFormatVersion and loadDataParts in its constructor; this is not a passive metadata object.
A concrete failure is a writable MergeTree with table_disk = true: start a long-running read, DETACH TABLE t PERMANENTLY, then DROP DETACHED TABLE t SYNC. The old instance still owns the disk root, so the new constructor fails in acquireTableDiskRoots with BAD_ARGUMENTS before the intended wait is reached. For other tables the second constructor can already load/repair the same files while the old instance remains in use.
Please reserve the UUID and complete the cancellable wait before constructing the replacement storage, and cover the table_disk case in a focused regression test.
| detached_create->setDatabase(table_id.getDatabaseName()); | ||
| detached_create->setTable(table_name); | ||
| auto detached_table | ||
| = createTableFromAST(*detached_create, table_id.getDatabaseName(), data_path, getContext(), LoadingStrictnessLevel::FORCE_RESTORE) |
There was a problem hiding this comment.
Passing the user's query context into createTableFromAST re-executes table-function access checks for persisted CREATE TABLE ... AS table_function definitions. Its as_table_function branch calls ITableFunction::execute, which checks source READ access and CREATE TEMPORARY TABLE before returning a storage.
For example, have an administrator create t AS file('drop_detached.tsv', 'TSV', 'x UInt64'), grant another user only DROP TABLE ON db.t, and detach t. That user can drop the attached table with the same grant, but DROP DETACHED TABLE db.t now fails with ACCESS_DENIED for READ ON FILE (and then needs CREATE TEMPORARY TABLE as well). The same problem affects persisted s3 and other source table functions.
Please reconstruct trusted stored metadata without imposing source-read/temporary-table grants on the dropping user, while retaining the explicit DROP TABLE check and query-context size/cancellation checks. Add a regression using a user with only the drop grant.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Added experimental
DROP DETACHED TABLEsupport, gated byallow_experimental_drop_detached_table, to remove metadata and data for detached tables.Continues #62490
Workflow [PR]
Sync PR [sync-upstream/pr/105499]