Repository navigation
Conversation
Internal second-model review (final round) — 1 unresolved blocker disclosed, 2 refuted with evidence, 4 notedReviewed cold against the code on disk before any of this PR's own notes were read, then ❌ Unresolved, disclosed: the followability gate accepts a null
|
Pre-PR validation gate
Mutation-verified, so the oracle is not vacuous. Six mutations, each reddening only its own The validation is ordered behind the decision to write, so the default configuration, where The per-attempt property is covered by a differential rather than by the suite, since the hint-write 50x repeat of the whole test: 600 passed, 0 flakes, run at load average 71. A file deleted after the check and before a reader arrives remains possible; the deletions are not The entry walk descends only into entries this snapshot added. An entry carried forward from an Edited 2026-08-11: rows (d) and (g) and the mutation-arm note updated after the fence moved to the production read path. The counts are recounted from the test file; the field-rule enumeration in (g) no longer described how the check works._ |
|
cc @SmitaRKulkarni @arsenmuk, could you review this? With iceberg_use_version_hint = 1, a commit interrupted between its vN.metadata.json PUT and the version-hint.text advance leaves the hint naming N-1 forever, so every later writer regenerates that same vN, hits the existence check, and the table stays unwritable; this converges the hint on that branch, but only after confirming a reader could actually follow the target. |
|
Workflow [PR], commit [4c56008] Summary: ❌
AI ReviewSummaryThis PR repairs the stale Missing context / blind spots
Final Verdict✅ No actionable review findings in the current revision. LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 53/147 (36.05%) · Uncovered code |
A commit is two non-atomic writes: the conditional PUT of `vN.metadata.json`, then the advance of `metadata/version-hint.text` to `N`. A crash in between leaves the metadata file durable and the hint naming `N-1`. With `iceberg_use_version_hint = 1` that never resolves: every later writer resolves its base through the stale hint, regenerates that same `vN`, is refused by the existence check, and collides again until it gives up, so every later INSERT stays wedged with DATALAKE_DATABASE_ERROR. `writeMetadataFileAndVersionHint` read "the target already exists" as only a lost race and returned before reaching its own hint-convergence loop. But the target carried `write-if-none-match: *`, so a completed PUT claimed that version and a hint naming `N-1` is behind it. Converge the hint there too, before reporting the lost race. Existence alone does not authorize publishing it, because the version the hint already names is readable and the target may not be. The hint is only advanced if the document reads back and a reader could follow its current snapshot: - the snapshot carries a `schema-id`, without which building it throws before any object is opened; - its manifest list satisfies the field and type rules the read path enforces on the list's own entries - `added_snapshot_id` present and long, `manifest_path` a string, `manifest_length` a non-negative long, `partition_spec_id` present, and `sequence_number`/`content` correctly typed where a v2 list carries them; - every object that reader would open exists: the list, each manifest it names, and the data and delete files that snapshot itself added. Only the snapshot's own additions are descended into, and the whole branch is reached only where the hint would otherwise be written, so the default configuration reads nothing. Deletions are not transactional, so the check holds as of the decision, not for good. The lost race is still reported and the hint is never lowered, so no caller's contract changes. ClickHouse cannot itself write the refused shapes - AvroSchema.h declares those manifest-list fields non-nullable, MetadataGenerator.cpp always emits a schema-id, and carrying a null adder id forward throws - so they arrive through an externally written manifest list, which is the population this fence exists for. Refusing leaves the hint where it was, which is never worse than adopting a version every read refuses. Manifest entries below the list are probed for existence only; holding those to the reader's own contract is a separate surface. The post-crash state needs no crash to build, so the tests construct it, on S3 and on local disk: before this the next write fails with `Code: 736`, after it it succeeds and returns the missing row. Six further cases pin what the hint must never do: one asserts monotonicity, the rest cover eight refusal states - three missing-object, and five where every object exists but the document or its list breaks a rule the read path enforces. Closes: ClickHouse#114108
ddd2468 to
a0d6e59
Compare
Build profile diff (arm_release)No arm_release build profile data for commit 4c56008 - the build was skipped, reused from cache, or predates profile upload. |
…path The publish fence mirrored the manifest-list field rules by hand, so it only covered the level it mirrored. A target whose list is well formed but whose manifest files are not still passed it, and publishing that target replaces a readable v(N-1) with a vN every reader refuses. Read the candidate through the same functions a SELECT uses instead: parseTableSchema for the document's own schema, registerMetadataSchemasAndSnapshots for the schema and snapshot bindings its manifests resolve against, getManifestList for the list entries, and getManifestFileEntriesHandle for each manifest's Avro header and rows. Every rule the read path enforces now holds by construction rather than being restated, so the manifest-level invariants (partition-spec and schema in the manifest header, and the required fields of each manifest row) are covered without enumerating them, and the levels can no longer drift apart. The rules this replaces were added in the previous two rounds of this PR after clickhouse-gh[bot] pointed out the null added_snapshot_id, negative manifest_length, missing partition_spec_id and snapshot schema-id gaps. Reading through the deserializer also removes every raw avro GenericDatum value<T>() call from this file, so the scoped NOLINT(clang-analyzer-core.uninitialized.UndefReturn) the arm_tidy fix needed is gone rather than narrowed: the analyzer had been pointing at unchecked narrowing on externally written fields, which the typed read path now rejects. Three places a probe must not diverge from the reader. Its schema processor follows allow_experimental_geo_types_in_iceberg, because field types resolve eagerly and a geo document would otherwise be declined as unfollowable, which is this PR's own wedge reintroduced for geo tables. The document's schema is parsed before the no-snapshot returns, because a reader parses it before looking for a snapshot at all. And only ADDED entries are required, because getFilesWithoutDeleted also returns EXISTING rows, which name files an ancestor wrote and a compaction carries forward for the whole table. Validated on the shipped binary: 32 integration cases pass, and four mutation arms each reverting one rule redden only their own cases (dropping the manifest-file parse reddens the six that need it; dropping the geo setting, the document schema parse, and the strict snapshot registration each redden exactly their own two). Reverting only the NOLINT reproduces the analyzer error at the previously flagged call, so the clean tidy run is a measurement rather than a vacuous one. An earlier round dismissed the current-schema-id gap after grepping IcebergMetadata.cpp and reading zero hits. The field is read in Utils.cpp by the helper that file calls, so the grep proved nothing and the finding was correct as first raised. Residual, unchanged: manifest entries below the list are still only checked for the existence of the files they name, and retry revalidation has no failpoint to drive it.
CI finish ledger - 4c56008Every failure below has an owner: a fixing PR (ours or external), or a full-effort fix task
All three arms carry one signature, read per Not PR-caused: this diff is confined to Gate: 175 check-runs read with pagination, 0 queued or in progress; Session id: cron:our-pr-ci-monitor:20260811-140000 |
|
@scanhex12 @SmitaRKulkarni easy to review |
|
This PR is no longer needed on master: #114324 already fixed the wedge (#114108) there. Since that PR, INSERT resolves its base metadata file by listing Measured with this PR's own regression test,
#114324 has no backport label, so 26.8 still wedges. @PedroTadim, you added |
Advance the Iceberg version hint on a lost commit race
Closes: #114108
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixes Iceberg tables with
iceberg_use_version_hint = 1becoming permanently unwritable after a server crash between a commit's metadata write and itsversion-hint.textadvance. Writes kept failing withDATALAKE_DATABASE_ERROR, and the rows committed by the interrupted transaction stayed invisible.Description
A commit is two non-atomic writes: the conditional PUT of
vN.metadata.json, then the advance ofmetadata/version-hint.texttoN. A crash in between leaves the metadata file durable and the hintnaming
N-1. Withiceberg_use_version_hint = 1that never resolves: every later writer resolves itsbase through the stale hint, regenerates that same
vN, and is refused by the existence check.writeMetadataFileAndVersionHintreads "the target already exists" as only a lost race and returnsbefore its own hint-convergence loop. But the target carried
write-if-none-match: *, so a completedPUT claimed its version: the orphan is a finished commit to adopt. So converge the hint there too.
Existence alone does not authorize publishing it. The hint is left alone unless a reader could follow
the document's current snapshot, decided by reading the candidate through the same functions a
SELECTuses: every object that reader would open must be present (the manifest list, each manifest it names,
and the files that snapshot itself added), and every shape the read path rejects makes it refuse here
too, by construction rather than by restating the rules. Only its own additions are descended into, and
the branch is reached only where the hint would otherwise be written, so the default configuration reads
nothing. Deletions are not transactional, so this closes the window as of the decision, not for good.
The post-crash state needs no crash to build, so the tests construct it, on S3 and local disk: before
this the next write fails with
Code: 736, after it it succeeds and returns the missing row. Eightfurther cases pin what the hint must and must not do: one monotonicity, six covering refusal states,
and one asserting a followable target carrying a geo schema is still published.