Repository navigation
Cherry pick #109082 to 26.4: Split remote database and data lake visibility settings - #109219
Conversation
Restore `show_data_lake_catalogs_in_system_tables` for `DataLakeCatalog` visibility in system introspection tables. Add `show_remote_databases_in_system_tables`, enabled by default, for `MySQL` and `PostgreSQL` databases only. Keep separate `IDatabase` APIs so data lake catalogs and remote databases are classified independently.
Record `show_remote_databases_in_system_tables` with default `true` where the setting is introduced, and update the `26.6` settings reference accordingly.
Keep the existing remote database integration tests focused on the `system.columns` visibility behavior restored by this PR. The explicit `SHOW COLUMNS` and `SHOW INDEX` checks were added together with the original `show_remote_databases_in_system_tables` change, but they are not needed for the default remote database visibility coverage.
Add a `show_remote_databases_in_system_tables` entry to the 26.7 settings changes history block so the Upgrade check passes: the baseline release is 26.6, and the check requires an entry in a version block newer than the baseline. Keep the values as `true, true` so `compatibility` mode does not roll the restored default back to `false`. Tag `04210_show_remote_databases_in_system_tables` as `no-parallel`. The test registers `PostgreSQL` and `MySQL` databases on an unreachable host; with the new default `show_remote_databases_in_system_tables = true` they are visible in `system.tables`, `system.columns` and `system.completions`, so concurrent tests that scan those tables without a database filter timed out with `POSTGRESQL_CONNECTION_FAILURE`. This caused failures in 00564_temporary_table_management, 01518_cast_nullable_virtual_system_column, 03566_system_completions_table, 03602_query_system_tables_definer and 00696_system_columns_limit. CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=109082&sha=latest&name_0=PR
Keep `show_remote_databases_in_system_tables` as a single `26.6` settings-history entry with default value `true`. This avoids duplicate history entries while keeping the restored default visible in the generated compatibility reference.
Revert commit e79fd5f and return to the layout from commit 9c7c5ab and commit 1fc129c: `show_remote_databases_in_system_tables` is recorded as `{true, true}` in both the `26.2` and the `26.7` settings-history blocks. The `26.2` entry covers the planned backports to 26.2+ release branches, and the `26.7` entry satisfies the Upgrade check, which requires an entry in a block newer than the 26.6 baseline release. Keeping both values `true` means `compatibility` mode never rolls the restored default back to `false`, matching the pre-#104416 behavior where `MySQL` and `PostgreSQL` databases were always visible.
…system-tables Split remote database and data lake visibility settings
…ypick/26.4/109082 # Conflicts: # src/Interpreters/InterpreterSystemQuery.cpp # src/Storages/System/StorageSystemConstraints.cpp # src/Storages/System/StorageSystemIcebergFiles.cpp # tests/queries/0_stateless/02995_settings_26_3_1.tsv
There was a problem hiding this comment.
Pull request overview
Backport of #109082 to the 26.4 branch to split visibility controls for data-lake catalogs vs remote DB engines in system tables. This restores data-lake-specific behavior under show_data_lake_catalogs_in_system_tables while keeping MySQL/PostgreSQL visibility separately controlled via show_remote_databases_in_system_tables (default enabled).
Changes:
- Split
DatabaseCatalogfiltering intowith_datalake_catalogsvswith_remote_databases, and update system table implementations to use the correct flag(s). - Restore/introduce separate settings:
show_data_lake_catalogs_in_system_tables(defaultfalse) andshow_remote_databases_in_system_tables(defaulttrue). - Update stateless + integration tests to reflect new defaults and expected visibility.
Reviewed changes
Copilot reviewed 41 out of 41 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/queries/0_stateless/04210_show_remote_databases_in_system_tables.sql | Updates stateless test expectations and tags for the new split settings/defaults. |
| tests/queries/0_stateless/04210_show_remote_databases_in_system_tables.reference | Updates expected output for the stateless test. |
| tests/queries/0_stateless/02995_settings_26_3_1.tsv | Adds the new setting to the “expected settings list” snapshot. |
| tests/integration/test_postgresql_database_engine/test.py | Adjusts PostgreSQL engine integration test to rely on new defaults. |
| tests/integration/test_mysql57_database_engine/test.py | Adjusts MySQL 5.7 engine integration test to rely on new defaults. |
| tests/integration/test_mysql_database_engine/test.py | Adjusts MySQL engine integration test to rely on new defaults. |
| src/Storages/System/StorageSystemTables.cpp | Uses both settings to decide whether to include datalake catalogs vs remote DBs when listing databases for system.tables. |
| src/Storages/System/StorageSystemReplicationQueue.cpp | Switches database listing to exclude datalake catalogs during local-only enumeration. |
| src/Storages/System/StorageSystemReplicas.cpp | Switches database listing to exclude datalake catalogs during local-only enumeration. |
| src/Storages/System/StorageSystemProjections.cpp | Switches database listing to exclude datalake catalogs during local-only enumeration. |
| src/Storages/System/StorageSystemPartsBase.cpp | Switches database listing to exclude datalake catalogs during local-only enumeration. |
| src/Storages/System/StorageSystemPartMovesBetweenShards.cpp | Switches database listing to exclude datalake catalogs during local-only enumeration. |
| src/Storages/System/StorageSystemObjectStorageQueueSettings.cpp | Updates database enumeration used by object storage queue settings system table. |
| src/Storages/System/StorageSystemMutations.cpp | Switches database listing to exclude datalake catalogs during local-only enumeration. |
| src/Storages/System/StorageSystemKafkaConsumers.cpp | Updates database enumeration for Kafka consumer system table. |
| src/Storages/System/StorageSystemIcebergHistory.cpp | Ensures Iceberg history system table can include both datalake catalogs and remote DBs when needed. |
| src/Storages/System/StorageSystemGraphite.cpp | Switches database listing to exclude datalake catalogs during local-only enumeration. |
| src/Storages/System/StorageSystemDistributionQueue.cpp | Switches database listing to exclude datalake catalogs during local-only enumeration. |
| src/Storages/System/StorageSystemDataSkippingIndices.cpp | Switches database listing to exclude datalake catalogs during local-only enumeration. |
| src/Storages/System/StorageSystemDatabases.cpp | Ensures system.databases includes both datalake catalogs and remote DBs unconditionally. |
| src/Storages/System/StorageSystemDatabaseReplicas.cpp | Switches database listing to exclude datalake catalogs during local-only enumeration. |
| src/Storages/System/StorageSystemCompletions.cpp | Uses both settings when deciding which DBs to include in system.completions. |
| src/Storages/System/StorageSystemColumns.cpp | Uses both settings when deciding which DBs to include in system.columns. |
| src/Storages/System/StorageSystemClusters.cpp | Switches database listing to exclude datalake catalogs when enumerating for cluster-related info. |
| src/Storages/StorageMerge.cpp | Ensures Merge engine DB regex path includes both datalake catalogs and remote DBs. |
| src/Storages/RocksDB/StorageSystemRocksDB.cpp | Switches database listing to exclude datalake catalogs during local-only enumeration. |
| src/Server/ReplicasStatusHandler.cpp | Switches database listing to exclude datalake catalogs during local-only enumeration. |
| src/Interpreters/ServerAsynchronousMetrics.cpp | Switches database listing to exclude datalake catalogs during local-only enumeration. |
| src/Interpreters/loadMetadata.cpp | Switches database listing to exclude datalake catalogs when iterating DBs for conversion logic. |
| src/Interpreters/InterpreterSystemQuery.cpp | Switches database listing to exclude datalake catalogs in multiple system operations. |
| src/Interpreters/InterpreterShowTablesQuery.cpp | Ensures explicit SHOW TABLES forces visibility for requested datalake catalogs and remote DBs. |
| src/Interpreters/InterpreterCreateQuery.cpp | Ensures database-count checks include both datalake catalogs and remote DBs. |
| src/Interpreters/InterpreterCheckQuery.cpp | Switches database listing to exclude datalake catalogs for CHECK-related DB enumeration. |
| src/Interpreters/DatabaseCatalog.h | Introduces GetDatabasesOptions split flags and adds datalake helpers. |
| src/Interpreters/DatabaseCatalog.cpp | Implements separate cached maps and filtering for datalake catalogs vs remote DBs. |
| src/Databases/IDatabase.h | Adds isDatalakeCatalog and clarifies remote DB classification. |
| src/Databases/DataLake/DatabaseDataLake.h | Marks DataLake DB as a datalake catalog (not a “remote DB” in the new split). |
| src/Core/SettingsChangesHistory.cpp | Updates settings-change history entries related to these settings. |
| src/Core/Settings.cpp | Declares separate settings and updates defaults/description strings accordingly. |
| src/Client/BuzzHouse/Generator/SessionSettings.cpp | Adds the new setting(s) to fuzz/session settings generation. |
| src/Backups/BackupEntriesCollector.cpp | Ensures backups enumerate DB metadata including both datalake catalogs and remote DBs when needed. |
Comments suppressed due to low confidence (6)
src/Storages/System/StorageSystemObjectStorageQueueSettings.cpp:66
getDatabases(GetDatabasesOptions{.with_datalake_catalogs = false})will still includeMySQL/PostgreSQLdatabases (becausewith_remote_databasesdefaults totrue). This code then callsgetTablesIteratorfor every database, which can trigger remote enumeration/network calls and failures. Exclude remote databases here.
auto databases = DatabaseCatalog::instance().getDatabases(GetDatabasesOptions{.with_datalake_catalogs = false});
for (const auto & db : databases)
{
for (auto iterator = db.second->getTablesIterator(context); iterator->isValid(); iterator->next())
{
src/Storages/System/StorageSystemKafkaConsumers.cpp:273
getDatabases(GetDatabasesOptions{.with_datalake_catalogs = false})will still includeMySQL/PostgreSQLdatabases (becausewith_remote_databasesdefaults totrue). This code iterates tables for every database, which can unexpectedly enumerate remote databases and perform network calls. Exclude remote databases here.
auto databases = DatabaseCatalog::instance().getDatabases(GetDatabasesOptions{.with_datalake_catalogs = false});
for (const auto & db : databases)
{
for (auto it = db.second->getTablesIterator(context); it->isValid(); it->next())
{
src/Interpreters/InterpreterSystemQuery.cpp:1495
dropStorageReplicasFromDatabasecallsdatabase->getTablesIterator, so includingMySQL/PostgreSQLdatabases here can cause remote enumeration/network calls (and failures) duringSYSTEM DROP REPLICA .... Previously remote DBs were excluded; keep excluding them.
auto databases = DatabaseCatalog::instance().getDatabases(GetDatabasesOptions{.with_datalake_catalogs = false});
auto access = getContext()->getAccess();
bool access_is_granted_globally = access->isGranted(AccessType::SYSTEM_DROP_REPLICA);
/// Instead of silently failing, check the permissions to delete all databases in advance.
/// Throw an exception to user if the user doesn't have enough privileges to drop the replica.
/// Include the databases that the user needs privileges for in the exception
std::vector<String> required_access;
for (auto & elem : databases)
{
src/Interpreters/InterpreterSystemQuery.cpp:1864
- This
SYSTEM DROP DATABASE REPLICApath iterates all databases and may enumerate tables (viadropStorageReplicasFromDatabase). WithGetDatabasesOptions{.with_datalake_catalogs = false}remote databases (MySQL/PostgreSQL) are still included by default, which can trigger remote enumeration/network calls. Exclude remote databases here.
auto databases = DatabaseCatalog::instance().getDatabases(GetDatabasesOptions{.with_datalake_catalogs = false});
auto access = getContext()->getAccess();
bool access_is_granted_globally = access->isGranted(AccessType::SYSTEM_DROP_REPLICA);
for (auto & elem : databases)
{
DatabasePtr & database = elem.second;
auto * replicated = dynamic_cast<DatabaseReplicated *>(database.get());
if (!replicated)
continue;
src/Interpreters/InterpreterSystemQuery.cpp:1533
- This check iterates
database->getTablesIteratorfor every database. WithGetDatabasesOptions{.with_datalake_catalogs = false}remote databases (MySQL/PostgreSQL) are still included by default, so this can trigger remote enumeration/network calls duringSYSTEM DROP REPLICA. Exclude remote databases here to keep the check purely local.
for (auto & elem : DatabaseCatalog::instance().getDatabases(GetDatabasesOptions{.with_datalake_catalogs = false}))
{
DatabasePtr & database = elem.second;
for (auto iterator = database->getTablesIterator(getContext()); iterator->isValid(); iterator->next())
{
if (auto * storage_replicated = dynamic_cast<StorageReplicatedMergeTree *>(iterator->table().get()))
src/Interpreters/InterpreterSystemQuery.cpp:2042
- This loop enumerates tables in every database to load/unload primary keys. With
GetDatabasesOptions{.with_datalake_catalogs = false}remote databases (MySQL/PostgreSQL) are still included by default, andgetTablesIteratoron them may perform remote enumeration/network calls. Exclude remote databases here so the operation only walks local databases.
for (auto & database : DatabaseCatalog::instance().getDatabases(GetDatabasesOptions{.with_datalake_catalogs = false}))
{
for (auto it = database.second->getTablesIterator(getContext()); it->isValid(); it->next())
{
if (auto * merge_tree = dynamic_cast<MergeTreeData *>(it->table().get()))
|
|
||
| #include <Storages/System/StorageSystemIcebergHistory.h> |
| else | ||
| { | ||
| for (auto & elem : DatabaseCatalog::instance().getDatabases(GetDatabasesOptions{.with_remote_databases = false})) | ||
| for (auto & elem : DatabaseCatalog::instance().getDatabases(GetDatabasesOptions{.with_datalake_catalogs = false})) |
| cursor.execute("ALTER TABLE test_table ADD COLUMN data Text") | ||
| assert "data" in node1.query("SHOW COLUMNS FROM postgres_database.test_table") | ||
| assert "PRIMARY" in node1.query("SHOW INDEX FROM postgres_database.test_table") | ||
| assert "data" in node1.query( | ||
| "SELECT name FROM system.columns WHERE table = 'test_table' AND database = 'postgres_database'", | ||
| settings={"show_remote_databases_in_system_tables": 1}, | ||
| "SELECT name FROM system.columns WHERE table = 'test_table' AND database = 'postgres_database'" | ||
| ) |
| mysql_node.query( | ||
| "ALTER TABLE `test_database`.`test_table` ADD COLUMN `add_column` int(11)" | ||
| ) | ||
| assert "add_column" in clickhouse_node.query( | ||
| "SHOW COLUMNS FROM test_database.test_table" | ||
| ) | ||
| assert "PRIMARY" in clickhouse_node.query( | ||
| "SHOW INDEX FROM test_database.test_table" | ||
| ) | ||
| assert "add_column" in clickhouse_node.query( | ||
| "SELECT name FROM system.columns WHERE table = 'test_table' AND database = 'test_database'", | ||
| settings={"show_remote_databases_in_system_tables": 1}, | ||
| "SELECT name FROM system.columns WHERE table = 'test_table' AND database = 'test_database'" | ||
| ) |
| mysql_node.query( | ||
| "ALTER TABLE `test_database`.`test_table` ADD COLUMN `add_column` int(11)" | ||
| ) | ||
| assert "add_column" in clickhouse_node.query( | ||
| "SHOW COLUMNS FROM test_database.test_table" | ||
| ) | ||
| assert "PRIMARY" in clickhouse_node.query( | ||
| "SHOW INDEX FROM test_database.test_table" | ||
| ) | ||
| assert "add_column" in clickhouse_node.query( | ||
| "SELECT name FROM system.columns WHERE table = 'test_table' AND database = 'test_database'", | ||
| settings={"show_remote_databases_in_system_tables": 1}, | ||
| "SELECT name FROM system.columns WHERE table = 'test_table' AND database = 'test_database'" | ||
| ) |
| SELECT '--- system.settings exposes both the new name and the alias ---'; | ||
| SELECT name, alias_for FROM system.settings WHERE name IN ('show_remote_databases_in_system_tables', 'show_data_lake_catalogs_in_system_tables') ORDER BY name; | ||
| SELECT '--- system.settings exposes separate data-lake and remote-database settings ---'; | ||
| SELECT name, value, alias_for = '' FROM system.settings WHERE name IN ('show_remote_databases_in_system_tables', 'show_data_lake_catalogs_in_system_tables') ORDER BY name; |
Original pull-request #109082
Do not merge this PR manually
This pull-request is a first step of an automated backporting.
It contains changes similar to calling
git cherry-picklocally.If you intend to continue backporting the changes, then resolve all conflicts if any.
Otherwise, if you do not want to backport them, then just close this pull-request.
The check results does not matter at this step - you can safely ignore them.
Troubleshooting
If the conflicts were resolved in a wrong way
If this cherry-pick PR is completely screwed by a wrong conflicts resolution, and you want to recreate it:
pr-cherrypicklabel from the PRYou also need to check the Original pull-request for
pr-backports-createdlabel, and delete if it's presented thereThe PR source
The PR is created in the CI job