Skip to content

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

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

robot-clickhouse merged 4 commits into
backport/26.3/108674from
cherrypick/26.3/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
Adapt cherry-pick of #108674 ("Do not validate DataLakeCatalog
`auth_header` or build catalog on ATTACH") to 26.3, where the catalog is
already built lazily.

On `master` the fix had two parts: gate the `auth_header` validation in
`registerDatabaseDataLake` on `CREATE` only, and defer eager catalog
construction (`DatabaseDataLake::initialize` called from the constructor)
to first use on `ATTACH`. In 26.3 the constructor only calls
`validateSettings` and the catalog is already built lazily inside
`getCatalog` (there is no `initialize` method and `catalog_impl` is
already `mutable`), so the second part of the change does not apply and
would not even compile against 26.3.

Resolution:
- `DatabaseDataLake.h`: kept unchanged (the `lazy_init` constructor
  parameter, `catalog_mutex`, and `initialize` declaration from `master`
  do not exist in 26.3).
- `DatabaseDataLake.cpp`: applied only the `registerDatabaseDataLake`
  gate (`if (!args.create_query.attach && !auth_header_str.empty())`),
  which is the part that fixes the 26.3 startup failure. The
  constructor/`initialize`/`getCatalog` changes were dropped.
- `RestCatalog.cpp`: kept the `http_forbid_headers` enforcement on the
  lazy `RestCatalog` constructor path and the `Common/HTTPHeaderFilter.h`
  include (auto-merged cleanly; 26.3 also builds the catalog lazily, so
  this is where a forbidden persisted header is first rejected).
- Added the test `04401_datalake_attach_does_not_block_startup`.

The resulting diff against the backport base is exactly the four files of
the adapted fix; `DatabaseDataLake.h` is unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member

Resolved the conflicts so this cherry-pick of #108674 applies cleanly to 26.3. The branch is now MERGEABLE / CLEAN against backport/26.3/108674, and the diff against the base is exactly the four files of the adapted fix.

The PR could not be cherry-picked verbatim because 26.3 is structurally different from master. On master the fix has two parts:

  1. Gate the auth_header validation in registerDatabaseDataLake on CREATE only.
  2. Defer eager catalog construction on ATTACH (move DatabaseDataLake::initialize out of the constructor and build the catalog lazily under a new catalog_mutex).

In 26.3 the catalog is already built lazily inside getCatalog: the constructor only calls validateSettings, there is no initialize method, and catalog_impl is already mutable. So part 2 does not apply and would not even compile against 26.3.

Resolution:

  • src/Databases/DataLake/DatabaseDataLake.h — kept unchanged (the lazy_init constructor parameter, catalog_mutex, and initialize declaration introduced on master do not exist in 26.3).
  • src/Databases/DataLake/DatabaseDataLake.cpp — applied only the registerDatabaseDataLake gate if (!args.create_query.attach && !auth_header_str.empty()), which is the part that fixes the 26.3 startup failure. The constructor / initialize / getCatalog changes were dropped.
  • src/Databases/DataLake/RestCatalog.cpp — kept the http_forbid_headers enforcement on the lazy RestCatalog constructor path plus the Common/HTTPHeaderFilter.h include (auto-merged cleanly; 26.3 builds the catalog lazily, so this is where a forbidden persisted header is first rejected on use).
  • Added the test 04401_datalake_attach_does_not_block_startup.

The test exercises both 26.3-relevant paths: a malformed auth_header and a forbidden auth_header (exact_header) both attach at startup but are still reported on first use, and CREATE with a malformed header is still rejected up front.

@robot-clickhouse
robot-clickhouse merged commit 583c949 into backport/26.3/108674 Jun 30, 2026
1 check passed
@robot-clickhouse
robot-clickhouse deleted the cherrypick/26.3/108674 branch June 30, 2026 07:00
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