Skip to content

Do not delete staged Iceberg files when a catalog commit outcome is unknown - #115580

Open
groeneai wants to merge 36 commits into
ClickHouse:masterfrom
groeneai:fix-iceberg-catalog-commit-state-unknown
Open

groeneai wants to merge 36 commits into
ClickHouse:masterfrom
groeneai:fix-iceberg-catalog-commit-state-unknown

Conversation

@groeneai

@groeneai groeneai commented Aug 20, 2026 •

Copy link
Copy Markdown
Collaborator

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

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_TRANSACTION with 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::updateMetadata returned false for any HTTPException, and GlueCatalog::updateMetadata threw one error code for any AWS failure. false means "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 becomes UNKNOWN_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 PARTITION commit 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, createTable and EXPIRE SNAPSHOTS are out of scope, as none deletes staged files on failure; DeltaLakeSink commits through a Delta transaction, not this interface.


Workflow [PR]
Sync PR [sync-upstream/pr/115580]

groeneai and others added 10 commits August 19, 2026 06:54
…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]>
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-review-bot PR origin: review-bot finding on a groeneai PR labels Aug 20, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review

Before opening this PR I ran the diff past an independent reviewer and a second model over
several rounds, and adjudicated every finding against the code. Verdicts below.

Finding Verdict
❌ The Glue read-back could throw instead of returning "cannot tell". readRawMetadataLocation had no exception handler, so an exception escaping GetTable reached the callers as an ordinary error and took the cleanup path, deleting the files of a snapshot that had in fact been committed. Its REST counterpart already returned "cannot tell" for exactly this case; the asymmetry was unintended. Agreed, fixed. The read-back now yields the unknown outcome for any failure, and a regression arm makes the read-back throw.
❌ No test reached the handler that real socket failures use. Every fault injection raised an HTTP-status exception, so the branch handling a plain transport exception after the request was sent was untested and could have been removed with all arms still green. Agreed, fixed. Added a post-dispatch transport fault and an arm that fails if that branch is neutered.
❌ An exception thrown by the Glue UpdateTable call itself was treated as proof of rejection. That client retries internally, so an earlier attempt may already have applied, and treating the throw as a failure deleted the committed files. Agreed, fixed. Every failed Glue outcome, thrown or returned, is now reconciled, with arms for both the applied and the unresolved case.
⚠️ A failure raised before the request was dispatched could still be reported as an unknown commit when it arrived as an HTTP exception, for example from a configured remote proxy resolver. The direction is safe, since files are kept, but it hides the actionable error. Agreed, fixed. The "nothing was dispatched" check now runs first for every exception type.
⚠️ The two branches classifying an already-dispatched commit, the 409 and the non-retryable status, were not pinned by any test. Agreed, fixed. Three mutants now cover them: deleting either branch reddens a named arm, and deleting both reddens both while the pre-dispatch arm stays green.
⚠️ REST reconciliation reads the catalog state independently of the state the commit used, so a concurrent credential change could make it read a different prefix. Disagreed. The comparison is against a snapshot id minted randomly per commit, so a read of any other table cannot match it; the only reachable outcome is a mismatch, which is the unknown verdict, and that keeps files rather than deleting them. The worst effect of the race is therefore the conservative answer. The independent state read also matches every other read path in this file.
⚠️ The S3 Tables catalog overrides the network primitive, so its commit is not proven single-attempt. Disagreed. Before this PR that line already ignored per-request settings, and the change is only the compiler-forced propagation of a new parameter to an override, so there is no behaviour here this PR could regress. There is also no S3 Tables integration harness in the repository to add an arm to.
💡 The pre-dispatch arm injects an exception that reaches the generic handler, so the HTTP-specific dispatch guard is not pinned by itself; separately, the REST read-back's exception handler is bypassed by its fault injection while the Glue twin's is exercised. Noted, not changed. Both guards are present and correct here, so neither is a live defect: each can only over-report the unknown outcome, which keeps files. They are future-regression liveness gaps, and pinning them needs new fault-injection points rather than a behaviour change.
💡 The scope note said updateSchema stages no files. On the Glue path the metadata file is in fact written before that call. Agreed, corrected in the description. The exclusion holds for a different reason: that path performs no cleanup on failure, so the defect class cannot reach it.

Session id: cron:clickhouse-review-slot-9:20260820-084000

@clickhouse-gh clickhouse-gh Bot closed this Aug 20, 2026
@clickhouse-gh clickhouse-gh Bot reopened this Aug 20, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. SYSTEM ENABLE FAILPOINT iceberg_catalog_commit_response_lost, then INSERT into a catalog-backed table on the existing REST + MinIO harness. On unmodified master the catalog advanced to snapshot 1893167076298277860 while its manifest list reported exists=False, and the following SELECT failed. Failpoint-driven, no sleeps, no polling.
b Root cause explained? Yes. The catalog commit has three possible outcomes and only two were representable. RestCatalog::updateMetadata returned false for any HTTPException and GlueCatalog::updateMetadata threw one code for any AWS failure, so a commit the catalog accepted but whose response was lost became "another writer won, retry", and the caller deleted the staged files of what was by then the current snapshot. The retry then read the parent snapshot's manifest list that the same cleanup had removed, which deleted the data files too.
c Fix matches root cause? Yes. The third outcome is restored at the seam that owns the information, instead of guarding the deletion site. Pinning the REST commit POST to one attempt removes the mechanism that made a received status meaningless (the transport retries and does not treat 409 as final, so a re-POST is rejected by the requirement the first attempt satisfied).
d Test intent preserved / new tests added? Yes. No existing test weakened or removed (zero deleted lines in either test file). Twelve new REST integration arms and six Glue arms, all asserting on object existence and table readability rather than on error text.
e Both directions demonstrated? Yes. With only the source hunks reverted (failpoints and tests kept) each arm fails for its own hunk, and the destruction signature is the chain itself: Code: 497 raised from initializeMetadata -> generateManifestList -> forEachAvroEntry, for the Glue read-back Code: 710 escaping readRawMetadataLocation -> updateMetadata -> initializeMetadata, for a throw out of UpdateTable itself Code: 710 escaping GlueCatalog.cpp -> initializeMetadata, and for a non-Poco failure after the REST request was dispatched Code: 1001 escaping updateMetadata -> initializeMetadata. The two status-based REST branches are pinned by mirror-image mutants: removing the non-retryable-status rethrow turns the 403 into Code: 659 and reddens only that arm, removing the 409 block turns the conflict into Code: 659 instead of a clean retry and reddens only that arm, and applying both reddens both while the pre-dispatch arm still passes. Neutering the Glue read-back reddens the applied-then-threw arm while its not-applied twin still passes. With the fix all eighteen pass, and every arm passes its repeated-run check.
f Fix is general across code paths? Yes. All five updateMetadata/updateSchema call sites were enumerated: the three destructive ones (INSERT, mutations, compaction) are fixed and each has an arm that reddens for its own hunk alone. ExpireSnapshotsExecute was checked rather than assumed safe: it is Glue-only, performs no cleanup on failure, and its retry loop contains no catch, so the new exception propagates and never reaches deleteExpiredFiles. Subclass coverage was re-verified by grep; the S3TablesCatalog transport override was changed in the same commit, and reverting it alone fails to compile.
g Fix generalizes across inputs? Yes. The axis is the failure shape, and each is handled explicitly: 409, a non-retryable status (400/401/403/404/405/501), a retriable 5xx, a timeout or dropped connection, a failure raised before the request reached the wire (which keeps its own error and its cleanup, since nothing can have been applied), a plain Poco::Net::NetException carrying no status at all, which is what a dropped connection actually raises, and a failure outside the Poco hierarchy such as an allocation failure while the response body is read, which no typed handler covered. The two branches that read a status off a request the catalog cannot have applied are covered separately, since a fault raised after the request is counted but before its body is written is dispatched and yet provably without effect: a 403 there keeps its own error, and a 409 there is a lost race, so the staged files are deleted and the commit retried. For Glue every failed outcome takes one path, because its client retries UpdateTable and exposes no per-request pin, so no AWS error can be shown to describe the only attempt: an exact pointer match, a differing pointer, an absent parameter, a read-back that answers nothing, a read-back that raises, and an exception thrown by the UpdateTable call itself, which the SDK's own retries make no more conclusive than an unsuccessful outcome. Nothing escapes unclassified.
h Backward compatible? Yes. No new setting, no default change, no serialization format change, so no SettingsChangesHistory.cpp entry. The two behaviour changes are deliberate and stated in the description: updateMetadata can now throw where it returned false, and Glue can return true where it threw (a verified commit).
i Invariants and contracts preserved? Yes. ICatalog::updateMetadata's signature is untouched, and its documented contract ("false on a recoverable conflict so the caller can retry, throws otherwise") is now actually honoured. Cleanup still runs on every path except the one where deletion is provably unsafe. There is no crash-durability obligation: the retained objects are ordinary object-storage files, and a retained orphan is recoverable while a deleted current snapshot is not.

Session id: cron:clickhouse-impl-slot-40:20260820-074300

@clickhouse-gh

clickhouse-gh Bot commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [ac6a56b]

Summary: ❌

job_name test_name status info comment
Finish Workflow FAIL
python3 ./ci/jobs/scripts/workflow_hooks/can_be_merged.py --review-threads FAIL

AI Review

Summary

Reviewed ac6a56bd53df28d866ef1b34902a4eba3f78110d. The change reconciles ambiguous REST and Glue catalog commits and retains staged Iceberg files when the outcome is unknown. Two paths still turn a potentially successful commit into an ordinary exception that authorizes deletion. One incomplete Glue rejection classification also remains. All findings already have inline threads; no duplicate comments were posted.

Findings

❌ Blockers

  • GlueCatalog.cpp:1081–1083: Uncertainty is lost on subsequent retry-loop exits. An UpdateTable can apply, lose its response, and have an SDK retry rejected with CONCURRENT_MODIFICATION. This sets update_may_have_landed and continues, but the next failed GetTable throws DATALAKE_DATABASE_ERROR at lines 974–979; exceptions thrown by that call and retry exhaustion at lines 1128–1131 likewise escape without preserving uncertainty. The cleanup callers can then delete the committed snapshot's files. Preserve the uncertain state across every subsequent exit and report UNKNOWN_STATUS_OF_TRANSACTION unless reconciliation establishes the outcome. Existing open thread.

  • RestCatalog.cpp:2487–2500, RestCatalog.cpp:2520–2525, and GlueCatalog.cpp:1063–1087: Allocating the failure diagnostic can authorize deletion after an accepted commit. REST constructs temporary exceptions before entering reconciliation and allocates the final unknown-status exception outside its guard. Glue copies error strings after UpdateTable may have applied and also allocates its final exception. An allocation failure at these sites escapes as an ordinary exception; the sibling handlers do not catch exceptions thrown from a handler. Cleanup then removes potentially committed files. Prepare an unknown-outcome exception before dispatch and preserve that outcome independently of diagnostic allocation. [dismissed by author -- https://github.com/Do not delete staged Iceberg files when a catalog commit outcome is unknown #115580#discussion_r4506747770] The guarded read-back preparation fixes only one allocation site; the current classification sites above remain unguarded.

⚠️ Majors

  • GlueCatalog.cpp:139–157: Some definite request rejections still become unknown commits. For example, INVALID_PARAMETER_VALUE, INVALID_PARAMETER_COMBINATION, and INVALID_QUERY_PARAMETER are non-retryable request errors in the pinned AWS error mapper, but this predicate returns false for them. When the only attempt receives one, reconciliation cannot find the uncommitted pointer, so the caller receives UNKNOWN_STATUS_OF_TRANSACTION and retains staged files unnecessarily. Complete the proven-rejection set while retaining the retry-history guard. [dismissed by author -- https://github.com/Do not delete staged Iceberg files when a catalog commit outcome is unknown #115580#discussion_r4239413464] The added credential cases do not cover these remaining request errors.
Performance & Safety

The unknown-outcome consumers checked were IcebergStorageSink::initializeMetadata and its destructor, mutation writeMetadataFiles, manifest-compaction writeConsolidatedManifestFile, and AlterDropPartitionExecutor::tryCommit. Each suppresses cleanup only for the exact UNKNOWN_STATUS_OF_TRANSACTION code, making both blocker paths destructive. Glue schema changes and snapshot expiration propagate that exception without deleting staged files; the Unity wrapper preserves it, and REST-derived catalogs, including the S3 Tables transport override, inherit the REST classification risk.

Tests
  • ⚠️ Add an accepted Glue update with a lost response, an SDK retry conflict, and a failing or throwing next GetTable. Assert that the committed manifests and data remain readable; also cover uncertain retry exhaustion.
  • ⚠️ Inject allocation failure during REST and Glue status conversion after an accepted commit, outside the read-back helper. Assert that the snapshot's files survive.
  • ⚠️ Cover a remaining definite core request error on a single Glue attempt, asserting the ordinary error and cleanup. Existing rejection arms cover access and credential errors only.
Final Verdict

Status: ❌ 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.

@groeneai

Copy link
Copy Markdown
Collaborator Author

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.

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Aug 20, 2026
Comment thread src/Databases/DataLake/RestCatalog.cpp Resolved
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]>
@clickhouse-gh

clickhouse-gh Bot commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing ac6a56bd5 with master fd41c0219 (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Object file sizes

12 object files changed (+129.35 KiB total), 0 added.

Object file Master PR Δ
src/CMakeFiles/dbms.dir/Databases/DataLake/RestCatalog.cpp.o 1.33 MiB 1.39 MiB +60.27 KiB (+4.41%)
src/CMakeFiles/dbms.dir/Databases/DataLake/GlueCatalog.cpp.o 1.13 MiB 1.17 MiB +41.65 KiB (+3.61%)
src/CMakeFiles/clickhouse_common_io.dir/Common/FailPoint.cpp.o 681.17 KiB 699.68 KiB +18.52 KiB (+2.72%)

716 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only clickhouse-bundle) and not compared.

Compile time of recompiled translation units

48 translation units recompiled, 377 s compile time in total, 48 of them have a recent master baseline.

Job report

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - cff7408

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Docker keeper image job wedged 4h55m inside apt-get update against the in-region Ubuntu mirror, then died on the 18000s job timeout (WARNING: Job timed out: [Docker keeper image], timeout [18000], exit code [-15]) #113869 (mine, open)

The 150 CIDB test_status = FAIL rows at this head are all Bugfix validation (integration tests, aarch64/amd64) with check_status = success, i.e. the intended proof that the new regression tests reproduce the bug against the pre-fix binary. They are not failures.

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.
@clickhouse-gh

clickhouse-gh Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

📊 Cloud Performance Report

✅ AI verdict: no_change — no significant changes across 39 queries analysed

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.

clickbench

⚠️ 1 inconclusive

Flagged queries (1 of 43)
Query Verdict Baseline median (ms) PR median (ms) Change q-value Hint
⚠️ 31 not_sure 302 342 +13.2% <0.0001 cache: CPU time is flat (3466.9 vs 3477.6 ms) while wall time rose +13.2%, and this PR only touches Iceberg catalog commit paths a ClickBench SELECT never runs, so this is scheduling/cache variance, not a PR effect.

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
  • StressHouse run: cfc93151-484e-4bec-a4f2-3ce71b60f087
  • MIRAI run: 8758bdee-542d-4f03-a2a1-c7449f865dec
  • PR check IDs:
    • clickbench_133225_1787543317
    • clickbench_133238_1787543317
    • clickbench_133244_1787543317
    • tpch_adapted_1_official_133256_1787543317
    • tpch_adapted_1_official_133281_1787543317
    • tpch_adapted_1_official_133295_1787543317

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.
Comment thread src/Databases/DataLake/RestCatalog.cpp Resolved
@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 68e237f

Every failure below has an owner: a fixing PR (ours or external), or a full-effort fix task whose
fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Stress test (arm_release) / STID 0250-3e49, Not-ready Set is passed as the second argument for function 'globalIn' trunk defect, not caused by this PR #112968 (external, open)

CI is fully finished at this head: 175 unique check runs, 0 incomplete, one parent workflow run
(33077587382), and Config Workflow, Style check and Finish Workflow all success. The praktika
report has 177 nodes, 0 DROPPED.

CIDB returns 156 non-green rows at this commit and only the one above is ownable. The other 154 are
Bugfix validation (integration tests, aarch64 / amd64) rows whose check_status is success: that is
the expected inversion for a bugfix PR, where the new regression test must fail against the pre-fix
binary, which is what the check asserts. The control for that query was 309,512 rows in the same window,
so the split is a measurement and not an empty read.

The owner is resolved from the stack frames rather than from the STID, because the Not-ready Set
bucket pools several distinct defects. This abort runs
FunctionIn::executeImpl (src/Functions/in.cpp:128) <- VirtualColumnUtils::filterBlockWithExpression
<- VirtualColumnUtils::getFilterByPathAndFileIndexes <- StorageObjectStorageSource::createFileIterator
<- ReadFromObjectStorageStep::createIterator, i.e. the object-storage _path / _file prune shape,
which is what #112968 ("Fix Not-ready Set for GLOBAL IN over an object-storage _path / _file filter")
changes. It is open, so it cannot already be present on this branch.

Not caused by this PR: over 30 days that sub-shape measures 58 rows across 47 distinct PRs with 6
true-master hits (a fabricated-phrase control returns 0).

Session id: cron:our-pr-ci-monitor:20260827-190000

Comment thread src/Databases/DataLake/GlueCatalog.cpp Resolved
groeneai and others added 2 commits October 10, 2026 19:58
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]>
Comment thread src/Databases/DataLake/GlueCatalog.cpp Resolved
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]>
@groeneai

groeneai commented Oct 11, 2026 •

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - a196412

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Stateless tests (arm_binary, s3 storage, DBReplicated, parallel, 1/2) / 05339_parquet_prewhere_subcolumn_read_through_column not from this PR (it changes Iceberg catalog commits only): the test passes a session temporary table to IcebergLocal, which the replicated DDL worker cannot see (UNKNOWN_TABLE on iceberg_path). 38 PRs and 20 master runs show it since 2026-10-10 21:55Z #125121 (external, merged 00:36Z), the revert of my #124685 that added this test. The tested merge commit predates it, so I will merge master here to pick it up
Performance Comparison (arm_release, master_head, 3/6) / direct_dictionary #3, #9 dashboard confirmed_regression, client_time 0.421 -> 0.488 s (+15.7%) and 0.434 -> 0.502 s (+15.6%), still +12.0% and +10.9% after the harness restarted both servers. The queries are dictGet on a DIRECT dictionary, which this PR does not touch. On arm these queries have a slow mode of the server process: they moved by more than 10% in 34 of 476 and 37 of 463 master-vs-master runs since 2026-09-15, against 5 of 1091 and 2 of 1049 before 2026-09-09, and in 0 of 932 amd runs #117018 (external, open)
Mergeable Check, PR rollups, red only because of the rows above #125121 and #117018
Sync - CH Inc sync (private, not actionable by me)

All 163 check runs completed and Finish Workflow is green. The Bugfix validation (integration tests, *) rows are the expected inversion of this PR's new tests on master (both jobs green). CIDB has no other FAIL or ERROR row on this head.

Session id: cron:our-pr-ci-monitor:20261011-030008

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - f38d83a

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Stateless tests (arm_binary, ParallelReplicas, s3 storage, parallel) / 05210_lightweight_update_materialized_cte_in_ignore not from this PR (it changes Iceberg catalog commits only): UNKNOWN_TABLE on the temporary table of a MATERIALIZED CTE (_materialized_cte_c_*) that a parallel replicas read with a local plan sends to the other replicas. 97 PRs and 17 master runs show it in 30 days, and 129 reruns with the same settings passed #123121 (mine, open)
Mergeable Check, PR rollups, red only because of the row above #123121 (mine, open)
Sync - CH Inc sync (private, not actionable by me)

All 163 check runs completed and Finish Workflow is green. The Bugfix validation (integration tests, *) rows are the expected inversion of this PR's new tests on master (both jobs green). CIDB has no other FAIL or ERROR row on this head.

Session id: cron:our-pr-ci-monitor:20261011-073009

@groeneai

groeneai commented Oct 11, 2026 •

Copy link
Copy Markdown
Collaborator Author

Fixing PR for the arm_release 3/6 perf red (direct_dictionary #3/#9): #125278 (closed unmerged: the release binaries stay PIE). A fix task is moved to pending; the fixing-PR link will follow here.

@groeneai

groeneai commented Oct 15, 2026 •

Copy link
Copy Markdown
Collaborator Author

Fixing PR for the arm_release 3/6 perf red (direct_dictionary #3/#9): #125949 Withdrawn: reds like this one were more common before PIE (PR side at least 15% slower in 1.6% of PR runs from Jul 1 to Sep 9, 0.4-0.5% since Sep 15), so PIE does not explain it. I will investigate it separately and post the result here. Per-query numbers: #125949 (comment)

@groeneai

Copy link
Copy Markdown
Collaborator Author

Result of the separate investigation I promised above: the direct_dictionary #3/#9 red on a196412 comes from #113051, not from this PR and not from the test's random keys. Since #113051 the dictionary's source query id IN (k1, ..., kN) converts every key with its own CAST, because the literal list mixes UInt8/UInt16/UInt32 and the batch path needs a single type. That made these queries about 2x slower (#115803).

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.

groeneai and others added 2 commits October 25, 2026 11:44
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]>
Comment thread src/Databases/DataLake/RestCatalog.cpp Resolved
`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]>
groeneai and others added 3 commits November 8, 2026 13:53
…-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
@clickhouse-gh clickhouse-gh Bot added comp-datalake-catalogs Data lake catalogs: the DataLakeCatalog database engine and its catalog clients - Iceberg REST, A... and removed comp-datalake Data lake table formats (Iceberg/Delta/Hudi) integration. labels Nov 19, 2026
groeneai and others added 2 commits November 23, 2026 13:58
…-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]>
Comment on lines +1080 to +1083
/// 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;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors comp-datalake-catalogs Data lake catalogs: the DataLakeCatalog database engine and its catalog clients - Iceberg REST, A... groeneai-origin-review-bot PR origin: review-bot finding on a groeneai PR pr-bugfix Pull request with bugfix, not backported by default

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants