Repository navigation
Report Iceberg REST catalog schema update errors instead of retrying them - #102194
RinChanNOWWW wants to merge 42 commits into
Conversation
|
cc @scanhex12 |
|
Workflow [PR], commit [143c054] Summary: ✅
AI ReviewSummaryThe PR reports non-conflict Iceberg REST catalog errors, prevents HTTP replay of catalog writes, and preserves snapshot files after an uncertain commit. Reviewed head Missing context / blind spots
ClickHouse-Specific Rule NotesThe separate, pre-existing Final VerdictStatus: ✅ Approve |
|
The flaky check failure is fixed in #102148, let's update the branch. |
|
Dear @scanhex12, you haven't been active on this PR for 30 days. You will be unassigned. Will you continue working on it? If so, please feel free to reassign yourself. |
…TTPError After merging master, the retriable-error helper that this PR refactored into the member function `ReadWriteBufferFromHTTP::isRetriableError` no longer matched master: master had centralized the non-retryable status list into the shared free function `isRetriableHTTPError` (in `HTTPCommon`), and `doWithRetries` now calls that. As a result the member `isRetriableError` (which also consulted `custom_non_retryable_errors`) became dead code, and the custom set passed via `withCustomNonRetryableError` had no effect - so `createNamespaceIfNotExists` would still retry a `409 Conflict` 10 times, defeating the purpose of this PR. Remove the now-dead member `isRetriableError` and instead consult `custom_non_retryable_errors` directly at the retry decision in `doWithRetries`, alongside the centralized `isRetriableHTTPError`. The `custom_non_retryable_errors` member, constructor parameter, builder field and `withCustomNonRetryableError` setter are preserved. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…W_STD_CONTAINERS The style check for src/IO forbids bare std containers; annotate the new `custom_non_retryable_errors` declarations, matching the existing convention used for `response_headers` and `cookies` in the same file. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
`test_create_tables_under_same_namespace` only counted the `already exists, skipping creation` debug lines. That count is also nine with the old code, because `createNamespaceIfNotExists` logs it after `sendRequest` has already exhausted its HTTP retries, so the test passed even when the `409 Conflict` was still retried `http_max_tries` times (as pointed out in review). Assert the retry layer directly instead: give each `CREATE TABLE` its own query id and compare the per-query `ProfileEvents['ReadWriteBufferFromHTTPRequestsSent']`. Every `CREATE` sends the create-namespace request exactly once, so the counts must stay flat; a returning regression would inflate the nine reuse `CREATE`s by `http_max_tries - 1` requests each. Co-Authored-By: Claude Opus 4.8 (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
|
# Conflicts: # src/Databases/DataLake/RestCatalog.cpp # tests/integration/test_database_iceberg/test.py
…Exists` `createNamespaceIfNotExists` used to log and ignore every failure of the `POST /namespaces` request. `HTTP_CONFLICT` is the only status that means "the namespace is already there", i.e. the outcome the method asks for; anything else (`401`, `500`, a malformed response body, a transport error) leaves it unknown whether the namespace exists. Swallowing those made `CREATE TABLE` continue as if namespace creation had succeeded, so the real problem surfaced later as a confusing table-creation error - or not at all. Now only `HTTP_CONFLICT` is consumed and every other exception propagates, which aborts `CREATE TABLE` at the point where it actually went wrong. Added the failpoint `rest_catalog_create_namespace_http_error` and the integration test `test_create_table_namespace_creation_error`, which checks that a non-conflict error from the namespace request fails `CREATE TABLE` instead of being hidden.
…9` in `updateSchema` `HTTP_CONFLICT` is already in the shared non-retriable set of `isRetriableHTTPError` since ClickHouse#119238, so threading `{HTTP_CONFLICT}` through `BuilderRWBufferFromHTTP::withCustomNonRetryableError` into `RestCatalog::sendRequest` changed nothing. Remove that hook. `RestCatalog::updateSchema` returned `false` for every `HTTPException`, which the `ALTER` loop in `Mutations.cpp` treats as an optimistic-concurrency conflict, so a `401`, `500` or malformed catalog response was retried until the query failed with "Too many unsuccessed retries to alter iceberg table". Return `false` only for `409` and rethrow anything else, mirroring `updateMetadata`. Add a failpoint and an integration test for the non-conflict path. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 Merged |
# Conflicts: # tests/integration/test_database_iceberg/test.py
`ReadWriteBufferFromHTTP` retried retriable `HTTPException` / `NetException` for every catalog request, including the non-idempotent `POST` commits. If the catalog applied a commit and only the response was lost, the replayed commit got `409 Conflict`, which `updateSchema` reports as a concurrent change, and `ALTER TABLE ADD COLUMN` was rebuilt against the already updated schema and failed with `Column ... already exists`. Requests other than `GET` and `HEAD` are now sent with `http_max_tries = 1` in both `RestCatalog::sendRequest` and `S3TablesCatalog::sendRequest`, so the original error is reported. The new `rest_catalog_lose_request_response` failpoint breaks the connection after the whole request has been sent, which is a retriable error at the HTTP layer. Without the fix, the new test fails with `Column y already exists`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Conflict in `RestCatalog::sendRequest`: master switched `OutStreamCallback` from `std::ostream` to `WriteBuffer`; the `rest_catalog_lose_request_response` failpoint now finalizes the `WriteBuffer` before throwing.
…is unknown Since mutating REST catalog requests are sent only once, a commit whose response is lost surfaced as a plain network error, and the callers of `updateMetadata` (`INSERT`, mutations, manifest compaction, `DROP PARTITION`) took it for a rejected commit and deleted the data files, manifests and the manifest list, although the catalog may have published a snapshot that references them. `RestCatalog::updateMetadata` (and `S3TablesCatalog`, which inherits it) now reports a network failure or a `5xx` answer, which the REST catalog specification defines as "commit state unknown", with the new error code `DATALAKE_CATALOG_COMMIT_STATE_UNKNOWN`. The callers keep the written files in that case and only clean up after a definitive rejection. Leftover files of a commit that was not applied are orphans, which is safe. Add an integration test: an `INSERT` whose commit response is lost reports the unknown outcome and its rows remain readable. Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # src/Databases/DataLake/RestCatalog.cpp # src/Storages/ObjectStorage/DataLakes/Iceberg/IcebergWrites.cpp
|
🕵 Merged The previous |
…mit state is unknown `IcebergStorageSink::initializeMetadata` skipped the local cleanup on `DATALAKE_CATALOG_COMMIT_STATE_UNKNOWN`, but `committed` stayed `false`, so `IcebergStorageSink::~IcebergStorageSink` still called `removeDataFilesAndManifests` and deleted the manifests that the catalog may already have published. This is what made `test_writes_insert_lost_commit_response` fail with `The specified key does not exist` when reading the table afterwards. Mark the files as committed in that state. https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=102194&sha=latest&name_0=PR ClickHouse#102194 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Conflicts: - `src/Common/ErrorCodes.cpp`: `1027` is now `AMBER_ERROR`, so `DATALAKE_CATALOG_COMMIT_STATE_UNKNOWN` moves to `1028`. - `src/Databases/DataLake/ICatalog.h`: keep the new `updateMetadata` signature from `master` together with the comment about the unknown commit state. - `AlterDropPartitionExecutor.cpp`: keep the statistics file written on `master` and the handling of the unknown commit state around `commitMetadataJSON`. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…rites_insert_lost_commit_response` The `rest_catalog_lose_request_response` failpoint throws right after the request body is flushed, before the response is read, so the catalog may still be applying the commit when the `INSERT` fails. The following `SELECT` could then read the previous snapshot. Wait until the catalog reports the new snapshot before checking the rows, and assert that exactly one snapshot was added, which also shows that the commit was not replayed. The failure is still injected inside the HTTP retry path. Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
📊 Cloud Performance Report
PR verdict: not_sure. 5 measured difference(s) not attributable to this PR. clickbench Q16: The measured difference cannot be attributed to this PR from the available source evidence. The pinned test merge 573034b9 against its first parent 560f2ed5 only touches src/Databases/DataLake/RestCatalog.cpp (sendRequest, createNamespaceIfNotExists, updateMetadata, updateSchema), src/Databases/DataLake/S3TablesCatalog.cpp, Iceberg write and cleanup paths (IcebergWrites.cpp, Mutations.cpp, Compaction.cpp, AlterDropPartitionExecutor.cpp), a new error code, failpoint registrations and integration tests. The query is a plain aggregation over the MergeTree hits table and calls none of these … clickbench Q18: The measured difference cannot be attributed to this PR from the available source evidence. Same pinned patch (573034b9 vs first parent 560f2ed5): it only changes DataLake catalog request and retry handling in src/Databases/DataLake/RestCatalog.cpp and S3TablesCatalog.cpp, plus Iceberg write cleanup. A GROUP BY UserID, minute, SearchPhrase over the MergeTree hits table runs none of it. No inherited cause was verified. clickbench Q28: The measured difference cannot be attributed to this PR from the available source evidence. The pinned patch for 573034b9 against 560f2ed5 is limited to Iceberg and DataLake catalog commit semantics: RestCatalog::updateMetadata and updateSchema, getReadSettingsForRequest in src/Databases/DataLake/RestCatalog.cpp, and cleanup guards in the Iceberg write paths. The query runs REGEXP_REPLACE, AVG and MIN over the MergeTree hits table, which touches none of these files. The master-side cause was not verified. clickbench Q33: The measured difference cannot be attributed to this PR from the available source evidence. The pinned test merge 573034b9 changes only src/Databases/DataLake/RestCatalog.cpp, S3TablesCatalog.cpp, ICatalog.h, the Iceberg write, mutation, compaction and drop-partition cleanup paths, ErrorCodes.cpp and FailPoint.cpp registrations, and tests. String-key hash aggregation over the MergeTree hits table reaches none of them. No inherited master change was verified. clickbench Q34: The measured difference cannot be attributed to this PR from the available source evidence. Same pinned patch (573034b9 vs 560f2ed5): it is limited to DataLake and Iceberg catalog request, retry and cleanup logic in src/Databases/DataLake/RestCatalog.cpp and related Iceberg files. GROUP BY 1, URL over the MergeTree hits table does not execute any of it. The cause of the shift was not verified. clickbenchFlagged queries (6 of 43)
Change = percent below ×2; the ratio of medians (×N faster/slower) beyond, where percent understates the scale. q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on. tpch_adapted_1_official🟢 No significant changes Debug info
|
Make Iceberg REST catalog requests fail fast and report the real error instead of masking it.
Originally this PR made the HTTP client stop retrying
409 ConflictwhenRestCatalog::createNamespaceIfNotExistscreates a namespace that already exists (eachCREATE TABLEin an existing namespace took tens of seconds). That part has since landed onmasterin #119238 (409is now in the shared non-retriable set ofisRetriableHTTPError), so the PR is re-scoped to what remains:RestCatalog::updateSchemareturnedfalsefor everyHTTPException, which theALTERloop inMutations.cpptreats as an optimistic-concurrency conflict. So a401,500or malformed catalog response was retried until the query failed withToo many unsuccessed retries to alter iceberg table, hiding the real catalog error. Now only409returnsfalse; anything else is rethrown, as inupdateMetadata.GET/HEAD(commits, create, drop) are no longer replayed by the HTTP layer (http_max_tries = 1) inRestCatalogandS3TablesCatalog. A replayed commit whose first attempt succeeded but lost its response got409 Conflict, soALTER TABLE ADD COLUMNwas rebuilt against the already updated schema and failed withColumn ... already exists.5xxanswer toupdateMetadatais reported asDATALAKE_CATALOG_COMMIT_STATE_UNKNOWN.INSERT, mutations, manifest compaction andDROP PARTITIONthen keep the files they wrote instead of deleting files that a published snapshot may reference.createNamespaceIfNotExistslogs when the409"namespace already exists" answer is consumed.CREATE TABLEin an existing namespace not being retried, the conflicting namespace creation being consumed in a single attempt, a non-conflict namespace creation error abortingCREATE TABLE, a non-conflict schema update error reaching the user, a schema update commit whose response is lost not being replayed, and a committedINSERTwhose response is lost staying readable.Related: #119238
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
ALTER TABLEon anIcebergtable in a REST catalog now reports the catalog's error (for example an authentication or server error) instead of retrying the schema update until it fails withToo many unsuccessed retries to alter iceberg table. Only a409 Conflictfrom a concurrent schema change is retried, and catalog commits are no longer resent at the HTTP layer after a lost response.Documentation entry for user-facing changes
Workflow [PR]
Sync PR [sync-upstream/pr/102194]