Repository navigation
Conversation
…nknown A catalog-backed Iceberg write commits in two steps: write the metadata file to object storage, then point the catalog at it. At the catalog step both implementations collapsed a three-valued outcome into two values, so a commit the catalog had already accepted but whose response was lost was read as "the commit did not happen" and the caller deleted the staged files. Those files belong to the table's current snapshot, so the table became unreadable. RestCatalog::updateMetadata returned false for any HTTPException, and GlueCatalog::updateMetadata threw DATALAKE_DATABASE_ERROR for any AWS failure. Each of the three destructive call sites (INSERT, mutations, compaction) treats either outcome as a lost race and cleans up. For REST the commit POST is now single-attempt, because the transport retries by default and 409 is classified retriable, so a re-POST is rejected by the requirement the first attempt already satisfied and every outcome becomes ambiguous. With one attempt the received status describes our own request: 409 is a proven lost race, a non-retriable status is a proven rejection that keeps its original error, and anything else is reconciled against the table's main ref. For Glue UpdateTable carries no precondition, so a pointer that is not ours is equally consistent with "we never committed" and "we committed and a third writer superseded us". The read-back therefore runs first and unconditionally, and reads the raw metadata_location parameter rather than a resolved one, because the resolving path lists object storage and would match the metadata file the caller staged before the commit. Glue has exactly two outcomes now: confirmed committed, or UNKNOWN_STATUS_OF_TRANSACTION with the original AWS error chained in. An unknown outcome propagates as UNKNOWN_STATUS_OF_TRANSACTION past the cleanup handlers of all three call sites, so the files are kept. An orphaned file is recoverable; a deleted current snapshot is not. Related: ClickHouse#112081
The 404 the previous arm relied on was answered by the metadata read that runs before the commit, so updateMetadata was never reached and the arm could not distinguish the definite branch from the ambiguous one. Inject the rejection at the commit request instead, and assert the table is unchanged.
Both reach updateMetadata through their own cleanup handler, so each needs its own arm. The commit failpoints become REGULAR: they are process-global, so an unrelated commit consuming a single-shot injection leaves the arm measuring nothing. The compaction arm creates its table through ClickHouse to get its own storage prefix, because compaction resolves the parent snapshot through object storage and the shared prefix of the pyiceberg helper makes it pick up another table's metadata file.
Three arms: a lost response that the read-back confirms, a read-back that cannot resolve, and a rejection that leaves the pointer unchanged. The last one is the reason the read-back reads the raw metadata_location parameter: a helper that derives the location from object storage would find the metadata file staged before the commit and report a rejected update as applied.
Each block states the local invariant in at most three lines, without first person and without restating what the surrounding code shows.
A commit whose outcome is genuinely unknown must keep its staged files, but a failure that provably did not commit must keep its own error and let the caller clean up. Two paths conflated the two. For a REST catalog, DB::Exception derives from Poco::Exception, so the handler also caught failures raised before anything reached the catalog: minting an OAuth token, or building the request URI. Those were reported as an unknown outcome, so the actionable error was replaced and, being deterministic, every retry leaked another set of data files, manifests and manifest list. Discriminate on the ReadWriteBufferFromHTTP request counter, which is bumped on a connected socket immediately before the request is written, so an unchanged value proves nothing was dispatched. For Glue, every unsuccessful UpdateTable was reconciled, including errors AWS itself reports as final (access denied, validation). Such an error was answered definitively, so the update cannot have been applied; discriminate on AWSError::ShouldRetry(), as src/IO/S3/Client.cpp already does, and keep the original error on that path. The retryable path is unchanged. The Glue arm that asserted the opposite contract to its REST twin for the same injected fault is retargeted to the twin's contract. Co-Authored-By: Claude Fable 5 <[email protected]>
A glue UpdateTable failure that the SDK reports as non-retryable was treated as proof that nothing had been applied, so the caller deleted the files staged for the commit. That premise does not hold. The glue client installs the default retry strategy, which allows 11 attempts, and a lost response is mapped to NETWORK_CONNECTION, which the marshaller marks retryable. The SDK therefore retries after an attempt has already committed, and a later attempt can answer ConcurrentModificationException, which is non-retryable. Deleting on that outcome destroys the manifests of a snapshot that did take effect. Neither escape hatch is available: the converting move constructor that yields the model outcome does not copy the retry count, so it always reads zero here, and no per-request retry override exists. Every failed outcome is reconciled against the raw metadata_location again, so the function has two results: true when the pointer is confirmed to be ours, or UNKNOWN_STATUS_OF_TRANSACTION with the original AWS message chained in. Only the REST catalog can preserve a definite rejection, because it pins the commit POST to a single attempt. The glue arm asserting the opposite contract is restored to its original name and expectation, and its docstring records why the two catalogs differ.
…ck cannot answer Three failure paths still reached the callers' destructive cleanup carrying an error code that reads as a proven failure. Glue: readRawMetadataLocation had no exception handler, so anything thrown by GetTable escaped as an ordinary exception. The AWS SDK layers between the call and ClickHouse's own HTTP client contain no handler of their own, and PocoHTTPClient rethrows DB::Exception verbatim, so a redirect check, a redirect-count overrun, an auth failure or a memory-limit hit propagates. A read attempted to establish that a lost-response commit did land would then destroy that commit's files. The REST read-back already returned nullopt for the same reason; Glue now matches it. REST: the plain Poco::Exception handler is what a connection dropped mid-commit arrives in, since doWithRetries rethrows Poco::Net::NetException verbatim and the commit allows one attempt. No test reached it, so it could be removed without any arm failing. Also hoist the never-dispatched guard into the HTTPException handler, so a failure raised before the request was sent keeps its own error whatever type reports it. New failpoints and arms cover all three, and the Glue arms now execute locally. Co-Authored-By: Claude Opus 5 <[email protected]>
Both catalogs left one path where a failure of an already dispatched commit reached the caller as its own error rather than as an unknown outcome, and the three destructive callers read any other error as a proven rejection and delete the files staged for a snapshot that may already be the table's current one. Glue reconciled only a returned unsuccessful outcome. The AWS call itself can throw instead: PocoHTTPClientFactory is installed as the global AWS HTTP client factory, and PocoHTTPClient::MakeRequest rethrows DB::Exception verbatim and converts other types into one, with no handler anywhere between it and the caller. Such a throw says no more about whether the update applied than an unsuccessful outcome does, because the SDK may already have retried an attempt that landed, so it is now the same unknown outcome. The REST commit had handlers for DB::HTTPException and Poco::Exception, which between them cover every DB and Poco type but not the rest of std::exception. An allocation failure while the response body is read arrives that way, and the transport's retry loop does not absorb it either. A catch-all classifies it, keeping the pre-dispatch rethrow first so a failure that never reached the wire still keeps its own error and its cleanup. Three integration arms, one per new failure shape, each of which reddens when its own hunk is reverted. Co-Authored-By: Claude Fable 5 <[email protected]>
The two post-dispatch REST branches and the applied-then-threw glue branch had no arm, so nothing held them to their contract. A fault injected after the request is counted but before its body is written gives a status on a dispatched attempt the catalog cannot have seen. The 403 arm now uses that seam, which is what makes its "the table is unchanged" assertions true rather than pinning the data loss they would otherwise describe: a fault raised after the body is on the wire is a commit that did apply. A new 409 arm fires once at the same seam, so the retry that follows must commit normally and the lost attempt's manifest list must be gone, covering the one branch where deleting the staged files is correct. The glue throw is armed after UpdateTable returns, where the update has applied and only the read-back can resolve it, so the insert must succeed. Its twin covering the not-applied direction is unchanged. Co-Authored-By: Claude Fable 5 <[email protected]>
Internal second-model reviewBefore opening this PR I ran the diff past an independent reviewer and a second model over
Session id: cron:clickhouse-review-slot-9:20260820-084000 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-40:20260820-074300 |
|
Workflow [PR], commit [ac6a56b] Summary: ❌
AI ReviewSummaryReviewed Findings❌ Blockers
Performance & SafetyThe unknown-outcome consumers checked were Tests
Final VerdictStatus: ❌ Block Preserve uncertain commit state across Glue retry-loop exits and allocation failures in both catalogs, add the focused regression coverage above, and complete Glue's definite-rejection classification. |
|
cc @SmitaRKulkarni @arsenmuk, could you review this? A catalog commit that was accepted but whose response was lost read as "another writer won, retry", so the caller deleted the staged files of what had become the table's current snapshot; the commit is now pinned to one attempt so a received status is meaningful, an unresolvable outcome is reported as UNKNOWN_STATUS_OF_TRANSACTION, and the three cleanup handlers skip that case. |
clang-tidy's google-default-arguments forbids a default argument on a virtual or override method: a derived override may declare a different default, so which one applies depends on the static type at the call site rather than on the dynamic type. Build (arm_tidy) runs clang-tidy with -warnings-as-errors, so the default on the new `read_settings` parameter failed the build at RestCatalog.h:227, S3TablesCatalog.h:60 and both out-of-line definitions. Drop the default and pass `std::nullopt` at the six call sites that relied on it; the commit path keeps passing `commit_read_settings`. This is what the sibling virtual `createReadBuffer` in the same header already does, for the same reason. Verified by running the CI check locally with clang-tidy-22 on the three flagged translation units: no diagnostics with this change, and restoring only the two header defaults reproduces the three CI errors at the same file:line. Co-Authored-By: Claude Fable 5 <[email protected]>
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Object file sizes12 object files changed (+129.35 KiB total), 0 added.
716 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only Compile time of recompiled translation units48 translation units recompiled, 377 s compile time in total, 48 of them have a recent master baseline. |
CI finish ledger - cff7408Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
The 150 CIDB Session id: cron:our-pr-ci-monitor:20260820-210000 |
Resolves one content conflict in RestCatalog::updateMetadata, where master's Snowflake Horizon support (ClickHouse#114547) rewrote the same catch (HTTPException) block this branch replaces. Master's rewrite kept 409 returning false and made every other HTTP failure throw a wrapped DATALAKE_DATABASE_ERROR instead of returning false. This branch's classification is a strict superset of that intent: an undispatched request rethrows its own error, a 409 returns false, a non-retryable status rethrows, and only a dispatched retryable failure is classified against a read-back of the main ref. The single behavioural difference is the case the branch exists to fix, where the read-back proves the snapshot did commit and master would report a failure for a commit that took effect. The rest of master's changes to the function auto-merged and are kept: the unconditional assert-ref-snapshot-id requirement, the explicit Content-Length on catalog commits, the X-Iceberg-Access-Delegation header and the request body trace. HorizonCatalog inherits updateMetadata and sendRequest unchanged, so the new read_settings parameter needs no adjustment there.
|
📊 Cloud Performance Report ✅ AI verdict: This PR only changes Iceberg catalog commit reconciliation (Glue/REST write paths and fault-injection tests) — code a ClickBench SELECT never executes. clickbench Q31 shows a +13.2% wall-time delta but its CPU time is essentially unchanged (3466.9 vs 3477.6 ms) and its median (342 ms) sits inside master's normal variance band (149–461 ms), so the math correctly left it as not_sure. Treat Q31 as run-to-run variance, not a regression from this change. clickbenchFlagged queries (1 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
|
Two conflicts, both additive: master's getIdentityPartitionColumnValues and
this branch's isCommitStateUnknown were appended at the same anchor in
Iceberg/Utils.{h,cpp}. Both sides kept, master's first.
src/Common/FailPoint.cpp auto-merged; all of master's failpoint entries are
present alongside the twelve this branch adds.
CI finish ledger - 68e237fEvery failure below has an owner: a fixing PR (ours or external), or a full-effort fix task whose
CI is fully finished at this head: 175 unique check runs, 0 incomplete, one parent workflow run CIDB returns 156 non-green rows at this commit and only the one above is ownable. The other 154 are The owner is resolved from the stack frames rather than from the STID, because the Not caused by this PR: over 30 days that sub-shape measures 58 rows across 47 distinct PRs with 6 Session id: cron:our-pr-ci-monitor:20260827-190000 |
Co-Authored-By: Claude Opus 5.5 <[email protected]>
A glue UpdateTable that the service refused on its only attempt, for example with AccessDeniedException, was reported as UNKNOWN_STATUS_OF_TRANSACTION, so the caller kept the files staged for a commit that cannot have applied and the user saw an "unknown outcome" error for a permission problem. The model outcome does not carry the retry count, but the SDK calls the request's retry handler before every retry, so the function now records whether the request was retried. A failure answered on the only attempt with an error that proves glue refused the request (access denied, validation, invalid input, entity not found, concurrent modification, resource limit) keeps the original DATALAKE_DATABASE_ERROR, and the caller cleans up. Neither the SDK's retryability flag nor the HTTP status can make this decision: glue's error mapper marks every glue error non-retryable, including InternalServiceException (HTTP 500), and OperationTimeoutException and the federation source errors come with HTTP 400 although they may follow an applied update. Every error outside the list stays unknown. The rejection arm now asserts the original error and the removed manifest list. Two new arms assert that a rejection after a retry and a timeout remain unknown with the staged files kept. Co-Authored-By: Claude Opus 5.5 <[email protected]>
DROP PARTITION became catalog-backed on master after this branch added the UNKNOWN_STATUS_OF_TRANSACTION outcome, and its executor removes the staged manifest list on every exception from the commit. When the catalog did apply the commit, that file is the manifest list of the table's current snapshot, so the table becomes unreadable. Skip the cleanup for an unknown outcome, as the INSERT, mutation and compaction commits already do. The new REST arm loses the response and the read-back. It fails on the previous head with the current snapshot's manifest list deleted, and passes with this change. Co-Authored-By: Claude Opus 5.5 <[email protected]>
AWS authenticates a request before Glue processes it, so a signature, access key, client token or missing token error on the only attempt means the update was never applied. Keep such failures as an ordinary `DATALAKE_DATABASE_ERROR` and let the caller clean up the staged files, as master did, instead of reporting `UNKNOWN_STATUS_OF_TRANSACTION`. The injection failpoints now share one optional error type, and the new `iceberg_catalog_commit_auth_rejected` adds an `UNRECOGNIZED_CLIENT` arm to the definite rejection test. Co-Authored-By: Claude Opus 5.5 <[email protected]>
CI finish ledger - a196412Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
All 163 check runs completed and Session id: cron:our-pr-ci-monitor:20261011-030008 |
…-commit-state-unknown
CI finish ledger - f38d83aEvery failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
All 163 check runs completed and Session id: cron:our-pr-ci-monitor:20261011-073009 |
|
|
|
Result of the separate investigation I promised above: the On arm the cost of that part differs between server processes. In this job every direct-dictionary query, including the complex-key ones whose keys are deterministic, was 5-18% slower on the same server, while the rest of the shard was flat (geomean 1.002). The first restart drew the other server slow (#5 0.455 vs 0.410 s), the second this one again. In PR runs up to September 9, #3/#5/#9 had a side at least 15% slower in 4 of 19,836 runs where both builds predate #113051, and in 896 of 9,449 runs where both include it. Fixing PR: #117018 (external, open). It converts the keys without a CAST; in its own arm runs #3 and #9 took 0.46-0.53 of master's time. I updated the owner of this row in the ledger above. |
Since the HTTP client writes request bodies through `HTTPRequestBodyWriteBuffer` (ClickHouse#116222), the body leaves only when `callImpl` finalizes the buffer after the callback returns, and the buffer's destructor cancels rather than flushes. A throw inside the callback after the body is written therefore never reaches the catalog; on the `std::iostream` path the stream destructor still wrote the buffered request out while unwinding. Measured on the merged tree: `test_catalog_commit_transport_failure_unknown_keeps_files` and `test_catalog_commit_std_exception_unknown_keeps_files` failed with `assert '2' == '3'`, and the REST catalog logged no commit after the injected failure. They now inject once the response has arrived (`..._response_lost_net`, `..._response_lost_std`), as their confirming twins already do, so the commit lands and the unresolved read-back must keep its files. The catalog log shows the commit applied in both arms. `iceberg_catalog_commit_std_throw` has no user left and is removed. The comment at `request_body_written` and the refused arm's description now state what the new transport does; the flag itself stays where it is, which is conservative. Mutant: the no-status handlers rethrow the original error when the read-back cannot confirm the snapshot -> exactly the two re-pointed arms and the refused arm fail, the other 16 commit arms pass. Co-Authored-By: Claude Opus 5.5 <[email protected]>
`tableHasSnapshot` runs after a commit whose response was lost, so any exception it lets escape replaces the UNKNOWN_STATUS_OF_TRANSACTION outcome and the caller then deletes the files of a snapshot that may be current. The catalog state and the endpoint were prepared before the `try`, so a failure while building them escaped. Prepare them inside it, after the read-back fault injection, the same shape the Glue read-back already has. Measured: with the read-back fault injection moved back to where the endpoint used to be built (before the `try`), test_catalog_commit_readback_failure_keeps_files fails with FAULT_INJECTED reaching the INSERT instead of UNKNOWN_STATUS_OF_TRANSACTION. With this change the REST commit, drop partition and drop table arms pass (37/37). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…-commit-state-unknown # Conflicts: # src/Databases/DataLake/RestCatalog.cpp
Master's ClickHouse#127275 made `~IcebergStorageSink` remove the written data files and manifests whenever the insert did not commit. When the catalog commit fails with an unknown outcome, `initializeMetadata` already skips its own cleanup, but the exception leaves `committed` false, so the destructor then deleted the files of a snapshot that may be the table's current one. Measured on the merged tree: the Glue arms `test_glue_commit_unknown_keeps_files` and `test_glue_commit_read_back_raising_keeps_files` failed with `S3_ERROR ... key does not exist ... metadata/<uuid>.avro`. The REST arms stayed green only because they asserted `count()`, which Iceberg answers from the snapshot summary without opening the manifests or data files. They now count through `WHERE NOT ignore(*)`, and on the unfixed binary the four INSERT unknown-outcome arms fail with the same missing-manifest error; DELETE, OPTIMIZE and DROP PARTITION have no such destructor and stayed green. The unknown branch now sets `committed`, whose meaning becomes "is, or may be, committed". Co-Authored-By: Claude Opus 5.5 <[email protected]>
…-commit-state-unknown # Conflicts: # src/Storages/ObjectStorage/DataLakes/Iceberg/Utils.cpp
…-commit-state-unknown Master's ClickHouse#126924 rewrote the Glue commit into a VersionId-guarded loop. The unknown-outcome handling is re-applied inside it: a proven rejection keeps the old error and cleanup, and any other UpdateTable failure reads the pointer back before reporting UNKNOWN_STATUS_OF_TRANSACTION. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…t upon `GlueCatalog::commitTableUpdate` sets `update_may_have_landed` once an SDK-retried `UpdateTable` was refused for a stale `VersionId`: an earlier attempt may have applied it. When the next read finds a pointer that is neither ours nor built directly on ours, it threw DATALAKE_DATABASE_ERROR "Unknown outcome of commit", which the INSERT, mutation, compaction and DROP PARTITION callers read as a proven failure and clean up. If our attempt had landed, that deleted files the table references. It now throws UNKNOWN_STATUS_OF_TRANSACTION, which they skip. The new arm reproduces it with the fault proxy's VersionId check: on the binary without this change the INSERT fails with DATALAKE_DATABASE_ERROR and its manifest list is deleted. Co-Authored-By: Claude Opus 5.5 <[email protected]>
| /// A rejected single attempt did not land; after an SDK retry the rejection may come from our own landed attempt. | ||
| update_may_have_landed = update_may_have_landed || request_retried; | ||
| LOG_DEBUG(log, "Glue table {}.{} was modified concurrently, retrying commit of {}", namespace_name, table_name, new_metadata_path); | ||
| continue; |
There was a problem hiding this comment.
[Blocker] Preserve an uncertain commit across the next retry iteration
After an SDK retry returns CONCURRENT_MODIFICATION, update_may_have_landed becomes true and this continue starts another iteration. However, the next GetTable at lines 974–979 still throws DATALAKE_DATABASE_ERROR if it fails. A successful UpdateTable whose response was lost, followed by a rejected SDK retry and an unavailable reconciliation read, therefore reaches IcebergStorageSink::initializeMetadata as an ordinary failure. It runs cleanup(false), and the sink destructor removes the committed data files and manifests. Mutations, manifest compaction, and partition drops likewise run their cleanup. The loop-exhaustion exception at lines 1128–1131 also ignores the uncertainty flag.
Once any attempt may have landed, preserve that state across every subsequent exit, including failed/thrown GetTable calls and retry exhaustion, and report UNKNOWN_STATUS_OF_TRANSACTION unless the outcome is established. Add a focused regression where the update applies, its response is lost, the SDK retry conflicts, and the following GetTable fails; the committed snapshot must remain readable.
There was a problem hiding this comment.
Agreed: after a possibly landed attempt, a failed or thrown GetTable and retry exhaustion still end in an ordinary error, unchanged from master's loop. I am leaving these exits to #131575, which already reports them as UNKNOWN_STATUS_OF_TRANSACTION (files_may_be_referenced), rather than adding a second, conflicting version of the same change here.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed data loss on catalog-backed Iceberg tables when a write's catalog commit was accepted but its response was lost: the staged files of what had become the table's current snapshot were deleted, leaving the table unreadable. The catalog step now confirms the outcome first, and one it cannot establish is reported as
UNKNOWN_STATUS_OF_TRANSACTIONwith the files kept.Description
Related: #112081
Related: #115390
What breaks. On 26.8, an Iceberg catalog commit that was accepted but whose response was lost read as "the commit did not happen", so the caller deleted the staged files of the table's new current snapshot, leaving the table unreadable. #115390 fixes the storage half of #112081.
Root cause.
RestCatalog::updateMetadatareturnedfalsefor anyHTTPException, andGlueCatalog::updateMetadatathrew one error code for any AWS failure.falsemeans "another writer won, retry", and every destructive call site cleans up on it, so a third outcome, "cannot tell", had nowhere to go.The change. The REST commit POST becomes single-attempt, because a re-POST is refused by the requirement the first attempt satisfied, making every status ambiguous. A 409 is then a proven lost race; a non-retryable status, and any failure raised before the transport took the request, keep their error and their cleanup; anything else reconciles against the table's snapshot list. Glue keeps its error and cleanup only when AWS refused the only attempt with an authentication, access, validation, missing-table or limit error (the request's retry handler records SDK retries); any other failure, a timeout or an internal error included, reconciles against the raw
metadata_location, as the derived one matches the staged file. Only an unresolved outcome becomesUNKNOWN_STATUS_OF_TRANSACTION, which the cleanup handlers skip.Validation and scope. Eighteen REST and ten Glue integration arms cover the insert, delete, compaction and
DROP PARTITIONcommit paths, asserting that files exist and tables read. Reverting the reconciliation, its read-back guard, single-attempt pin, unsent-body guard, 409 branch, non-retryable branch, the Glue refusal list or retry check, or a cleanup guard each reddens a named arm.updateSchema,createTableandEXPIRE SNAPSHOTSare out of scope, as none deletes staged files on failure;DeltaLakeSinkcommits through a Delta transaction, not this interface.Workflow [PR]
Sync PR [sync-upstream/pr/115580]