Skip to content

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

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

robot-clickhouse merged 4 commits into
backport/26.4/108674from
cherrypick/26.4/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
…ypick/26.4/108674

# Conflicts:
#	src/Databases/DataLake/DatabaseDataLake.cpp
#	src/Databases/DataLake/DatabaseDataLake.h
@alexey-milovidov

Copy link
Copy Markdown
Member

Resolved the cherry-pick conflicts by merging backport/26.4/108674 into this branch (90646a6a500..4d3615ea1b4). The PR now diffs cleanly against its base — exactly 4 files (+86/-2):

src/Databases/DataLake/DatabaseDataLake.cpp                 |  8 +-
src/Databases/DataLake/RestCatalog.cpp                      |  9 +++
.../04401_datalake_attach_does_not_block_startup.reference  |  6 ++
.../04401_datalake_attach_does_not_block_startup.sh         | 65 ++++++++

Why the backport is smaller than the original #108674

The original PR did three things on master:

  1. Defer catalog construction on ATTACH — master's constructor eagerly called initialize, so it added a lazy_init constructor flag, split out an initialize method, and added a catalog_mutex to guard lazy initialization in getCatalog.
  2. Validate auth_header on CREATE only in registerDatabaseDataLake.
  3. Enforce http_forbid_headers lazily in RestCatalog (so a forbidden header persisted by an older version is still rejected on first use, since it is no longer checked on ATTACH).

On 26.4, item (1) is already the behavior: the constructor only calls validateSettings, and getCatalog() const already builds catalog_impl (which is already mutable) lazily on first access. There is no eager construction on ATTACH to fix. So the lazy_init flag, the initialize split, and the catalog_mutex are master-only machinery and are intentionally not backported — DatabaseDataLake.h is unchanged here. (The pre-existing absence of a mutex around 26.4's lazy getCatalog is independent of this fix and out of scope for the backport.)

What 26.4 actually needed, and what this backport contains, is items (2) and (3):

  • DatabaseDataLake.cpp: if (!auth_header_str.empty()) → if (!args.create_query.attach && !auth_header_str.empty()), so a persisted malformed/forbidden auth_header no longer blocks server startup on ATTACH.
  • RestCatalog.cpp: enforce http_forbid_headers on the parsed auth_header before loadConfig, so the forbidden header is still rejected on first use.

Test trace on 26.4

04401_datalake_attach_does_not_block_startup.sh passes against this resolution: both bad DBs attach (validation skipped on ATTACH; getCatalog is not called); CHECK DATABASE of the malformed one → Unexpected format of auth header (from parseAuthHeader); CREATE with a malformed header → Invalid auth header format; the forbidden-header DB attaches but CHECK DATABASE → is forbidden (via the new RestCatalog check). exact_header is forbidden by tests/config/config.d/forbidden_headers.xml in 26.4, and it is installed by install.sh.

Original PR: #108674

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