Skip to content

Cherry pick #108674 to 26.5: Do not validate DataLakeCatalog auth_header or build catalog on ATTACH - #108794

Merged
robot-clickhouse merged 4 commits into
backport/26.5/108674from
cherrypick/26.5/108674
Jun 30, 2026
Merged

robot-clickhouse merged 4 commits into
backport/26.5/108674from
cherrypick/26.5/108674

Conversation

@robot-clickhouse

Copy link
Copy Markdown
Member

Original pull-request #108674

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-pick locally.
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:

  • delete the pr-cherrypick label from the PR
  • delete this branch from the repository

You also need to check the Original pull-request for pr-backports-created label, and delete if it's presented there

The PR source

The PR is created in the CI job

groeneai and others added 3 commits June 27, 2026 01:15
A DataLakeCatalog database whose auth_header was accepted by an older
version (which validated it lazily) became un-attachable after upgrading
to 26.2+. The auth_header validation in registerDatabaseDataLake ran on
ATTACH as well as CREATE, so at startup one database with a malformed
auth_header threw BAD_ARGUMENTS during attach and the server failed to
start (exit 36).

On master the constructor additionally builds the catalog eagerly
(RestCatalog reads the catalog config over the network), so any database
with an unreachable endpoint also failed to attach at startup.

Gate the auth_header validation on CREATE only, matching the existing
allow_experimental_database_* gates in the same function which already
self-skip on attach. Defer catalog construction to first use on ATTACH
so that attach performs no validation or network I/O; the catalog is
built lazily in getCatalog under catalog_mutex (the eager construction
was originally a race fix, so lazy init is now synchronized). CREATE
still builds eagerly and rejects malformed headers up front.

A malformed auth_header is reported lazily on first use of the database,
as it was before, so one misconfigured database can no longer block
server startup.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
The startup-block fix gated auth_header validation in registerDatabaseDataLake
to CREATE only. That validation was also the only place enforcing
http_forbid_headers for a persisted auth_header, so old metadata carrying a
forbidden header would attach and then send it on first use, even though CREATE
still rejects it.

Run the forbidden-header check in the RestCatalog constructor, right after the
header is parsed and before loadConfig issues the first request. That is where a
user-provided auth_header first becomes a header sent to the catalog, so the
check covers the deferred first-use path without reintroducing the startup block
(the catalog is still built lazily on ATTACH). The CREATE path is unchanged.

Extend 04401_datalake_attach_does_not_block_startup: a persisted forbidden
auth_header attaches (no startup block) but is rejected on first use. The
forbidden-header filter is read only by the server, so that part runs against
the test server.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
…rtup_108671

Do not validate DataLakeCatalog auth_header or build catalog on ATTACH
@robot-clickhouse robot-clickhouse added pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only! do not test disable testing on pull request pr-bugfix Pull request with bugfix, not backported by default labels Jun 29, 2026
Resolve cherry-pick conflicts of #108674 for 26.5.

26.5 already builds the `DataLakeCatalog` lazily: the `DatabaseDataLake`
constructor does not call `initialize()` and `getCatalog()` constructs the
catalog on first access, so the master fix's `lazy_init` parameter / `initialize`
restructuring / `catalog_mutex` (which moved master from eager to lazy
construction) do not apply and `DatabaseDataLake.h` is left unchanged.

The parts of the fix that are meaningful for 26.5 are applied:
- `registerDatabaseDataLake`: gate the `auth_header` validation on CREATE only
  (`!args.create_query.attach`), so a database persisted by an older version with
  a malformed/forbidden `auth_header` no longer blocks server startup on ATTACH.
- `RestCatalog`: enforce `http_forbid_headers` on the lazy build path, where the
  `auth_header` first becomes a request header, since validation no longer runs on
  ATTACH.

Includes test `04401_datalake_attach_does_not_block_startup`.
@alexey-milovidov

Copy link
Copy Markdown
Member

Resolved the cherry-pick conflicts for 26.5 by merging backport/26.5/108674 into this branch (64e7cf530c5). The PR is now MERGEABLE/CLEAN.

Key adaptation: 26.5 has already diverged from master here — it builds the DataLakeCatalog lazily. The DatabaseDataLake constructor does not call initialize(), and getCatalog() constructs the catalog on first access (with catalog_impl already mutable). So the master fix's lazy_init constructor parameter, the initialize() const TSA_REQUIRES restructuring, and the new catalog_mutex — all of which moved master from eager-in-constructor to lazy construction — do not apply to 26.5. DatabaseDataLake.h is therefore left unchanged.

The parts of #108674 that are meaningful for 26.5 are applied verbatim (hunks byte-identical to the original where they apply):

  • registerDatabaseDataLake — gate the auth_header validation on CREATE only (!args.create_query.attach), so a database persisted by an older version with a malformed/forbidden auth_header can no longer block server startup on ATTACH (the original bug, DataLakeCatalog with a malformed auth_header created in 25.12 prevents server startup after upgrade to 26.2+ #108671).
  • RestCatalog — enforce http_forbid_headers on the lazy build path (where the user-provided auth_header first becomes a request header), since validation no longer runs on ATTACH.
  • Test 04401_datalake_attach_does_not_block_startup (number is free on 26.5; highest existing 044xx is 04411).

Net PR diff is exactly 4 files (+86/-2): DatabaseDataLake.cpp (+8/-2), RestCatalog.cpp (+9), and the new test .sh (+65) / .reference (+6).

I verified against 26.5 that every error string the test asserts is produced: CHECK DATABASE → getCatalog() → parseAuthHeader throws Unexpected format of auth header; CREATE-path reject throws Invalid auth header format; and the forbidden-header path throws ... is forbidden via the new RestCatalog enforcement. This is a first-step cherry-pick, so the check results here can be ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do not test disable testing on pull request pr-bugfix Pull request with bugfix, not backported by default pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants