Repository navigation
Fix attach tables & total rows stats for data lakes - #117584
Conversation
|
Workflow [PR], commit [4b3598e] Summary: ✅
AI ReviewSummaryThis PR defers data-lake metadata loading during Findings
Tests
Final VerdictStatus: Minimum required actions:
LLVM Coverage ReportMeasured on commit 4b3598e.
Changed lines: Changed C/C++ lines covered: 30/32 (93.75%) · Uncovered code |
The test harness runs the script directly, so without the executable bit it fails with `Permission denied` and return code 126. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The style check requires queries against `system.tables` to be constrained to a database. Both tests attach into a `Memory` database named `d`, so filter on it. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
| && (args.table_id.table_name.ends_with("_s3") || args.table_id.table_name.ends_with("_s3queue"))) | ||
| configuration->force_anonymous_load_fallback = true; | ||
|
|
||
| const bool lazy_init = args.mode >= LoadingStrictnessLevel::ATTACH; |
There was a problem hiding this comment.
ATTACH here still covers fresh user-supplied full definitions, not only metadata replay. For IcebergLocal / DeltaLakeLocal, the user_files_path guard is enforced in DataLakeConfiguration::update / lazyInitializeIfNeeded via assertLocalPathCorrect, and StorageObjectStorageConfiguration::check does not run that check. With lazy_init = true, ATTACH TABLE t (x UInt64) ENGINE = IcebergLocal('/tmp/outside') stops failing at DDL time and only gets rejected on first read.
Could we keep the local-path validation eager for fresh ATTACH queries, or restrict lazy init to replayed metadata / short-syntax ATTACH?
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units8 translation units recompiled, 24 s compile time in total, 8 of them have a recent master baseline. |
`StorageObjectStorage::totalRows` and `totalBytes` skipped the storage only when no metadata object had been created yet. For DeltaLake the metadata object exists right after `ATTACH`, while the delta-kernel snapshot state is resolved lazily, so scanning `system.tables` still built that state and read the table metadata from the storage. When the storage was gone, every scan raised one exception per table, which `StorageSystemTables` swallowed and logged, and `05056_datalake_system_tables_does_not_read_storage` counted those log lines and failed in every build. Ask the metadata whether the table state is already resolved in memory (`hasLoadedTableState`) instead of whether the metadata object exists. `04762_datalake_concurrent_metadata_update` used a `system.tables` scan to republish the metadata under `allow_experimental_delta_kernel_rs=1`; it now runs `DESCRIBE TABLE` for that, because the scan no longer loads anything. https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=117584&sha=abcbf1f01ac5b34cc3f5b0741c9905cd674721b0&name_0=PR&name_1=Stateless%20tests%20%28amd_asan_ubsan%2C%20flaky%20check%29 Related: #117584 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
| /// Whether `totalRows` and `totalBytes` are answered from memory, without reading the storage. | ||
| /// `system.tables` must never read the storage, so it reports unknown totals for the storages | ||
| /// that answer false here. | ||
| virtual bool hasCheapTotals() const { return true; } |
There was a problem hiding this comment.
hasCheapTotals() is now the only guard that keeps system.tables off storage, but this default true leaks through delegating storages. StorageAlias::totalRows / totalBytes, StorageProxy::totalRows / totalBytes (and therefore StorageTableProxy), StorageMerge::totalRows / totalBytes, and StorageBuffer::totalRows all forward to child tables without overriding hasCheapTotals(). So SELECT total_rows FROM system.tables on a wrapper around DeltaLakeLocal / IcebergLocal can still reach StorageObjectStorage::totalRows() and do the remote configuration->update() that this PR is trying to avoid.
Could we make delegating / aggregate storages forward or compose hasCheapTotals() too, or default this flag to false and opt in only the storages whose totals are guaranteed memory-only?
There was a problem hiding this comment.
The current isDataLake() guard still misses wrapper rows.
StorageSystemTables now checks only the outer storage at src/Storages/System/StorageSystemTables.cpp:945, but StorageTableProxy, StorageAlias, StorageMerge, and StorageBuffer do not forward that classification. A concrete trace is:
StorageSystemTablescallstable->totalRows(...)atsrc/Storages/System/StorageSystemTables.cpp:951because the outer wrapper reportsisDataLake() == false.StorageTableProxy::totalRowsthen forwards to the nested table once it has already been materialized (src/Storages/StorageTableProxy.h:170-175).- For a nested
Iceberg*/DeltaLake*table, that reachesStorageObjectStorage::totalRows, which still doesconfiguration->update(...)before reading totals (src/Storages/ObjectStorage/StorageObjectStorage.cpp:582-595).
So SELECT total_rows, total_bytes FROM system.tables can still touch a dead data-lake backend through a loaded proxy/alias/merge/buffer table, which is the same no-storage-access contract gap as before.
The `StorageObjectStorage` constructor resolves the table state, and for a data lake that means building the metadata: `DeltaLakeMetadataDeltaKernel` -> `S3KernelHelper` -> `S3::Client::getRegionForBucket` -> `HeadBucket`. A connection error is retryable, and the S3 client retries it 501 times with a delay growing to 5 s, so a single table whose bucket had gone away held the constructor for tens of minutes. The same constructor runs for every table the server attaches at start, which is what kept a service in "Starting" for 17 to 35 minutes. ClickHouse/support-escalation#8579 A table attached from its metadata already knows its columns, so nothing has to be read to attach it. Defer the resolution to the first use of the table, as the constructor already does for the hive partitioning sample path. Measured on a server holding one `DeltaLakeS3` table whose endpoint does not answer: start to "Ready for connections" goes from tens of minutes to 93 ms, with no request sent to the endpoint; reading the table still reports the failure. The new integration test freezes the MinIO container and restarts the server: without this change the server does not answer again and the test fails on a client timeout. `05056` covers both halves of the guarantee now (nothing is read to attach the tables, and nothing is read to list them in `system.tables`), so it is renamed after what it states. The tests it replaces used the `*Local` engines, which never build an S3 client and so never showed the retries. Related: #117584 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
`S3ReadRequestAttempts` and `S3WriteRequestAttempts` stay at zero even for a request that is really sent, so the probe passed no matter what the attach did. `S3ReadRequestsCount` and `S3ReadRequestsErrors` are the ones `PocoHTTPClient::makeRequestInternalImpl` raises, before the request goes out and again when it fails, so a refused connection is counted too; match every `S3*Request*` event to catch the write side as well. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…emory` Address review: `totalRows`/`totalBytes` already mean "cheaply known", so a new virtual claiming every storage has totals in memory is misleading. `system.tables` now simply skips the totals for data lake tables via the existing `isDataLake`. Also rename `attaching_described_table` to `is_attach`. #117584 Co-Authored-By: Claude Fable 5.1 <[email protected]>
Review of #117584: the flag does not change between the columns of one row, so read it before the loop that walks them. The startup test is skipped when the database disk is remote. That job flavour keeps the server's own metadata in the same MinIO the test pauses, so the server cannot start for a reason that has nothing to do with the table: it retries `http://minio1:9001/root-db-disk?...prefix=test-default|node1/__meta` until the start times out. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
`test_startup_with_unavailable_bucket` restarts the server with the table's object storage paused. With `CLICKHOUSE_USE_DATABASE_DISK=1` the server keeps its own database metadata on an S3 disk in the same MinIO (`helpers/remote_database_disk.xml`, bucket `root-db-disk`), so pausing MinIO stopped the start for a reason that has nothing to do with the table: S3 request to: http://minio1:9001/root-db-disk?list-type=2&max-keys=1&prefix=test-default%7Cnode1%2F__meta, aws sdk attempt: 3 S3ClientRetryStrategy: Attempt 3/501 failed with retryable error: Timeout Skipping that flavour would drop the test from half of the integration jobs. The cluster already runs Azurite, and the database disk is always in MinIO, so put the table in Azurite and pause `azurite1` instead - MinIO stays up and the test behaves the same everywhere. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
📊 Cloud Performance Report ✅ AI verdict: no significant changes detected. K_source=6 K_base=30 flagged=0/65 clickbench🟢 No significant changes tpch_adapted_1_official🟢 No significant changes Debug info
|
|
@scanhex12 @kssenii — ClickGap found the following in this PR:
Close anything that's wrong or already addressed. |
Cherry pick #117584 to 26.6: Fix attach tables & total rows stats for data lakes
…tables `system.tables` skipped `totalRows`/`totalBytes` of a data lake table with a caller-side `isDataLake()` check (ClickHouse#117584). Engines that forward those calls to another table (`Alias`, `Merge`, `Buffer`, materialized views, `StorageTableProxy`, `StorageTableFunctionProxy`) keep the `IStorage` default `isDataLake() == false`, so `system.tables` still reached `StorageObjectStorage::totalRowsInSnapshot`/`totalBytes`, which refresh the metadata from the object storage. On an unreachable bucket every `system.tables` scan paid the S3 retry budget once per wrapper table. `StorageObjectStorage` cannot tell that call apart from the ones that need the refresh (trivial `count()` through a wrapper, `DROP TABLE ... IF EMPTY`), so the caller's intent now travels on the argument every forwarder already passes through unchanged: the `ContextPtr`. The context `system.tables` reads totals with (the copy without sequential consistency, renamed `totals_context`) sets a new `Context` field, `totals_without_storage_access`. It is a field rather than a setting, like `is_automatic_parallel_replicas_probe`, so no query can set it, and the `ContextData` copy constructor keeps it. `StorageObjectStorage` and `StorageObjectStorageCluster` return `nullopt` before touching the metadata when it is set, and the `isDataLake()` checks in `StorageSystemTables` are removed, so the storage that does the I/O decides for every wrapper. Alternatives not taken: an explicit argument on `totalRows`/`totalBytes` changes ~21 storage classes for the same semantics; overriding `isDataLake()` in `StorageAlias`/`StorageMerge` misses the other wrappers and changes the engine classification policy code reads. Extends `05056` with an `Alias` + `Merge` over `IcebergS3` on a gone endpoint: master sends 40 S3 requests (MinIO), the fix sends none. Closes ClickHouse#118941 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix attach tables for data lakes. We don't need to read anything from object storage in attach query + don't provide rows stats in system tables
Workflow [PR]
Sync PR [sync-upstream/pr/117584]