Skip to content

Cherry pick #117584 to 26.6: Fix attach tables & total rows stats for data lakes - #120772

Merged
scanhex12 merged 19 commits into
backport/26.6/117584from
cherrypick/26.6/117584
Sep 18, 2026
Merged

scanhex12 merged 19 commits into
backport/26.6/117584from
cherrypick/26.6/117584

Conversation

@robot-ch-test-poll2

Copy link
Copy Markdown
Contributor

Original pull-request #117584

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.

Before you resolve anything

Conflicts are often caused by a prerequisite change that has not been backported yet, rather than by a real divergence. The bot re-tries this cherry-pick against the release branch on every run, so if that is the case here it will merge itself as soon as the prerequisite lands, and you will see a comment saying so. Manual resolution is only needed while the conflict persists.

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

scanhex12 and others added 18 commits September 1, 2026 21:20
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]>
`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]>
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]>
Fix attach tables & total rows stats for data lakes
@robot-ch-test-poll2 robot-ch-test-poll2 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 Sep 18, 2026
@scanhex12
scanhex12 merged commit f10e59e into backport/26.6/117584 Sep 18, 2026
@scanhex12
scanhex12 deleted the cherrypick/26.6/117584 branch September 18, 2026 10:22
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.

4 participants