Repository navigation
Key the metadata-replay exemption of PostgreSQL, MaterializedPostgreSQL and DataLakeCatalog database engines on the loader flag - #120280
Conversation
…reSQL` and `DataLakeCatalog` on the loader flag The three database engines skipped `remote_url_allow_hosts` (and, for `MaterializedPostgreSQL`, the single-address validation; for `DataLakeCatalog`, the tolerant catalog load) when `args.internal && args.mode >= ATTACH`, taking that pair as the signature of the server replaying its own stored metadata. `internal` does not imply a replay: `InterpreterParallelWithQuery` runs every statement of a user's `PARALLEL WITH` as an internal query, and the full `ATTACH DATABASE ... ENGINE = ...` form runs in `ATTACH` mode, so a user could attach a `PostgreSQL`-backed database to a host the policy forbids by wrapping the statement in `PARALLEL WITH`. `DatabaseFactory::Arguments::is_metadata_replay` is set only by `loadMetadata`, which is the discriminator `DatabaseFilesystem` and `DatabaseBackup` already use. Switch the three engines to it. Startup replay is unchanged (`loadDatabase` sets both flags), and `RESTORE DATABASE` was never covered by the exemption because it replays a `CREATE` in `CREATE` mode. The integration test now wraps a user `ATTACH DATABASE` over the blocked host in `PARALLEL WITH` for both PostgreSQL engines and asserts `UNACCEPTABLE_URL`. Found by the automated review of #118674. Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
Workflow [PR], commit [6fc3d76] Summary: ✅
AI ReviewSummaryThis PR hardens several external database engines so that the “startup metadata replay” exemption is keyed off Final Verdict
LLVM Coverage ReportMeasured on commit 6fc3d76.
Changed lines: Changed C/C++ lines covered: 24/24 (100.00%) · Uncovered code |
…tadata-replay-flag
…ernal` Address review: `lazy_init` still used `args.internal`, so a user `CREATE DATABASE ... ENGINE = DataLakeCatalog` wrapped in `PARALLEL WITH` or `EXECUTE AS` (both run subqueries as internal ones) skipped eager catalog construction and could persist a definition that a plain `CREATE` rejects (e.g. a Glue catalog relying on server credentials). `RestorerFromBackup` now marks the database `CREATE` with `setIsRestoreFromBackup`, which is passed to the engine as `DatabaseFactory::Arguments::is_restore_from_backup`, and `DataLakeCatalog` defers catalog construction only on `ATTACH` or restore. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…tadata-replay-flag Conflicts in `RestorerFromBackup.cpp` and `DatabaseFactory.h`: master independently added `is_restore_from_backup` with the same plumbing; took master's version.
…tadata_replay` `DatabaseHDFS` skipped the upfront `remote_url_allow_hosts` check whenever `internal` was set, so a user `RESTORE DATABASE` or a statement wrapped in `PARALLEL WITH` could persist a definition pointing at a blocked host. Only the server's own startup metadata replay is exempt now. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Build profile diff (arm_release)Commit See the job log for details. |
…on `is_metadata_replay` `PARALLEL WITH` and `EXECUTE AS` run user statements as internal ones, so a user `ATTACH DATABASE ... ENGINE = Cluster(...)` / `Remote(...)` wrapped in them skipped the cluster-name validation and the proxy-chain cycle rejection. Use the loader flag instead of `internal`, and add a regression test for the wrapper case. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 Merged master to pick up 813345f, the fix for the flaky |
…nours `remote_url_allow_hosts` The definition in a backup is user-controlled input, so the `HDFS` database engine must reject a disallowed host on restore just as it does on `CREATE`. The new case backs up an `HDFS` database to a `Memory` backup, tightens the allowlist, and checks that the restore fails with `UNACCEPTABLE_URL` and does not leave the database behind. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 The only red check, |
Related: #118674
Related: #118684
Related: #119848
Update (2026-10-05): #119848 has since landed on master: it marks the subqueries of
PARALLEL WITH,EXECUTE ASandQueryRunnerasuser_initiated, soInterpreterCreateQueryno longer passesinternalto the database engines for them. That closes thePARALLEL WITHreproduction described below on master, which is why the bugfix validation reports that the new tests do not fail there. This PR is kept as hardening: the engines' exemption no longer depends on every wrapper of a user statement remembering to setuser_initiated, and it now matches the discriminatorDatabaseFilesystemandDatabaseBackupuse. The one behaviour change left on master is that theHDFSdatabase engine also checksremote_url_allow_hostsfor a database created byRESTORE DATABASE. The changelog category is changed from Bug Fix to Improvement accordingly.The
PostgreSQL,MaterializedPostgreSQLandDataLakeCatalogdatabase engines exempt the server's replay of its own stored metadata fromremote_url_allow_hosts(and from the single-address validation and the tolerant catalog load, respectively), so that one database created before a policy was tightened cannot turn into a server that does not boot. They recognised that replay asargs.internal && args.mode >= ATTACH.internaldoes not imply a replay:InterpreterParallelWithQueryruns every statement of a user'sPARALLEL WITHas an internal query, and the fullATTACH DATABASE ... ENGINE = ...form runs inATTACHmode. Wrapping the statement inPARALLEL WITHtherefore let a user attach aPostgreSQL-backed database to a host the policy forbids.DatabaseFactory::Arguments::is_metadata_replay(introduced in #118684) is set only byloadMetadataand is the discriminatorDatabaseFilesystemandDatabaseBackup(#118674) already use. This switches the three remaining engines to it. Startup replay is unchanged, becauseloadDatabasesets both flags.RESTORE DATABASEwas never covered by the exemption, because it replays aCREATEinCREATEmode.DataLakeCatalogalso deferred catalog construction wheneverargs.internalwas set, meant forRESTORE DATABASE, so a userCREATE DATABASE ... ENGINE = DataLakeCatalogwrapped inPARALLEL WITHorEXECUTE ASskipped the eager construction that rejects e.g. a Glue catalog relying on server credentials.RestorerFromBackupnow marks its databaseCREATEwithsetIsRestoreFromBackup, carried to engines asDatabaseFactory::Arguments::is_restore_from_backup, andDataLakeCatalogdefers construction only onATTACHor restore.The same
internal-based check also gated the eager validation of theClusterandRemotedatabase engines (unknown cluster name, a proxy chain that refers back to itself) and theremote_url_allow_hostscheck of theHDFSdatabase engine; they are keyed onis_metadata_replaynow too.The integration test
test_postgresql_remote_host_filtergains a case that wraps a userATTACH DATABASEover the blocked host inPARALLEL WITHfor both PostgreSQL engines and assertsUNACCEPTABLE_URL. The stateless test05243_datalake_catalog_parallel_with_eager_initcovers theDataLakeCatalogpart. The stateless test05321_proxy_database_attach_parallel_withcoversClusterandRemote. The integration testtest_database_hdfs_read_grantgainstest_hdfs_database_restore_is_checked, which asserts thatRESTORE DATABASEof anHDFSdatabase whose host is not allowed fails withUNACCEPTABLE_URLand does not create the database. Found by the automated review of #118674.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
The
PostgreSQL,MaterializedPostgreSQL,DataLakeCatalog,Cluster,RemoteandHDFSdatabase engines key the exemption for the server's replay of its own stored metadata on the metadata loader instead of on the query being internal. AHDFSdatabase restored withRESTORE DATABASEis now checked againstremote_url_allow_hosts.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/120280]
Version info
26.10.1.1775-master(included in26.10and later)