Skip to content

Do not block startup on an unreachable DataLakeCatalog catalog replayed from stored metadata - #132097

Merged
alexey-milovidov merged 5 commits into
masterfrom
datalake-startup-no-block
Nov 20, 2026
Merged

alexey-milovidov merged 5 commits into
masterfrom
datalake-startup-no-block

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

A DataLakeCatalog database (for example, catalog_type = 's3tables') whose IAM role was deleted could block server startup.

DatabaseDataLake already defers catalog construction for ATTACH and RESTORE, so a plain server restart from local metadata is fine. A catalog of databases replicated through a coordination service, as in ClickHouse Cloud, replays the stored definition as a plain CREATE instead. That query is neither ATTACH nor a restore, so the constructor built the catalog eagerly. For S3 Tables, building the catalog calls STS AssumeRole and sends a signed config request. With the role missing, the error is not ACCESS_DENIED and was rethrown. That aborted the whole replay, which retried forever, so startup never finished.

With this change, a query context marked with isRecoveryFromStoredMetadata counts as an existing definition. That flag is already used for CREATE queries replayed from stored metadata by Replicated database recovery and SYSTEM RESTART REPLICA. The catalog is built on first use, so the database attaches and the error is reported on queries against it. A user CREATE DATABASE still builds the catalog eagerly and fails immediately on misconfiguration. The replaying side sets the flag on its query context in a companion change in the private repository.

No test is added: public code has no path that creates a database from stored metadata as CREATE, and a stateless test cannot set this context flag.

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

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

A DataLakeCatalog database whose catalog is unreachable or unauthorized (for example, an S3 Tables catalog with a deleted IAM role) no longer blocks server startup when its definition is replayed from stored metadata; the error is reported on queries to the database instead.

🤖 Generated with Claude Code


Workflow [PR]
Sync PR [sync-upstream/pr/132097]

Version info

  • Merged into: 26.12.1.24-master (included in 26.12 and later)

…nition

A catalog of databases replicated through a coordination service (as in
ClickHouse Cloud) rebuilds `DataLakeCatalog` databases at startup with a plain
`CREATE` query from the stored definition. That query is neither `ATTACH` nor
a restore, so `DatabaseDataLake` built its catalog eagerly in the constructor.
For an S3 Tables catalog this performs STS `AssumeRole` and a signed config
request; when the IAM role is missing, the error aborted the whole replay,
which was retried forever and blocked server startup.

Treat a context marked with `isRecoveryFromStoredMetadata` as an existing
definition: defer catalog construction to the first use, so the database is
attached and reports the error on queries instead.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [7544ff1]

Summary: ✅


AI Review

Summary

Reviewed #132097 at 7544ff107f9373a93621b720b89cc62296cdd9b1. The change treats DataLakeCatalog definitions replayed with isRecoveryFromStoredMetadata like existing definitions, deferring catalog construction and creation-time validation so an unavailable catalog does not prevent startup. No actionable findings remain. The previous inline finding is addressed in the current code and its thread is already resolved.

Missing context / blind spots
  • ⚠️ The companion change that marks database replay contexts lives in the private repository and was unavailable for inspection. Its diff and a recovery test with an unavailable catalog would complete end-to-end validation. Public callers set this flag only for table recovery, so the stated reason for omitting a public regression test is reasonable. No local build or tests were run.
Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Nov 16, 2026
clickhouse-gh[bot]
clickhouse-gh Bot previously approved these changes Nov 16, 2026

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

AI review approves this commit, see the AI Review comment.

@alexey-milovidov alexey-milovidov self-assigned this Nov 16, 2026
@clickhouse-gh clickhouse-gh Bot added the comp-datalake Data lake table formats (Iceberg/Delta/Hudi) integration. label Nov 16, 2026
@clickhouse-gh

clickhouse-gh Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 7544ff107 with master 463f45f5f (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Compile time of recompiled translation units

7 translation units recompiled, 17 s compile time in total, 7 of them have a recent master baseline.

Job report

@clickhouse-gh
clickhouse-gh Bot dismissed their stale review November 17, 2026 00:00

AI review of a later commit does not approve the PR, see the AI Review comment.

@alexey-milovidov alexey-milovidov added the ci-skip-new-tests-check Ignore a check for new tests in bugfix PRs label Nov 17, 2026
@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 Merged master and added the ci-skip-new-tests-check label. The only CI failure was new_tests_check.py ("No new tests have been added"). As the description says, public code has no path that creates a database from stored metadata as CREATE with isRecoveryFromStoredMetadata set, so neither a stateless test nor an integration test can reproduce the bug here.

alexey-milovidov and others added 2 commits November 19, 2026 18:03
…og` when replaying stored metadata

The `auth_header` check, the `allow_database_*` gates, and the strict
settings parsing in `loadFromQuery` ran before the recovery predicate, so a
previously valid definition replayed as `CREATE` with
`isRecoveryFromStoredMetadata` could still throw and block startup. Compute
the predicate first and treat such a replay like `ATTACH` everywhere.
A forbidden header is still never sent: `RestCatalog::validateAuthHeaders`
rejects it before the first request.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts:
#	src/Databases/DataLake/DatabaseDataLake.cpp
@clickhouse-gh clickhouse-gh Bot added comp-datalake-catalogs Data lake catalogs: the DataLakeCatalog database engine and its catalog clients - Iceberg REST, A... and removed comp-datalake Data lake table formats (Iceberg/Delta/Hudi) integration. labels Nov 20, 2026
@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=132097&sha=97f0990894d718fa899eb129bf01588b45c5ccd9&name_0=PR&name_1=Performance%20Comparison%20%28arm_release%2C%20master_head%2C%20iceberg_s3%2C%202%2F3%29 and provide a fix in a separate PR. If the fix is already in progress, link it here.

The reference (left, master) server disappeared without a <Fatal> record (its server.log just ends at 2026-11-19 21:46:58 while running the prewarm of ie_join_selectivity_key_choice on iceberg_s3, so most likely an external kill such as the kernel OOM killer), after which the report could not be built (left-query-log.tsv empty, all-query-metrics.tsv missing). The job is labeled disk-almost-full. This PR only changes registerDatabaseDataLake, which is not used by that test, and the dying binary is the master one.

I also merged master into the branch.

@groeneai

Copy link
Copy Markdown
Collaborator

Both parts are already fixed in open PRs, and the server was not OOM-killed:

@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 Thanks, @groeneai: the ARM perf death is tracked by #132186 and the missing report by #132710, so nothing to do here. CI at 7544ff10 has no failures now. The only red check is CH Inc sync. Its failures are a OneLake E2E request Timeout and teardown errors in test_distributed_cache tests, and none of them goes through the stored-metadata replay path this PR changes. I re-ran the failed private jobs.

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Nov 20, 2026
Merged via the queue into master with commit 82f5232 Nov 20, 2026
196 checks passed
@alexey-milovidov
alexey-milovidov deleted the datalake-startup-no-block branch November 20, 2026 09:40
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 20, 2026
groeneai added a commit to groeneai/ClickHouse that referenced this pull request Nov 23, 2026
Conflicts with the replayed-definition flag of ClickHouse#115581 and the
`DataLakeCatalog` replay rules of ClickHouse#132097:
- `TableFunctionFactory::get` and `getRequiredAccessOfTableFunction` take
  both `is_replayed_definition` and the loading `mode`; the data lake
  argument check of a table function keys on the mode, like the engine
  path, so a stored `CREATE TABLE ... AS <data lake function>` still loads
  wherever master now parses the function for the access check.
- `DatabaseDataLake::table_definition_mode` treats a replay marked with
  `isRecoveryFromStoredMetadata` as `ATTACH`, as ClickHouse#132097 does for the other
  fresh-`CREATE` validations.
- Glue catalog: `SecretString` engine definition from master, plus the mode.
- Docs and `.syntax` strings: master's workload identity forms of
  `deltaLakeAzure`, `deltaLakeAzureCluster` and `DeltaLakeAzure` without
  the `compression` slot.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-skip-new-tests-check Ignore a check for new tests in bugfix PRs comp-datalake-catalogs Data lake catalogs: the DataLakeCatalog database engine and its catalog clients - Iceberg REST, A... pr-bugfix Pull request with bugfix, not backported by default pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants