Repository navigation
DatabaseDataLake: Restore onelake_bearer_token, lazy init for internal create - #109724
Conversation
Add onelake_bearer_token option
| /*lazy_init=*/args.create_query.attach); | ||
| /// Internal creates (`RESTORE DATABASE`, shared catalog) shouldn't do network I/O. | ||
| /// We don't want an unreachable or unauthorized catalog to block replica startup. | ||
| /*lazy_init=*/args.create_query.attach || args.is_internal); |
|
Workflow [PR], commit [119165f] Summary: ✅
AI ReviewSummaryThis PR restores Tests
Final Verdict
|
463c116 to
69b6274
Compare
|
Preview deployment for your docs. Learn more about Mintlify Previews.
|
|
|
||
| @only_onelake | ||
| def test_onelake_read_with_bearer_token(node, catalog_manager, sales_table): | ||
| """Read table data authenticating only with onelake_bearer_token. |
There was a problem hiding this comment.
The reported bug is the metadata-load path: a persisted OneLake DataLakeCatalog with a stale bearer token should no longer block ClickHouse startup. None of the new tests exercises that path, though: they all cover fresh CREATE DATABASE + query behavior on a running server.
Because the behavior switch is args.internal in DatabaseDataLake, this bug can regress without any of these tests failing. Please add a focused regression test that creates a OneLake catalog, restarts the node, and verifies startup succeeds. If restore is meant to be lazy too, add the analogous RESTORE DATABASE case as well.
There was a problem hiding this comment.
I have a test. Will add to the other repo once this PR is merged.
| /// On ATTACH (server startup / user `ATTACH DATABASE`) or internal creates (restore), | ||
| // defer catalog construction to first use: building it can perform network I/O or credential validation | ||
| // that must not block startup. On CREATE build eagerly so misconfiguration (including a restricted | ||
| // server-credential catalog) is reported immediately. |
There was a problem hiding this comment.
small point, looks like some lines are starting with "//" instead of "///"
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 37/95 (38.95%) · Uncovered code |
When catalog credentials expire (e.g. an expired `onelake_bearer_token` for the OneLake catalog), a query to a table in a `DataLakeCatalog` database failed with `UNKNOWN_TABLE` instead of the real authentication error, and system tables like `system.iceberg_files` silently returned an empty result. `RestCatalog::tryGetTableMetadata` now treats only HTTP 404 as "table does not exist" and propagates any other error (401/403 for expired or invalid credentials, 5xx, ...). `DatabaseDataLake` table listing now propagates catalog errors when `show_data_lake_catalogs_in_system_tables = 1` instead of degrading to an empty listing. Related: ClickHouse#109724 Co-Authored-By: Claude Fable 5 <[email protected]>
…for internal create Resolve conflicts against 26.6: - Keep `getBearerToken`; the `OneLakeCatalog::getAuthHeaders` user-agent override (#108117) is not in 26.6 and is unrelated to this fix. - Drop `allow_server_credentials_in_user_queries` and `is_loading_from_existing_metadata` from the `DatabaseDataLake` constructor call; both come from #106855, which is not backported to 26.6 and whose credential restriction is deliberately left out. - Thread the existing `internal` flag from `InterpreterCreateQuery` through `DatabaseFactory` (the plumbing from 274f167, without the S3 credential restriction). Required by `lazy_init` for internal creates; both 26.6 call sites, `loadMetadata` and `RestorerFromBackup`, already set the flag. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Cherry pick #109724 to 26.6: DatabaseDataLake: Restore onelake_bearer_token, lazy init for internal create
…ken, lazy init for internal create
Resolve cherry-pick conflicts for the 26.5 backport of #109724 Kept: the `onelake_bearer_token` setting, its masking entry, the `OneLakeCatalog` bearer-token auth path (adapted to 26.5, where `access_token` is a `std::optional` rather than a `MultiVersion`), the Azure `StaticCredential` read path, the CREATE-time check for exactly one OneLake authentication method, docs and integration tests. Dropped as inapplicable to 26.5: - the `lazy_init` / `args.internal` change. 26.5 predates eager catalog initialization: `DatabaseDataLake` builds its catalog on first use in `getCatalog` for every path, including internal creates from `RESTORE DATABASE`, so there is nothing to defer. - the `OneLakeCatalog::getAuthHeaders` user-agent override and the `Documentation` argument of `registerDatabase`, neither of which exists on 26.5. The bearer-token note is still delivered via `docs/en/engines/database-engines/datalake.md`. - everything related to `s3_allow_server_credentials_in_user_queries` and `is_loading_from_existing_metadata`.
Cherry pick #109724 to 26.5: DatabaseDataLake: Restore onelake_bearer_token, lazy init for internal create
…ken, lazy init for internal create
Resolve conflicts for the 26.3 backport of #109724, keeping only the `onelake_bearer_token` half. - `RestCatalog.h`/`.cpp`: keep `getBearerToken` and the bearer-token branch of the `OneLakeCatalog` constructor; drop the `OneLakeCatalog::getAuthHeaders` override (from #108117, not backported). On 26.3 `access_token` is `std::optional<AccessToken>`, so assign it directly. - `DatabaseDataLake.cpp`: drop the lazy-init half. 26.3 predates eager catalog initialization -- the constructor only calls `validateSettings` and `getCatalog` builds the catalog on first access, so every path is already lazy. - Drop the e2e test changes: `tests/integration/test_e2e_catalogs/` and `tests/integration/helpers/catalog_manager_onelake.py` do not exist on 26.3. The resulting C++ change is identical to the merged 26.5 resolution (137209f).
Cherry pick #109724 to 26.3: DatabaseDataLake: Restore onelake_bearer_token, lazy init for internal create
…ken, lazy init for internal create
Backport #109724 to 26.5: DatabaseDataLake: Restore onelake_bearer_token, lazy init for internal create
Backport #109724 to 26.6: DatabaseDataLake: Restore onelake_bearer_token, lazy init for internal create
DatabaseDataLake: Restore onelake_bearer_token, lazy init for internal create
The parameter
onelake_bearer_tokenwas recently added (#109104) and reverted (#109597). The issue is that a node would try to create databases on startup, and if it encountered an expired token, would fail to start up. The fix is to use lazy initialization for internal creates.I have manually verified on real instances that it fixes the issue.
Changelog category (leave one):
Version info
26.7.1.754(included in26.7and later)26.6.2.159,26.5.7.2