Repository navigation
Conversation
The conditional write of v<N>.metadata.json is a compare-and-swap, and writeMetadataFileAndVersionHint reported every failure of it except a backend refusal as false. Callers read false as "my commit did not land" and delete the files they staged. But a response lost after the object store already accepted the object is indistinguishable, at the error, from another writer having taken the version, so that cleanup deletes the manifest list, the manifest entries and (on the INSERT path) the data files belonging to the snapshot the write has just made current. Every subsequent read then fails to resolve the manifest list and the table is unreadable. The Iceberg specification names this state CommitStateUnknown and requires the writer not to clean up. false asserts that the commit did not happen; the code could only establish that the failure was retryable. Those are different claims and only the first licenses a cleanup. Establish which one holds by reading the target back and comparing it to what was written, rather than inferring it from the error: identical content means the commit took effect, a different document means a genuinely lost race, and an absent or unreadable target means the outcome cannot be established. The last case throws UNKNOWN_STATUS_OF_TRANSACTION, because a failed conditional write is not cancelled server-side and there is no ordering fence, so absence does not prove the write will not land; a short retry bounds that window. Reconciliation runs only when the write was actually attempted, so a failure of the preceding existence probe keeps reporting a lost race, which is correct there because nothing was written. Classifying the error instead was rejected: a 412 arrives as a generic S3Exception whose AWS code is private, the four backends that implement the condition would each need their own taxonomy, and any error left unclassified would silently default into one of the two buckets. All five callers of the commit share this seam. The three that delete staged files while unwinding now let a commit-state-unknown exception pass through untouched, since those files may be the ones the current snapshot references. The post-commit version-hint convergence is also brought inside a handler. Its existence probe, hint read and version parse ran unguarded after the commit had landed, so a transient failure or a malformed hint file propagated into the same cleanup handlers and destroyed a snapshot that was already current, without any lost response being involved. Closes: ClickHouse#112081
Advancing version-hint.text runs after the metadata file is already durable, so every failure there is logged and swallowed: escalating would send a committed snapshot into the callers' cleanup handlers. The loop that does it inherited a 1000 attempt bound from the commit retry it used to sit next to, which is the wrong bound now that the read and the parse of the stored hint happen inside it. Content that names no metadata version fails identically however many times it is re-read, so it is reported once and the loop stops; only a lost write race and a transient read are retried, and a handful of attempts resolve both. Measured on a hint holding unparseable content: one warning, against 1000 exceptions and 1000 stack traces for a single INSERT before this change. Extend the test to the two paths whose guards nothing reached. Manifest compaction commits through the same seam and unwinds through its own handler, so it gets both a committed and an unestablished arm; reverting just the compaction guard now reddens the second one and leaves the INSERT and DELETE arms green. The version hint failure needs no failpoint at all, which makes the second data loss path this fix closes reproducible from a plain corrupt hint file. Assert the data files themselves. count() on an Iceberg table is answered from the manifests' record_count without opening a data file, so it reported the right number on a table whose Parquet files had all been deleted; the arms now also sum a column and compare the stored file count against an exact expected number rather than against the count before the operation, which a single survivor satisfied.
The three isCommitStateUnknown guards were not symmetrically covered. Entering one requires writeMetadataFileAndVersionHint to throw UNKNOWN_STATUS_OF_TRANSACTION, which needs both failpoints armed: iceberg_metadata_commit_response_lost alone is reconciled as Committed on local storage, which is what the existing INSERT and DELETE arms assert. The pre-existing DELETE arm armed response_lost only, so the guard in Iceberg/Mutations.cpp was reached by nothing and deleting it left every test green while the DELETE/UPDATE data loss stayed live. The new arm arms both failpoints, asserts the code is reported, and then asserts survival the way the other arms do: the current snapshot's manifest list is still stored, absolute data-file and Avro-file counts, and a forced column scan through both the table and a fresh icebergLocal(). count() alone is answered from the manifests' record_count and is blind to a deleted data file. On base the arm prints NOT REPORTED AS UNKNOWN and reads fail with the reported signature, No such file or directory [.../snap-<id>-2-<uuid>.avro. Deleting only the eight-line catch block in writeMetadataFiles reddens this arm and leaves the other eight byte-identical. Note the mutant still reports the error code, so an oracle on the code alone would be vacuous here; the manifest-list probe and the file counts carry the difference. 100 randomized runs through clickhouse-test, no source change.
Internal second-model review (three rounds; every finding and its disposition)An independent model reviewed this change against the frozen description before publication, once per Round 3 (final): 0 findings from the second model, 2 nits from my own review.
Round 3 also covered the round-2 addition: the Round 2: 1 finding (raised independently by both the second model and my own review).
Round 1: 6 findings.
One correction was made to the description during round 1: it had listed Also noted and deliberately not chased: |
Pre-PR validation gate
100 randomized runs, all passed. |
|
Workflow [PR], commit [0d66edf] Summary: ✅
AI ReviewSummaryThe PR reconciles failed Iceberg metadata writes against stored content and preserves staged files when the outcome is Findings❌ Blockers
Tests
Missing context / blind spots
Final VerdictStatus: ❌ Block Address the version-hint stale-read regression and complete the tracked catalog reconciliation for the remaining destructive commit paths. Existing dismissed findings remain summary-only; no threads were reopened or duplicated. |
|
cc @arsenmuk @kssenii, could you review this? The Iceberg |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Object file sizes8 object files changed (+45.67 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 units47 translation units recompiled, 390 s compile time in total, 47 of them have a recent master baseline. |
CI finish ledger - 80ebd36Every failure below has an owner: a fixing PR (ours or external), or a full-effort fix task
The praktika report for this head lists exactly one non-OK result, and it is the harness abort above; the whole test matrix is otherwise green. Note the GitHub check list also shows a |
…state-unknown-cleanup
…known `ALTER TABLE ... DROP PARTITION` on Iceberg commits through `writeMetadataFileAndVersionHint` like INSERT, DELETE/UPDATE and OPTIMIZE, but its `SCOPE_EXIT` removed the staged manifest list whenever the commit did not return true, including when it threw `UNKNOWN_STATUS_OF_TRANSACTION`. When the metadata write had in fact landed, that deleted the manifest list of the snapshot the table now points at, so every read failed with a missing `snap-*.avro`. On an unknown outcome the staged files are now kept, as in the other three commit paths. The 04929 arm arms both failpoints around a DROP PARTITION; without this change the new manifest list is gone and both reads fail with FILE_DOESNT_EXIST, with it the drop is visible and the table stays readable. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Comment-only change. The guard sites no longer restate the contract that `isCommitStateUnknown` documents in `Utils.h`, and the remaining blocks keep only the invariants the code below them cannot show: a failed conditional write can still land, only `LostRace` licenses deleting the staged files, the hint convergence must never throw, and both sides pin `SnappyMode::Basic`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Three properties of `writeMetadataFileAndVersionHint` had no test that fails without them: - a target that becomes visible only after the first read-back still resolves as committed (with a single probe it reports an unknown outcome); - a compressed document this writer stored is recognised as its own, which needs the read-back to decode what the write path encoded (gzip, zstd, and snappy in its pinned block format); - a transient failure while advancing `version-hint.text` neither leaves the function, since it runs after the commit landed and a throw would reach the callers' cleanup, nor stops the hint from advancing. The stub now stores what the commit writes before failing the write, hides the target from the first probes, and holds a version hint whose first probes fail. Each new case fails on its own mutation: one read-back attempt, no decoding, a framed snappy reader, and giving up or rethrowing in the hint retry loop. Co-Authored-By: Claude Opus 5.5 <[email protected]>
`convergeVersionHint` gave up after four failed attempts in total, so a writer of the highest version could lose four hint races to writers of lower versions and stop with `version-hint.text` still naming one of theirs: readers with `iceberg_use_version_hint = 1` then miss the latest commit until the next one repairs the hint. A failed attempt after which the hint turns out to have advanced was lost to another writer's progress, so it no longer counts; the budget still bounds attempts that make no progress, and the number of resets is bounded by the versions between the observed hint and the committed one. The new gtest loses four hint races, each to a writer that advances the hint by one: before this change the hint stays at 5 after version 6 committed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
CI finish ledger - 0ce6a73Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
The targeted jobs pick this test because the PR changes the Iceberg commit code; the PR does not touch the test or the manifest bounds decoding. CIDB has no other Session id: cron:our-pr-ci-monitor:20260929-183205 |
|
📊 Cloud Performance Report ✅ AI verdict: No performance change can be attributed to this PR. It only changes Iceberg write commits: checking whether a metadata write landed, retrying the version-hint update, and skipping cleanup when the commit outcome is unknown. Benchmark SELECTs over MergeTree tables never run that code. The one flagged row, clickbench Q18 (+13.3%, 892 ms to 1010.5 ms), was already held at not_sure because the new median sits inside master's current range of 856-1079 ms. That ruling fits the diff, and the run's measurements were noisy. 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
|
…state-unknown-cleanup Co-Authored-By: Claude Opus 5.5 <[email protected]>
This PR removed the constant together with its only user, the version hint loop of `writeMetadataFileAndVersionHint`, which `convergeVersionHint` replaced. Master has since added `tryWriteVersionHintFile`, which OPTIMIZE uses and which loops on the same constant, so the merge of master did not compile. Keep the constant at master's value so that function keeps master's behaviour; `writeMetadataFileAndVersionHint` still goes through `convergeVersionHint`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
CI finish ledger - 2b1946dEvery failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
Every other build and test job was skipped after this failure. They will run on the new head. Session id: cron:clickhouse-maint-slot-23:20261010-201100 |
The read-back of a failed conditional metadata write polled up to four times with a fixed 200 ms sleep, to catch a write that becomes visible late. The outcome is safe without the poll: an absent or unreadable target is already reported as an unknown commit state, which keeps the staged files, and every probe already goes through the object storage client's own retries. So the read-back is now a single probe and holds no query thread in a sleep. The unknown-state error no longer says the table is left untouched, which contradicted its own "the commit may have taken effect": it now says that no staged files were removed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The test stub returned no ETag for `version-hint.text` and accepted any hint write, so dropping the `If-Match` condition from the hint update left every test green, although that condition is what stops a writer of a lower version from overwriting a newer hint. The stub now hands out an ETag that changes on every hint write and expects each update of an existing hint to be conditional on it. Removing the condition from `convergeVersionHint` now fails the two hint tests. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…gtest Creating `version-hint.text` uses `If-None-Match: *`, so of two writers creating it at once only one succeeds. No test created the hint, so dropping that condition stayed green. A new arm creates it, and the stub expects the creating write to be exclusive. Co-Authored-By: Claude Opus 5.5 <[email protected]>
CI finish ledger - a239ef5Every 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-033004 |
…state-unknown-cleanup
CI finish ledger - 24cb5daEvery failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
The same shard's Session id: cron:our-pr-ci-monitor:20261011-080006 |
|
@groeneai check test failures |
|
The finished run on 24cb5da has one failed test, and it is not related to this PR:
|
…write `Iceberg::writeMetadataFile` is the single storage-side commit point (an `If-None-Match: *` create of `vN.metadata.json`). It turned every write failure except `UNSUPPORTED_METHOD` into `false`, and every caller (expire_snapshots, INSERT, DELETE/UPDATE, ALTER, DROP PARTITION, OPTIMIZE) reads `false` as a lost commit race and retries. A write the storage refused (no permission) is refused again on every round, so the loop ended in `LIMIT_EXCEEDED` and the real error was only logged (ClickHouse#125343). Propagate a refused write, extending the `UNSUPPORTED_METHOD` carve-out: `READONLY` (a read-only disk refuses every write before sending it), `ErrnoException` with EACCES/EPERM/EROFS (local storage; the temporary file is opened, and the target linked, before anything is published) and `S3Exception` with the codes `S3::isAuthenticationError` recognises (ACCESS_DENIED, INVALID_ACCESS_KEY_ID, INVALID_SIGNATURE) plus SIGNATURE_DOES_NOT_MATCH (a 403/401 is answered before the request is applied). A refusal that comes after the write was sent, e.g. of the `s3_check_objects_after_upload` request, may follow a PUT that landed, so it propagates only when the file is absent; a refused pre-write existence check propagates directly. Every other failure stays retryable: - S3 reports a lost race (412 PreconditionFailed) as an untyped `UNKNOWN` error, so "retry only on a recognised conflict" would fail the parallel sinks of a multi-threaded INSERT. - A timeout or 5xx after the PUT may have committed; that case is ClickHouse#115390's. - Azure's layer classifies 403 as retryable on purpose (RBAC propagation lag), so Azure is unchanged. `S3Exception::isRetryableError` is not reused: its non-retryable set includes NO_SUCH_KEY/NO_SUCH_UPLOAD, which can follow a PUT that landed. The callers' exception paths clean up only this attempt's uncommitted staged files and rethrow, which is correct for a write that did not happen. The gtest stub now takes the error to throw and the answers of `exists`. The `UNSUPPORTED_METHOD` test also covers READONLY. New tests cover the errno and S3 refusals, a refusal of a write that may have landed (the file is there afterwards, or the check fails), and a refused pre-write existence check. The retryable control gains the local lost race (FILE_ALREADY_EXISTS), an I/O error (EIO) and the S3 lost race (412), so a classifier that propagated every ErrnoException or S3Exception fails it. Closes ClickHouse#125343 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…state-unknown-cleanup Conflicts in Iceberg/Utils.cpp and the commit-propagation gtest, both against master's refused-write propagation (ClickHouse#125406). Utils.cpp: keep master's `isRefusedWrite`/`isKnownAbsent` and its `write_attempted` flag, which replaces this branch's `put_started` (same meaning). The refusal check stays the first statement of the catch arm, so a refused write whose target is absent still propagates as itself; every other failure after the write was sent is reconciled. gtest: port master's refusal cases onto the reconciling stub (the write failure is now a thrower, and the target's existence probe can be answered per call). Two of master's expectations encoded "an ambiguous outcome returns false" and change with this branch: a non-refused failure with an absent target, or a failing check after a refusal, is now UNKNOWN_STATUS_OF_TRANSACTION; a refusal after an upload whose bytes landed is committed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…state-unknown-cleanup Conflicts in Iceberg/Utils.h and Utils.cpp, both against master's `isConditionalWriteConflict` (ClickHouse#125026), which logs a lost metadata commit race at Debug instead of Error. Utils.h: declare both `isCommitStateUnknown` and master's `isConditionalWriteConflict`; keep this branch's `writeMetadataFile` contract (false only for a known-lost commit). Utils.cpp: union of the error codes and failpoints. In the catch arm the refusal check stays first, master's Debug/Error log split follows, and every failure after the write was sent is still reconciled against the stored bytes instead of returning false. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Master's ClickHouse#127275 made `~IcebergStorageSink` remove the written data files and manifests whenever the insert did not commit. An `UNKNOWN_STATUS_OF_TRANSACTION` from `initializeMetadata` leaves `committed` false, so the destructor deleted the files of a snapshot the table may already point at, after the commit path had deliberately kept them. 04929's unknown-outcome INSERT case caught it after the master merge: a data file and a manifest gone, `SELECT sum(c0)` failing FILE_DOESNT_EXIST on the manifest. Record the unknown outcome and skip the destructor's cleanup for it. Inserts that fail any other way still remove their files (05441 passes). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…state-unknown-cleanup # Conflicts: # src/Storages/ObjectStorage/DataLakes/Iceberg/AlterDropPartitionExecutor.cpp # src/Storages/ObjectStorage/DataLakes/Iceberg/Utils.cpp
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed data loss on Iceberg writes when the response to the
metadata.jsoncompare-and-swap is lost after the object store already accepted it. ClickHouse read that as another writer having taken the version and deleted the manifests, manifest list and data files of the snapshot that had just become current, leaving the table unreadable.INSERT,DELETE/UPDATE,OPTIMIZE TABLE ... MANIFESTandALTER TABLE ... DROP PARTITIONwere affected. The commit outcome is now established by reading the target back instead of inferred from the error, so files are deleted only when the commit is known not to have taken effect; an outcome that cannot be established reportsUNKNOWN_STATUS_OF_TRANSACTION. Closes #112081.Description
writeMetadataFileAndVersionHintreturnedfalsefor every failure of the conditionalv<N>.metadata.jsonwrite except a backend refusal, and callers readfalseas "my commit did notland" and clean up. That PUT is a compare-and-swap, so a response lost after the store accepted the
object is indistinguishable at the error from a lost race: the cleanup deletes the manifest list,
manifests and (on
INSERT) the data files of the snapshot that write just made current, and readersthen 404.
falseasserts the commit did not happen; the code can only establish it is retryable. Thespec names this state
CommitStateUnknownand requires no cleanup.The outcome is now measured, not inferred. On a failed PUT the target is read back uncached and
compared byte-for-byte with what was written: identical means committed (no cleanup),
present-but-different means a lost race (cleanup, unchanged), absent or unreadable stays
unknown and throws. Absence is not proof the write will not land, since nothing cancels a failed
conditional PUT server-side. Classifying the error instead was
rejected; see below.
Six callers share this seam. The four that delete staged files while unwinding (
INSERT,DELETE/UPDATE,OPTIMIZE,DROP PARTITION) now let that exception pass through, and theINSERTsink keeps its files on it; otherwise itreaches their cleanup and the data loss survives.
ALTERand expiration delete nothing there. Thepost-commit
version-hint.textsteps also ran outside any handler, so a blip there reached thosesame cleanup handlers after the commit had landed.
A failure raised before the write reaches the store is also reported unknown, so it leaks the staged
files rather than removing them. Erring that way is deliberate.
The catalog
updateMetadataimplementations share the defect but need a different oracle: #115580.#114246 touches only this function's
exists()pre-check, so the hunks are disjoint.Validation, and why error classification was rejected
Classifying the error was rejected: a 412 is a generic
S3Exceptionwith a private AWS code, eachof four backends would need its own taxonomy, and an unclassified error defaults into one bucket.
Each guard has an arm: reverting that guard's single hunk reddens it and leaves the other eight
byte-identical. An error-code oracle would be vacuous, since a guard
changes only the cleanup, never the throw; so file counts are absolute and every scan sums
a column (
count()alone survives deleted Parquet). A/Bagainst base, failpoints in both, Build IDs asserted.
Stateless
04929_iceberg_commit_state_unknown_no_cleanup, 8 arms and a control:INSERT: rows,sum(c0), freshicebergLocal()INSERT: manifest list, data + Avro filesDELETE: rows,sum(c0), manifest listDELETE, unknown: reported, manifest list, filesOPTIMIZE, both arms: manifest list,sum(c0)INSERT, unknown: reported, data + Avro filesDROP PARTITION, unknown: manifest list, Avro,sum(c0)On base, reads fail with the reported signature,
No such file or directory [.../metadata/snap-<id>-...avro. The version-hint row needs no failpoint.IcebergCommitPropagationgtest: 7 new arms (committed, compressed, hint probe error, hint race,hint creation, absent, unreadable) redden on base. Master's refusal arms share the stub; two expecting
falsefor anambiguous outcome now expect
UNKNOWN_STATUS_OF_TRANSACTION, and a refusal after a landed uploadcommits. 100 randomized runs passed.
Workflow [PR]
Sync PR [sync-upstream/pr/115390]