Repository navigation
Reject Iceberg metadata that re-binds a schema-id to a different schema - #107370
Conversation
An Iceberg schema-id is immutable and unique per the spec: schema evolution appends a new schema-id and retains old ones unchanged (data files reference schema-id to resolve their column layout). IcebergSchemaProcessor caches each parsed schema by schema-id in iceberg_table_schemas_by_ids for the whole lifetime of the table's IcebergMetadata (persistent_components.schema_processor), accumulating across metadata refreshes. When a later metadata version re-used an existing schema-id with different content, the next read called addIcebergTableSchema(id, A') and tripped chassert(schemasAreIdentical(...)), aborting the server in debug builds. In release builds chassert is a no-op, so the stale cached schema was silently kept for the new metadata version, a latent wrong-schema / wrong-results bug. Reconciling (newest-wins) is not coherent: data files written under the original id would be read with the wrong layout. Turn the debug-only chassert into an ICEBERG_SPECIFICATION_VIOLATION that fires in all builds, which both stops the abort and closes the release-build silent-stale-schema path. Byte-identical re-adds remain a no-op. ClickHouse's own writer never reuses a schema-id, so only external/malformed metadata reaches this path. Found by BuzzHouse. Closes: ClickHouse#107316 Co-Authored-By: Claude Opus 4.8 <[email protected]>
Pre-PR validation gate
Session id: cron:clickhouse-worker-slot-2:20260612-204200 |
|
cc @scanhex12 @Michicosun — could you review? It rejects Iceberg metadata that re-binds an existing |
|
Workflow [PR], commit [f8475f6] Summary: ✅
AI ReviewSummaryThis PR turns the Iceberg Final VerdictStatus: ✅ Approve |
|
CI fully finished on HEAD
The Iceberg fix itself (reject metadata that re-binds a schema-id to a different schema; |
|
CI fully finished on
The Iceberg fix (reject metadata that re-binds a schema-id to a different schema; chassert -> throw ICEBERG_SPECIFICATION_VIOLATION; Closes #107316) is unchanged and was validated both directions. All failures explained + tracked; back to reviewers. |
Clearer variable names, vertical separation, and context-managed file access in the inline python block, per review feedback. No behavior change: the block still loads the latest metadata, renames schema-id 0 field c0 to c9, bumps last-updated-ms, and atomically writes the next vN+1.metadata.json. Verified byte-identical output to the previous block. Co-Authored-By: Claude Opus 4.8 <[email protected]>
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered by tests: 5/7 (71.43%) | Lost baseline coverage: none · Uncovered code |
|
CI fully finished on HEAD Session: cron:our-pr-ci-monitor:20260615-160000 |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed a crash (
LOGICAL_ERRORin debug builds) and a silent wrong-results bug (in release builds) when reading an Iceberg table whose metadata re-binds an existingschema-idto a different schema across metadata versions. Such metadata is now rejected withICEBERG_SPECIFICATION_VIOLATION.Description
Closes: #107316 (found by BuzzHouse).
An Iceberg
schema-idis immutable and unique per the spec: schema evolution appends a newschema-idand retains old ones unchanged, since data files referenceschema-idto resolve their column layout.IcebergSchemaProcessorcaches each parsed schema byschema-idiniceberg_table_schemas_by_idsfor the whole lifetime of the table'sIcebergMetadata(persistent_components.schema_processor), accumulating across metadata refreshes.When a later metadata version re-used an existing
schema-idwith different content, the next read calledaddIcebergTableSchema(id, A')and trippedchassert(schemasAreIdentical(...))atSchemaProcessor.cpp:222, aborting the server in debug builds. In release builds thechassertis a no-op, so the stale cached schema was silently kept for the new metadata version, a latent wrong-schema / wrong-results bug.Reconciling (newest-wins) is not coherent: data files written under the original id would then be read with the wrong layout. The fix turns the debug-only
chassertinto anICEBERG_SPECIFICATION_VIOLATIONthat fires in all builds, which both stops the abort and closes the release-build silent-stale-schema path. Byte-identical re-adds remain a no-op. ClickHouse's own writer never reuses aschema-id, so only external/malformed metadata reaches this path.Reproduced on master HEAD with the issue's
IcebergLocalreproducer (server SIGABRT before, cleanICEBERG_SPECIFICATION_VIOLATIONwith the server staying up after). Added regression test04337_iceberg_schema_id_reuse_across_versions, which fails (server dies) without the fix and passes with it; verified the no-op identical-re-read path and legitimate schema evolution (newschema-id) are unaffected.Version info
26.6.1.846