Repository navigation
Feature: Enable overlay databases for server. - #86768
AlyHKafoury wants to merge 222 commits into
Conversation
|
Workflow [PR], commit [3c776109] Summary: ✅
AI ReviewSummaryThis PR enables server-side Missing context / blind spots
Final Verdict✅ Approve LLVM Coverage ReportMeasured on commit 3c776109.
Changed lines: Changed C/C++ lines covered: 1552/1720 (90.23%) · Uncovered code |
|
@azat I believe this is ready for initial review, I don't know why the rest of the CI is not running |
|
@alexey-milovidov this test is failing with random error messages that doesn't happen in other runs or locally can you give me any pointers on why this might be failing ? https://github.com/ClickHouse/ClickHouse/actions/runs/17553376388/job/49853979804?pr=86768 |
|
@azat @alexey-milovidov I believe this is ready for review |
|
🕵 Pushed
Verification.
The only CI failure on |
…ource on the create path
Two findings of the 2026-09-21 AI review of the `Overlay` database facade.
The rejection of an explicit `ATTACH DATABASE ... ENGINE = Overlay(...)` layered
over another read-only facade was keyed on `!args.internal`. An internal query is
not necessarily the server's own metadata replay: wrappers such as `PARALLEL WITH`
execute user statements as internal ones, so
`PARALLEL WITH ATTACH DATABASE db_top ENGINE = Overlay('db_mid')` skipped the guard
and persisted a facade whose source `resolveDatabases` has to drop on every lookup.
The guard now keys on the loader's own replay flag, `args.is_metadata_replay`,
exactly as `DatabaseFilesystem` already does; startup replay still must not refuse
a previously-written definition.
`tryGetTableCreationDatabase` failed closed for a source that is currently
unresolved, but still skipped a source that resolves to a nested read-only
`Overlay`. That shape is reachable from metadata written before the checks above
existed, and the documented repair -- re-creating that source as an ordinary
database -- puts the source back into the facade order, so a table created past it
would then be owned by the wrong source, or shadowed by a table of the same name in
the source the create walked past. It is now rejected with `BAD_ARGUMENTS` for the
same reason as an unresolved source, naming only the facade.
Tests: `05236_overlay_database_parallel_with_attach_nested_rejected` for the first
finding, and `test_database_overlay` for the second -- the nested state is only
reachable through a metadata replay, so it needs a server restart.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…ests runnable Measured against a control binary built from the previous head: the explicit `PARALLEL WITH ATTACH DATABASE ... ENGINE = Overlay(...)` form was *already* refused before the previous commit, because `PARALLEL WITH` marks its sub-statements `user_initiated` and `executeQuery` therefore does not pass `internal` on to `InterpreterCreateQuery` (`setInternal(internal && !flags.user_initiated)`, added in `031704da17b3`). Keying the guard on `args.is_metadata_replay` is kept -- it states the intent directly instead of depending on that propagation, exactly as `DatabaseFilesystem` already does -- but the comment no longer claims the form slipped through, and the test now says what it pins. Also: `PARALLEL WITH` refuses a branch that has output, so the single-statement branches of the new test use a `DROP DATABASE IF EXISTS` of an absent database rather than `SELECT 1`, and the integration test is `black`-formatted. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
🕵 Pushed
The regression is The replay-only Verification.
|
|
🕵 On the only CI failure of The query cannot reach this change. It is Both numbers sit inside the query's own noise band. On that exact shard over the last 21 days (2694 runs,
20.6 ms and 23.8 ms are the bottom and the top of a band the query occupies on unmodified A swing this size is ordinary for this query. Across those same 2694 runs, The job was also labelled The branch has since been merged with |
…ame in `system.dictionaries` A dictionary created in a source database of a read-only `Overlay` facade is reachable through the facade name by the point lookups (`SHOW CREATE DICTIONARY`, `EXISTS DICTIONARY`, `SYSTEM RELOAD DICTIONARY`), but `SHOW DICTIONARIES FROM ov` is rewritten to `system.dictionaries WHERE database = 'ov'`, and `StorageSystemDictionaries` emitted rows under the owning source name only, so even a caller granted on both the facade and the source never saw `ov.d` in the listing. The listing now synthesizes a row under the facade name for every read-only facade that resolves the dictionary name to that very source, under the same fail-closed dual-grant rule as the other facade metadata readers: `SHOW DICTIONARIES` must be granted on both the facade name and the source name, the resolution never loads the source object, and a name that an earlier source shadows (with a table or a dictionary of its own) is not advertised through the facade, because through the facade that name denotes the earlier source's object. `DatabaseOverlay::tryGetVisibleSourceDatabaseNameNoLoad` is the resolving form of `isSourceTableVisibleNoLoad` (which now delegates to it): it returns the source database the name resolves to when both grants hold, and an empty string otherwise. Test `05237_overlay_database_show_dictionaries_facade` covers the default user (the shadowed name is listed for its source only and agrees with `EXISTS DICTIONARY` / `SHOW CREATE DICTIONARY` on the facade name), a facade-only grant, a source-only grant, and the dual grant. Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
🕵 Pushed
Verification. CI. Public CI on Merged |
… facade in `dictGet` and `dictionary`
`system.dictionaries` and `SHOW DICTIONARIES FROM ov` list a source dictionary under the facade name, but the
consumers that take the name as a string could not use it: `ExternalDictionariesLoader::resolveDictionaryNameFromDatabaseCatalog`
saw the facade (UUID `Nil`) as the owning database and kept the written string `ov.d`, which the loader does not know
(the dictionary is registered under its source key only), so `dictGet('ov.d', ...)`, `dictionary('ov.d')` and the
current-database form failed with `Dictionary (...) not found`.
The resolver now follows the storage the facade returns to its registered key (`StorageID::getInternalDictionaryName`:
the UUID for an `Atomic` source, `database.name` otherwise). The consumers follow the facade's dual-grant contract through
the new `DatabaseOverlay::checkDictionaryAccessIfFacade`: `dictGet` is required on both the facade name and the source
dictionary, checked fail-closed before the source dictionary is loaded, and the denial names only the facade. It is
called from `FunctionDictHelper::getDictionary`, `TableFunctionDictionary::getActualTableStructure` and
`StorageDictionary::read` for a custom name (the `dictionary` table function and the `Dictionary` table engine).
A name that an earlier source shadows with an object of its own still resolves to that object and stays unresolvable
as a dictionary, consistent with the listing.
Test `05238_overlay_database_dictget_through_facade` covers every consumer for the default user, the shadowed name,
and the facade-only / source-only / both-grants users.
AI review: ClickHouse#86768 (comment)
CI: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=86768&sha=9dec09b69ee1611992e317207a9e454c6c3141c0&name_0=PR
Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
🕵 Status 2026-09-22 (pass on head
|
…lay-databases Conflicts: `QueryAnalyzer.cpp`, `InterpreterSelectQuery.cpp`, `PlannerJoinTree.cpp` — master (ClickHouse#118668) moved the row-policy resolution into the shared `getRowPolicyFilterForStorage` / `getEffectiveRowPolicyFilter` helpers in `Storages/getEffectiveRowPolicyFilter.h`, replacing the per-call-site code where this branch combined the policies of the `Overlay` facade name with the source's. Resolved by adding `as_written_id` overloads of the two shared helpers that combine the other name's policies when the written id resolves through a read-only facade (plain source table: the facade's policies; parameterized view: the carried source view's policies), and by switching the three call sites to them; the branch's local planner copy of `getEffectiveRowPolicyFilter` is dropped in favour of the shared one. `DatabaseOverlay::getSourceTableIdForReadonlyFacade` gained an `IStorage const &` overload for the helper. Co-Authored-By: Claude Fable 5.1 <[email protected]>
commented
Sep 22, 2026
|
Checked both on
That shard obtained no learned per-query thresholds on this run: #121090 keeps a dashboard row only when the shard's own report also published the query as slower. Here it did, so the Both are open and unmerged. I will post here when they land. |
commented
Sep 22, 2026
|
🕵 Follow-up 2026-09-22: the PR had become Conflicts came from #118668, which moved row-policy resolution into the shared Verified locally: incremental |
commented
Sep 22, 2026
|
🕵 Status 2026-09-22 (pass on head
|
commented
Sep 23, 2026
|
🕵 Status 2026-09-23 (head |
commented
Sep 23, 2026
|
The Re-read from the artifact, since only the last 32 KiB of The caller frame is below the printed depth, but it is #119124 gives The link I gave here on 2026-08-09, #113996, is closed: @ PedroTadim reverted that mechanism on 2026-08-12 (#112203) as the wrong shape, and #119124 is the budget shape instead. The hint half of the same family, Separately, on the private sync reds: |
commented
Sep 23, 2026
|
🕵 Status 2026-09-23 (head @groeneai, thanks: noted that the 2026-08-08 |
commented
Sep 23, 2026
|
The Fast test abort you asked me to investigate here on 2026-08-16 is fixed on master, so there is no new PR from me. Not by #115061, which I linked on 2026-08-17 and which was closed unmerged the next day. Owning diff: #112984, merged 2026-08-29; the change is in Fix-presence check in CIDB, keyed on Fast test jobs that report This is separate from the |
commented
Sep 23, 2026
|
🕵 @groeneai, thanks: noted that the 2026-08-16 Fast test abort ( |
commented
Sep 23, 2026
|
Now the biggest question is why it is 8000 lines of code and tests. I think we need to "reset" the implementation. If we resubmit, I will make sure to credit the original author. |
commented
Sep 23, 2026
|
An idea: what if we reuse the same |
commented
Sep 24, 2026
|
Neither #121189 nor #121090 will land: @ fm4v closed both unmerged on 2026-09-23 in favor of #121847, which merged as |
Enables server-side
Overlaydatabases. AnOverlaydatabase is a read-only facade that exposes the union of the tables of several underlying databases, resolving each table name through the listed sources in order (the first source that has the table wins). The facade has no storage of its own:CREATE TABLEthrough it is delegated to the first writable source database, every other DDL on the facade is rejected, whileSELECTand pass-throughINSERTresolve to the underlying source table. Reading, writing or creating a table through the facade requires the corresponding grant on both the facade database and the underlying source, and the facade's row policies are combined with the source's. Previously anOverlaydatabase existed only as the implicit default database ofclickhouse-local.Closes: #52764
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Enable server-side
Overlaydatabases: a read-only facade that exposes the union of the tables of several source databases, passesSELECTandINSERTthrough to the source table, and delegatesCREATE TABLEto the first writable source database.Documentation entry for user-facing changes
Workflow [PR]
Sync PR [sync-upstream/pr/86768]