Repository navigation
Check the TABLE ENGINE grant before ATTACH ... AS [NOT] REPLICATED converts a table - #128995
Conversation
…PLICATED` A user with only `CREATE TABLE` runs `ATTACH TABLE ... AS REPLICATED` and `ATTACH TABLE ... AS NOT REPLICATED` on detached tables. Each query is refused for the missing `TABLE ENGINE` grant on the engine the table would be converted to, and a later plain `ATTACH TABLE` must load every table with the engine it had before. With the grant on the converted engine, the conversion succeeds in both directions and keeps the data. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…CATED` changes anything A short `ATTACH` carries no engine, so `getRequiredAccess` requires only `CREATE TABLE`. The `TABLE ENGINE` grant on the converted engine was checked only after `convertMergeTreeTableIfPossible` had rewritten the stored metadata of the detached table and, for `AS REPLICATED`, removed the transaction metadata files of its parts. A refused query still changed the engine that a later plain `ATTACH TABLE` used. Check that the converted engine exists and that the grant on it is held before any of these changes. The converted name comes from the new `DatabaseOrdinary::getConvertedMergeTreeEngineName`, which `setMergeTreeEngine` uses as well, so the checked name and the stored one are the same. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Workflow [PR], commit [72e6937] Summary: ✅
AI ReviewSummary
Missing context / blind spots
Final VerdictStatus: ✅ Approve. |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units38 translation units recompiled, 329 s compile time in total, 38 of them have a recent master baseline. |
…the conversion precondition A grant such as `TABLE ENGINE ON *` covers an engine name that is not registered, so the registered-engine check before the `TABLE ENGINE` check is what keeps a conversion from writing a definition that cannot be attached; say so in the comment. `DatabaseOrdinary::getConvertedMergeTreeEngineName` now asserts that the name it strips starts with `Replicated`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The parallel-INSERT section compared the entries of the newest manifest list (by file mtime) with the APPEND rows of system.iceberg_history. The insert streams commit their snapshots about 1 ms apart, so the current manifest list and its parent can share one coarse-clock mtime; `sort -n` then orders the tie by the path, which carries the random snapshot id, and `tail -1` can return the parent's list (one entry fewer), printing `0 1 1` instead of `1 1 1`. CI query_log of both failures (ClickHouse#125897, ClickHouse#128995) shows the test reading the parent snapshot's list. Find the list the way a reader does: the newest v<N>.metadata.json, the snapshot whose snapshot-id is current-snapshot-id, its manifest-list. Forcing every manifest list to one mtime, the old helper picked a wrong list in 23/40 trials and the new one in 0/40. 05496 and 05229 use the same mtime heuristic but write each snapshot from a separate client call, so they are not changed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Backport #128995 to 26.10: Check the `TABLE ENGINE` grant before `ATTACH ... AS [NOT] REPLICATED` converts a table
…efore `ATTACH ... AS [NOT] REPLICATED` converts a table
…ACH ... AS [NOT] REPLICATED` converts a table
Keep the release branch side and apply only the fix of #128995: check the `TABLE ENGINE` grant on the converted engine in `convertMergeTreeTableIfPossible` before the side effects of `ATTACH ... AS [NOT] REPLICATED`. The master-only code next to the fix is not carried over: `isTableReadonlyAsReplicated` (#119224) and the `temporary_uuid` / `ordinary_znode_info` handling of `Ordinary` databases, none of which exist on 26.9, where the conversion supports `Atomic` only. Because of that the test is tagged `no-ordinary-database`, as `03169_attach_as_replicated`.
Cherry pick #128995 to 26.8: Check the `TABLE ENGINE` grant before `ATTACH ... AS [NOT] REPLICATED` converts a table
…CH ... AS [NOT] REPLICATED` converts a table
Cherry pick #128995 to 26.9: Check the `TABLE ENGINE` grant before `ATTACH ... AS [NOT] REPLICATED` converts a table
Keep the release branch side and apply only the fix of #128995: check the `TABLE ENGINE` grant on the converted engine in `convertMergeTreeTableIfPossible` before the side effects of `ATTACH ... AS [NOT] REPLICATED`. The master-only code next to the fix is not carried over: `isTableReadonlyAsReplicated` (#119224) and the `temporary_uuid` / `ordinary_znode_info` handling of `Ordinary` databases, none of which exist on 26.8, where the conversion supports `Atomic` only. Because of that the test is tagged `no-ordinary-database`, as `03169_attach_as_replicated`.
…CH ... AS [NOT] REPLICATED` converts a table
Keep the release branch side and apply only the fix of #128995: check the `TABLE ENGINE` grant on the converted engine in `convertMergeTreeTableIfPossible` before the side effects of `ATTACH ... AS [NOT] REPLICATED`. The master-only code next to the fix is not carried over: `isTableReadonlyAsReplicated` (#119224) and the `temporary_uuid` / `ordinary_znode_info` handling of `Ordinary` databases, none of which exist on 26.3, where the conversion supports `Atomic` only. Because of that the test is tagged `no-ordinary-database`, as `03169_attach_as_replicated`.
Cherry pick #128995 to 26.3: Check the `TABLE ENGINE` grant before `ATTACH ... AS [NOT] REPLICATED` converts a table
…CH ... AS [NOT] REPLICATED` converts a table
Backport #128995 to 26.9: Check the `TABLE ENGINE` grant before `ATTACH ... AS [NOT] REPLICATED` converts a table
Backport #128995 to 26.8: Check the `TABLE ENGINE` grant before `ATTACH ... AS [NOT] REPLICATED` converts a table
Backport #128995 to 26.3: Check the `TABLE ENGINE` grant before `ATTACH ... AS [NOT] REPLICATED` converts a table
A short
ATTACH TABLE ... AS [NOT] REPLICATEDcarries no engine, so onlyCREATE TABLEwas required up front. TheTABLE ENGINEgrant on the converted engine was checked only afterconvertMergeTreeTableIfPossiblehad rewritten the stored definition of the detached table and, forAS REPLICATED, removed the transaction metadata files of its parts. A query refused for that grant therefore still changed the engine that a later plainATTACH TABLEloaded.Check that the converted engine exists and that the
TABLE ENGINEgrant on it is held before any of these changes. The converted name comes from the newDatabaseOrdinary::getConvertedMergeTreeEngineName, whichsetMergeTreeEngineuses as well, so the checked name and the stored one cannot diverge.The first commit adds the test, the second contains the fix.
🤖 Generated with Claude Code
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
ATTACH TABLE ... AS REPLICATEDandATTACH TABLE ... AS NOT REPLICATEDnow check theTABLE ENGINEgrant on the engine the table is converted to before changing anything. Previously a query refused for this grant had already rewritten the stored definition of the detached table, so a laterATTACH TABLEloaded it with the new engine.Workflow [PR]
Sync PR [sync-upstream/pr/128995]
Version info
26.11.1.1861-master(included in26.11and later)26.9.32.10,26.8.40.10,26.3.67.18