Repository navigation
Conversation
…fter a removed pointer When an `UpdateTable` of a Glue commit got a response that does not say whether it was applied (a server error, `OperationTimeoutException`, a failed SDK retry), or its read-back failed, the commit threw `DATALAKE_DATABASE_ERROR` and the writer deleted its data files, manifests and manifest list, although the table may already point to them. Now the commit reads the table back and resends the update if the table still points to the base. If it still cannot tell, it throws `UNKNOWN_STATUS_OF_TRANSACTION`, and `INSERT`, mutations, manifest compaction and `DROP PARTITION` keep their files. A metadata file whose commit Glue definitely refused is removed on the exception path too, so it does not block the next write. A commit built on a table pointer accepted a table whose pointer another writer removed, so it could be applied on a stale base and drop a concurrent commit. The base of a pointerless table is now passed as an empty pointer, and a removed or added pointer makes the commit rebuild on the latest metadata. Glue refuses a column name or type longer than its limit or with a control character other than tab. Such columns made every commit fail; now the commit keeps the existing Glue columns, and `CREATE TABLE` registers none. The tests are taken from #128752, which overlapped with #126924; the fault proxy now enforces `VersionId` for every database.
|
Workflow [PR], commit [cb38b81] Summary: ❌
AI ReviewSummaryThis PR preserves Iceberg files after ambiguous Glue commits, cleans up definitely rejected metadata, and avoids registering column text that Glue refuses. Review of Findings❌ Blockers
Missing context / blind spots
Tests
Final VerdictStatus: ❌ Block. Prevent deletion after the intermediate pointerless transition, make later writes progress past retained candidates, and add the two focused regressions. |
Glue requires `Column.Name` to have 1 to 255 characters, so an Iceberg field with an empty name made `UpdateTable` fail with `ValidationException` on every commit, the same way as a too long name. `canRegisterGlueColumns` now refuses it, and the fault proxy enforces the minimum length like Glue does. Also move `#include <algorithm>` out of the middle of the project includes in `GlueCatalog.cpp`, describe the empty `catalog_metadata_location` of a pointerless table in `MetadataFileWithInfo`, and fix the name of the test a comment in `test_database_glue` refers to. Related: #131575
| /// if another writer removed the pointer, the latest metadata file under the location may be a commit our base lacks. | ||
| const bool same_base = current_metadata_path.empty() | ||
| ? isSamePointerlessTable(existing, base_catalog_metadata_location) | ||
| ? base_catalog_metadata_location.empty() && isSamePointerlessTable(existing, new_metadata_path) |
There was a problem hiding this comment.
[Blocker] Establish a catalog pointer before publishing a pointerless writer's files
For a pointerless table, this accepts any base at the same location, while tryGetTableMetadata discovers the base by listing the latest metadata file. Consequently another writer can consume a candidate which the first writer still considers uncommitted:
- Writer A runs manifest compaction, uploads metadata
Band its consolidated manifests, and pauses before itsUpdateTableis applied. - Writer B starts an
INSERT, resolvesBfrom the pointerless table's location, and successfully commits metadataCreferencing those consolidated manifests. Glue still had no pointer when B checked this condition, so the commit is accepted. - A's conditional update is rejected. On reading
C, A returnsfalsebecauseupdate_may_have_landedis false. The cleanup inwriteConsolidatedManifestFilethen removes the manifests which the committedCreferences, making the table unreadable.
VersionId protects the Glue row but cannot protect a base selected from files published before that row changes. Please conditionally register the resolved base pointer before publishing candidate metadata, or reject writes until a pointer is registered. Add an overlapping compaction/insert case; the proxy's held_ mode can hold A's update while B commits.
There was a problem hiding this comment.
🕵 Fixed in cb38b81 by keeping the files instead of registering the pointer first. Registering the resolved base would not close the hole: the writer would still choose that base by listing, and the listing can return another writer's uncommitted metadata file.
commitTableUpdate now treats a commit as possibly referenced when its base is pointerless (empty base_catalog_metadata_location) or when it finds the pointer removed. Such a commit never returns false and never reports a definite error. Every failure becomes UNKNOWN_STATUS_OF_TRANSACTION, so INSERT, mutations, compaction and DROP PARTITION keep their files.
In your scenario, writer A's compaction now fails with UNKNOWN_STATUS_OF_TRANSACTION and keeps the consolidated manifests that C references. The cost on pointerless tables is possible orphan files after a failed commit, never a broken table. The same rule replaces the earlier rebuild after a removed pointer: those commits now fail and keep their files too.
New test test_glue_pointerless_compaction_keeps_files_another_writer_built_on covers it. The proxy's held_ mode holds the OPTIMIZE TABLE ... MANIFEST update while an INSERT lists the compaction's metadata file and commits on top of it. The test then checks that the compaction fails with UNKNOWN_STATUS_OF_TRANSACTION and that the table reads back 1, 2, 3, both through pyiceberg and through ClickHouse.
There was a problem hiding this comment.
[Blocker] The cleanup hole remains in cb38b81d3b1 when the pointer is removed and re-registered while a writer with a pointed base is pending.
At src/Databases/DataLake/GlueCatalog.cpp:1004-1008, consider this variant of the held-compaction case: A reads pointed base P, publishes compaction metadata B, and its update is held. Another client removes metadata_location; writer B lists A's metadata and commits C on top of it, setting previous_metadata_location = B. Release A: its conditional update is rejected without an SDK retry, so both base_is_listed and update_may_have_landed remain false. The next iteration reads C and returns false at line 1008, before checking previous_metadata_location at line 1012. commitMetadataFileToCatalog deletes A's metadata and the compaction cleanup deletes the consolidated manifests that C references.
The new guard covers a base that was already pointerless, or a pointer that is still absent when read back; it does not cover this intermediate pointerless state. Please preserve adopted files for this transition too, including when further commits have already advanced beyond C. A source-extracted harness confirms the current false return and metadata deletion for this state.
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Object file sizes20 object files changed (+69.71 KiB total), 0 added.
711 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 units125 translation units recompiled, 1567 s compile time in total, 125 of them have a recent master baseline. |
…terless base Address review of #131575: - The SDK reads a response body lazily, so a timeout or a truncated body can throw out of `GetTable` or `UpdateTable` instead of returning an unsuccessful outcome. An exception from `UpdateTable` now leads to a read-back like an ambiguous error, and an exception from `GetTable` after an update may have landed is reported as `UNKNOWN_STATUS_OF_TRANSACTION`. The fault proxy gets `truncated_` and `truncreadback_` faults that interrupt a response body. - The base of a table without `metadata_location` is the latest metadata file under its location, so another writer may take the metadata file of a pending commit as its base and commit on top of it. A commit with such a base, or one that finds the pointer removed, now reports every failure as `UNKNOWN_STATUS_OF_TRANSACTION` and keeps its files instead of returning a conflict that makes the writer remove them. A test runs an `INSERT` on top of a held manifest compaction of a pointerless table.
| } | ||
| catch (...) | ||
| { | ||
| if (writer_wrote_metadata_file && !isCatalogCommitOutcomeUnknown()) |
There was a problem hiding this comment.
[Blocker] Let subsequent writes get past metadata retained after an unknown outcome
Keeping the candidate file is necessary, but the current filename/retry scheme makes it a permanent write lock when the update never landed. If all five UpdateTable attempts fail before applying (for example, a temporary Glue outage), commitTableUpdate throws UNKNOWN_STATUS_OF_TRANSACTION and this handler keeps candidate B, while Glue still points to base P.
After Glue recovers, every new writer resolves P and regenerates exactly B: FileNamesGenerator::generateMetadataPathWithInfo derives the UUID from the base filename and next version. writeMetadataFile then returns false because B exists (Utils.cpp:429); the conflict retry rereads P and resets the generator to the same successor. All retries fail before another UpdateTable is sent. This affects subsequent INSERT, mutations and schema changes, so the write wedge from #112102 remains.
Please allow a fresh candidate name for a later commit, or otherwise make retries tolerate retained candidates safely, while keeping the files of the ambiguous commit. Add a fault case that refuses every update attempt without applying it, restores Glue, and verifies a new write succeeds without manually deleting objects. The current failed_no_retry/failed_timeout cases fail only the first attempt and therefore miss this.
Closes: #112102
Related: #128591
Related: #126924
Related: #128752
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed Iceberg writes to a Glue
DataLakeCatalogdatabase deleting the files of a commit that Glue may have applied (after a lost response, a timeout or a failed read-back), which left the table pointing to missing files. Such a commit now reads the table back, and fails withUNKNOWN_STATUS_OF_TRANSACTIONkeeping its files if the outcome cannot be established. Also fixed a commit on a Glue table withoutmetadata_locationremoving files that a concurrent commit references, and every write failing on a table whose column name Glue refuses.Description
#126924 made Glue commits read-modify-write and conditional on
VersionId. #128752 did the same in parallel and now conflicts with it. I ran the tests of #128752 against a master build (253dc40d795, includes #126924). 10 cases still failed because of real defects; this PR ports the fixes for those onto the code on master. The failing cases that only pinned that PR's own choices are not carried over: the Glue column history,timestamp_ns,EXTERNAL_TABLE, and comment handling.GlueCatalog::commitTableUpdatethrewDATALAKE_DATABASE_ERRORafter a 5xx,OperationTimeoutException, a failed SDK retry, a failed read-back, or a superseded commit. The writers then deleted the data files, manifests and manifest list that the table may already reference; master had a TODO for this inIcebergWrites.cpp. Now, after such a response, or an exception from the SDK while reading it, the commit reads the table back. If the table points to the new metadata, the commit succeeded. If it still points to the base, the update is sent again with the currentVersionId, so at most one attempt is applied. Otherwise the commit throwsUNKNOWN_STATUS_OF_TRANSACTION.INSERT, mutations,ALTER, manifest compaction,expire_snapshotsandDROP PARTITIONkeep their files on that error. They sharecommitMetadataFileToCatalog, which also removes the metadata file of a definitely refused commit on the exception path, so the file does not block the next write.metadata_locationis the latest metadata file under its location, so another writer can take the metadata file of a pending commit as its base and commit on top of it. A commit cleaning up after a conflict then removed files the table references. Also,isSamePointerlessTableaccepted a table whose pointer another writer removed, so the commit was applied on a stale base. The base of a pointerless table is now passed as an empty pointer (DataLakeSpecificProperties::resolved_from_table_location). A commit with such a base, or one that finds the pointer removed, reports every failure asUNKNOWN_STATUS_OF_TRANSACTIONand keeps its files.UpdateTablefail withValidationException. Now the commit keeps the existing Glue columns, andCREATE TABLEregisters none. ClickHouse reads the schema from the metadata file.The fault proxy from #128752 replaces the one on master. It enforces
VersionIdfor every database (master's existingcas_test now reads/rejected/) and injects lost-response, superseded, read-back, timeout and rejected faults. With the proxy, all existingtest_database_gluetests pass against the master build. The new tests are not run locally against this change; CI will run them.Workflow [PR]
Sync PR [sync-upstream/pr/131575]