Skip to content

Split remote database and data lake visibility settings - #109082

Merged
fm4v merged 7 commits into
masterfrom
fix/show-remote-databases-system-tables
Jul 2, 2026
Merged

fm4v merged 7 commits into
masterfrom
fix/show-remote-databases-system-tables

Conversation

@pamarcos

@pamarcos pamarcos commented Jul 1, 2026 •

Copy link
Copy Markdown
Member

Related: #104416

The initial idea was to consolidate the behavior into a single setting: show_data_lake_catalogs_in_system_tables. This was broadened to cover MySQL and
PostgreSQL databases. However, this breaks backwards compatibility in a way that we'd want to avoid. This PR restores the data-lake-specific behavior and keeps
remote database visibility as a separate control.

Thus, with this PR we keep the same behavior we had prior to #104416, but adding a separate setting to
avoid listing MySQL and PostgreSQL databases.

The new show_remote_databases_in_system_tables setting applies only to MySQL
and PostgreSQL databases. It defaults to true, so these databases keep their
previous visibility in system.tables, system.columns, and system.completions
unless users explicitly disable it. DataLakeCatalog databases remain hidden from
those system tables by default and are still controlled only by
show_data_lake_catalogs_in_system_tables.

Changelog category (leave one):

  • Improvement

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Restore show_data_lake_catalogs_in_system_tables as the setting that controls only DataLakeCatalog visibility in system.tables, system.columns, and system.completions. Added show_remote_databases_in_system_tables, enabled by default, to let users hide MySQL and PostgreSQL databases from those system tables separately.

Version info

  • Merged into: 26.7.1.450 (included in 26.7 and later)
  • Backported to: 26.6.2.31, 26.5.6.15, 26.4.5.101, 26.3.17.24

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.
@clickhouse-gh

clickhouse-gh Bot commented Jul 1, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [62139e4]

Summary: ❌

job_name test_name status info comment
AST fuzzer (amd_debug, targeted) FAIL
Logical error: Can't set alias of A of B (STID: 1493-3ccb) FAIL cidb, issue ISSUE CREATED
Stress test (amd_tsan) FAIL
Logical error: Block structure mismatch in A stream: different number of columns: (STID: 0993-308a) FAIL cidb, issue ISSUE CREATED

AI Review

Summary

This PR splits DataLakeCatalog visibility from MySQL/PostgreSQL visibility and restores remote databases to visible-by-default in system.tables/system.columns/system.completions. The current head still has one explicit-query correctness bug and two backward-compatibility regressions, and it reintroduces unscoped metadata scans that can fail on unreachable remote databases.

Findings

❌ Blockers

  • [src/Interpreters/InterpreterShowColumnsQuery.cpp:180-181; src/Interpreters/InterpreterShowIndexesQuery.cpp:131-132] [dismissed by author -- https://github.com/Split remote database and data lake visibility settings #109082#discussion_r3508602837] Explicit SHOW TABLES now opt-ins DataLakeCatalog databases, but SHOW COLUMNS and SHOW INDEX still only force-enable show_remote_databases_in_system_tables. After DatabaseDataLake stopped reporting isRemoteDatabase, these queries rewrite through system.columns / system.tables with show_data_lake_catalogs_in_system_tables = 0 and quietly return no rows for DataLakeCatalog databases unless the user sets the data-lake knob manually.
    Suggested fix: mirror the show_data_lake_catalogs_in_system_tables = 1 override from src/Interpreters/InterpreterShowTablesQuery.cpp:238 in both execute paths.
  • [src/Core/Settings.cpp:7424-7428] [dismissed by author -- https://github.com/Split remote database and data lake visibility settings #109082#discussion_r3511584103] Reusing show_data_lake_catalogs_in_system_tables as a new independent setting silently changes the meaning of an existing 26.6 knob. Queries/configs that still set the old name to hide MySQL/PostgreSQL now leave show_remote_databases_in_system_tables at its default 1, so upgrades change behavior even when the user keeps the same setting name.
    Suggested fix: preserve the legacy name's 26.6 semantics (or compatibility-gate them) and introduce a different name for the data-lake-only control if you need both behaviors at once.
  • [src/Core/SettingsChangesHistory.cpp:61; src/Core/SettingsChangesHistory.cpp:254; tests/queries/0_stateless/02995_settings_26_6_1.tsv:1530] [dismissed by author -- https://github.com/Split remote database and data lake visibility settings #109082#discussion_r3510987586] compatibility = '26.6' no longer restores the 26.6 default for show_remote_databases_in_system_tables. applyCompatibilitySetting only replays previous_value from newer versions, but both history entries record this setting as {true, true}, so the current default 1 survives and the stateless reference now expects that regression.
    Suggested fix: keep an entry that captures the 26.6 hide-by-default behavior and add a separate later entry that restores true for this PR.

⚠️ Majors

  • [tests/queries/0_stateless/04210_show_remote_databases_in_system_tables.sql:1-9; src/Storages/System/StorageSystemTables.cpp:62-64; src/Storages/System/StorageSystemTables.cpp:132-135; src/Storages/System/StorageSystemColumns.cpp:461-463; src/Storages/System/StorageSystemCompletions.cpp:114-116; src/Storages/System/StorageSystemCompletions.cpp:134-135] [dismissed by author -- https://github.com/Split remote database and data lake visibility settings #109082#discussion_r3513148402] The new default show_remote_databases_in_system_tables = 1 reintroduces server-wide remote I/O into unscoped metadata scans. The new stateless test explicitly documents that once one session registers an unreachable PostgreSQL/MySQL database, concurrent system.tables / system.columns / system.completions scans can fail with POSTGRESQL_CONNECTION_FAILURE, and the implementations still call getTablesIterator without shielding those scans from remote-connect failures.
    Suggested fix: keep remote databases hidden by default, or make unfiltered system-table/completion scans stay local unless the query explicitly targets the remote database.
Tests
  • ⚠️ Add a focused regression test for explicit SHOW COLUMNS / SHOW INDEX on a DataLakeCatalog database. Current coverage exercises SHOW TABLES and system.columns/system.tables, so the missing data-lake overrides in InterpreterShowColumnsQuery / InterpreterShowIndexesQuery are still unproven.

@clickhouse-gh clickhouse-gh Bot added the pr-improvement Pull request with some product improvements label Jul 1, 2026
@pamarcos
pamarcos requested a review from Copilot July 1, 2026 17:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR splits visibility controls for external catalogs vs. remote SQL database engines by restoring show_data_lake_catalogs_in_system_tables to govern only DataLakeCatalog visibility and introducing/retuning show_remote_databases_in_system_tables to govern MySQL/PostgreSQL visibility (defaulting to enabled).

Changes:

  • Reintroduces a dedicated setting for data lake catalogs and makes remote SQL database visibility a separate, default-on setting.
  • Updates system tables and related code paths to filter database enumeration based on the new split (with_datalake_catalogs vs with_remote_databases).
  • Updates stateless and integration tests to reflect the new setting behavior and defaults.

Reviewed changes

Copilot reviewed 42 out of 42 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/queries/0_stateless/04210_show_remote_databases_in_system_tables.sql Updates stateless coverage for remote DB visibility and settings exposure.
tests/queries/0_stateless/04210_show_remote_databases_in_system_tables.reference Adjusts expected outputs for the updated stateless test.
tests/integration/test_postgresql_database_engine/test.py Removes explicit opt-in setting usage now that remote DB visibility defaults to enabled.
tests/integration/test_mysql57_database_engine/test.py Removes explicit opt-in setting usage now that remote DB visibility defaults to enabled.
tests/integration/test_mysql_database_engine/test.py Removes explicit opt-in setting usage now that remote DB visibility defaults to enabled.
src/Storages/System/StorageSystemTables.cpp Enumerates databases for system.tables using both datalake and remote-DB visibility settings.
src/Storages/System/StorageSystemReplicationQueue.cpp Switches database enumeration filter from “remote” to “datalake catalogs”.
src/Storages/System/StorageSystemReplicas.cpp Switches database enumeration filter from “remote” to “datalake catalogs”.
src/Storages/System/StorageSystemProjections.cpp Switches database enumeration filter from “remote” to “datalake catalogs”.
src/Storages/System/StorageSystemPartsBase.cpp Switches database enumeration filter from “remote” to “datalake catalogs”.
src/Storages/System/StorageSystemPartMovesBetweenShards.cpp Switches database enumeration filter from “remote” to “datalake catalogs”.
src/Storages/System/StorageSystemObjectStorageQueueSettings.cpp Switches database enumeration filter from “remote” to “datalake catalogs”.
src/Storages/System/StorageSystemMutations.cpp Switches database enumeration filter from “remote” to “datalake catalogs”.
src/Storages/System/StorageSystemKafkaConsumers.cpp Switches database enumeration filter from “remote” to “datalake catalogs”.
src/Storages/System/StorageSystemIcebergHistory.cpp Ensures Iceberg system table sees both datalake catalogs and remote databases.
src/Storages/System/StorageSystemIcebergFiles.cpp Ensures Iceberg system table sees both datalake catalogs and remote databases.
src/Storages/System/StorageSystemGraphite.cpp Switches database enumeration filter from “remote” to “datalake catalogs”.
src/Storages/System/StorageSystemDistributionQueue.cpp Switches database enumeration filter from “remote” to “datalake catalogs”.
src/Storages/System/StorageSystemDataSkippingIndices.cpp Switches database enumeration filter from “remote” to “datalake catalogs”.
src/Storages/System/StorageSystemDatabases.cpp Keeps system.databases listing unconditional while enumerating with both flags enabled.
src/Storages/System/StorageSystemDatabaseReplicas.cpp Switches database enumeration filter from “remote” to “datalake catalogs”.
src/Storages/System/StorageSystemConstraints.cpp Switches database enumeration filter from “remote” to “datalake catalogs”.
src/Storages/System/StorageSystemCompletions.cpp Uses both settings to control DB/table/column completion sources.
src/Storages/System/StorageSystemColumns.cpp Uses both settings to control system.columns enumeration behavior.
src/Storages/System/StorageSystemClusters.cpp Switches database enumeration filter from “remote” to “datalake catalogs”.
src/Storages/StorageMerge.cpp Ensures Merge storage DB-regexp expansion includes both datalake catalogs and remote databases.
src/Storages/RocksDB/StorageSystemRocksDB.cpp Switches database enumeration filter from “remote” to “datalake catalogs”.
src/Server/ReplicasStatusHandler.cpp Switches database enumeration filter from “remote” to “datalake catalogs”.
src/Interpreters/ServerAsynchronousMetrics.cpp Switches database enumeration filter from “remote” to “datalake catalogs”.
src/Interpreters/loadMetadata.cpp Switches conversion scan DB enumeration filter from “remote” to “datalake catalogs”.
src/Interpreters/InterpreterSystemQuery.cpp Switches all-DB iteration filter from “remote” to “datalake catalogs”.
src/Interpreters/InterpreterShowTablesQuery.cpp Forces the relevant setting(s) on for explicit SHOW TABLES for datalake catalogs vs remote DBs.
src/Interpreters/InterpreterCreateQuery.cpp Includes both datalake catalogs and remote DBs when counting databases for server limits.
src/Interpreters/InterpreterCheckQuery.cpp Switches database enumeration filter from “remote” to “datalake catalogs”.
src/Interpreters/DatabaseCatalog.h Splits database enumeration options into two independent flags and adds datalake helpers.
src/Interpreters/DatabaseCatalog.cpp Implements datalake catalogs filtering/caching and updates hinting logic to use split flags.
src/Databases/IDatabase.h Adds isDatalakeCatalog and refines isRemoteDatabase semantics.
src/Databases/DataLake/DatabaseDataLake.h Marks DataLake DBs as datalake catalogs rather than remote DBs.
src/Core/SettingsChangesHistory.cpp Records show_remote_databases_in_system_tables default/behavior changes across versions.
src/Core/Settings.cpp Defines separate settings: datalake visibility (default off) and remote DB visibility (default on).
src/Client/BuzzHouse/Generator/SessionSettings.cpp Adds the restored datalake setting to fuzz session settings generation.
src/Backups/BackupEntriesCollector.cpp Ensures backups enumerate all databases including datalake catalogs and remote DBs.

Record `show_remote_databases_in_system_tables` with default `true` where the
setting is introduced, and update the `26.6` settings reference accordingly.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 43 out of 43 changed files in this pull request and generated 1 comment.

Comment thread src/Interpreters/DatabaseCatalog.cpp Resolved
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.
Comment thread src/Core/SettingsChangesHistory.cpp Resolved
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
Comment thread src/Core/Settings.cpp Resolved
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.
@pamarcos

pamarcos commented Jul 2, 2026

Copy link
Copy Markdown
Member Author

Just realized @fm4v is the one that made the commit to add the setting somewhere else. When I saw it I thought it had been me by mistake and I reverted that. I'm adding your changes back again in 62139e4

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 43 out of 43 changed files in this pull request and generated 3 comments.

Comment thread src/Core/SettingsChangesHistory.cpp Resolved
Comment thread src/Core/SettingsChangesHistory.cpp Resolved
@clickhouse-gh

clickhouse-gh Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 85.50% 85.50% +0.00%
Functions 92.70% 92.70% +0.00%
Branches 77.70% 77.70% +0.00%

Changed lines: Changed C/C++ lines covered: 255/263 (96.96%) · Uncovered code

Full report · Diff report

@fm4v
fm4v added this pull request to the merge queue Jul 2, 2026
Merged via the queue into master with commit 4017eff Jul 2, 2026
171 of 175 checks passed
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jul 2, 2026
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Jul 2, 2026
@groeneai groeneai mentioned this pull request Jul 3, 2026
1 task done
robot-ch-test-poll3 added a commit that referenced this pull request Jul 3, 2026
Cherry pick #109082 to 26.3: Split remote database and data lake visibility settings
robot-clickhouse added a commit that referenced this pull request Jul 3, 2026
robot-ch-test-poll3 added a commit that referenced this pull request Jul 3, 2026
Cherry pick #109082 to 26.4: Split remote database and data lake visibility settings
robot-clickhouse added a commit that referenced this pull request Jul 3, 2026
robot-ch-test-poll3 added a commit that referenced this pull request Jul 3, 2026
Cherry pick #109082 to 26.5: Split remote database and data lake visibility settings
robot-clickhouse added a commit that referenced this pull request Jul 3, 2026
robot-ch-test-poll3 added a commit that referenced this pull request Jul 3, 2026
Cherry pick #109082 to 26.6: Split remote database and data lake visibility settings
robot-clickhouse added a commit that referenced this pull request Jul 3, 2026
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Jul 3, 2026
zlareb1 added a commit that referenced this pull request Jul 3, 2026
Backport #109082 to 26.4: Split remote database and data lake visibility settings
fm4v added a commit that referenced this pull request Jul 5, 2026
Backport #109082 to 26.5: Split remote database and data lake visibility settings
fm4v added a commit that referenced this pull request Jul 5, 2026
Backport #109082 to 26.6: Split remote database and data lake visibility settings
pamarcos added a commit that referenced this pull request Jul 6, 2026
Backport #109082 to 26.3: Split remote database and data lake visibility settings
fm4v added a commit that referenced this pull request Jul 10, 2026
The migration removed the tag by mistake. The test attaches PostgreSQL
and MySQL databases pointing at an unreachable host, and while they
exist any concurrent query scanning `system.tables`, `system.columns`
or `system.completions` without a database filter attempts to connect
and fails with `POSTGRESQL_CONNECTION_FAILURE` (the failure mode fixed
by #109082). The victims are arbitrary tests, so no concurrency group
can contain it.
pull Bot pushed a commit to SINHASantos/ClickHouse that referenced this pull request Aug 20, 2026
A `DatabasePostgreSQL`/`DatabaseMySQL` pointed at an unreachable server
logged the connection failure at error level on code paths that
explicitly tolerate and retry it:

- `DatabasePostgreSQL::getTablesIterator` — its catch exists so that
  `system.tables` scans do not fail on a postgres error
- `DatabasePostgreSQL::removeOutdatedTables` — the background cleaner
  catches, reschedules and continues
- `DatabaseMySQL` constructor — the connection probe failure is
  explicitly tolerated on `ATTACH`
- `DatabaseMySQL::getCreateTableQueryImpl` with `throw_on_error = false`
- `mysqlxx::Pool::allocConnection`, `mysqlxx::PoolWithFailover::get` and
  `postgres::PoolWithFailover::get` — they log before propagating the
  exception to the caller, who decides the severity

The Upgrade check fails on any unexpected error message in the server
log, so the leftover unreachable-host databases created by test
`04210_show_remote_databases_in_system_tables` (added in ClickHouse#104416, made
reachable by `system.tables` scans by default in ClickHouse#109082) tripped the
check on 137 unrelated PRs in 14 days (0 on master).

The new test attaches PostgreSQL and MySQL databases pointing at an
unreachable host, exercises the tolerated paths, and asserts through
`system.text_log` that they produce warnings but no error-level lines.

Co-Authored-By: Claude Fable 5 <[email protected]>
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…databases-system-tables

Split remote database and data lake visibility settings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-improvement Pull request with some product improvements pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-synced-to-cloud The PR is synced to the cloud repo v26.2-must-backport v26.3-must-backport v26.4-must-backport v26.5-must-backport

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants