Repository navigation
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors Iceberg multi-table transaction handling by removing the broad TransactionWorkspaceMetaStoreManager wrapper and replacing it with an explicit, Iceberg-scoped buffering object (PendingTableCommit) to collect deferred entity updates and metadata-file cleanups during commitTransaction.
Changes:
- Introduces
PendingTableCommitto buffer table-commit side effects (entity updates + metadata cleanups) until validations succeed. - Updates
LocalIcebergCatalogandIcebergCatalogHandler.commitTransactionto use explicit buffering instead of swapping the metastore manager. - Updates/extends tests to validate deferred cleanup behavior and preserved location-overlap rejection behavior during a pending commit.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| runtime/service/src/main/java/org/apache/polaris/service/catalog/iceberg/PendingTableCommit.java | Adds a package-private collector for buffered entity updates and deferred metadata cleanups. |
| runtime/service/src/main/java/org/apache/polaris/service/catalog/iceberg/LocalIcebergCatalog.java | Buffers entity updates and metadata cleanup when a pending commit is set; preserves overlap-validation rejection behavior. |
| runtime/service/src/main/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalogHandler.java | Uses PendingTableCommit in commitTransaction and replays buffered persistence + cleanup after validation. |
| runtime/service/src/test/java/org/apache/polaris/service/catalog/iceberg/AbstractLocalIcebergCatalogTest.java | Updates tests to assert buffering/replay behavior via PendingTableCommit. |
| runtime/service/src/test/java/org/apache/polaris/service/catalog/iceberg/AbstractLocalIcebergCatalogOverlapTest.java | Adds coverage that overlap-check failure behavior is preserved under a pending commit. |
| polaris-core/src/main/java/org/apache/polaris/core/persistence/TransactionWorkspaceMetaStoreManager.java | Removes the metastore-wrapper implementation in favor of explicit buffering at the call sites. |
| // Buffer the entity updates and metadata-file cleanups produced by each table commit. The | ||
| // entity updates are persisted as a single atomic unit after all validations succeed. | ||
| PendingTableCommit pendingTableCommit = new PendingTableCommit(); | ||
| ((LocalIcebergCatalog) baseCatalog).setPendingTableCommit(pendingTableCommit); | ||
|
|
| deleteRemovedMetadataFiles.accept(new MetadataFileCleanup(io(), base, metadata)); | ||
| MetadataFileCleanup cleanup = new MetadataFileCleanup(io(), base, metadata); | ||
| if (pendingTableCommit != null) { | ||
| pendingTableCommit.addPendingMetadataFileCleanup(cleanup); |
There was a problem hiding this comment.
This and similar (new) if/else blocks complicate the processing logic. How about renaming PendingTableCommit to CatalogEntityUpdater and making two implementations:
- calling through to
metaStoreManagerfor single entity changes. - collecting updates and metadata cleanup for multi-table commits.
There was a problem hiding this comment.
Hi @dimas-b, that's a good point. The conditional block isn't that elegant. What you suggest also makes sense. That's actually my first version. But I intentionally switch it to back to this version due to at least one or two additional classes/interfaces added. I thought maybe this is maybe simpler, given there are only two places needing it. And we can always abstract later by introducing the interface, etc. WDYT?
There was a problem hiding this comment.
Made this change by introducing a new interface and two impl. for different behaviors. I'm OK with both. I think the first version is actually a bit simpler. Let me know if you strongly prefer one over another.
dimas-b
left a comment
There was a problem hiding this comment.
+1 to introducing TableCommitActions
| this.deleteRemovedMetadataFiles = | ||
| deleteLogic != null ? deleteLogic : LocalIcebergCatalog::defaultDeleteRemovedMetadataFiles; | ||
| /** Restores immediate persistence and metadata-file cleanup for table commits. */ | ||
| void resetTableCommitActions() { |
There was a problem hiding this comment.
I think this method is rather confusing. The local catalog object should not be shared between operations that have different "table commit" semantics.
Currently it's called only from test code, but those tests also pass without this method, I believe.
| realmConfig.getConfig(FeatureConfiguration.OPTIMIZED_SIBLING_CHECK); | ||
| if (tableCommitActions instanceof BufferedTableCommitActions) { | ||
| String methodName = useOptimizedSiblingCheck ? "hasOverlappingSiblings" : "listEntities"; | ||
| throw diagnostics.fail("illegal_method_in_transaction_workspace", methodName); |
There was a problem hiding this comment.
This logic looks odd in the current codebase 🤔 Why do we need this?
| } | ||
|
|
||
| @Test | ||
| public void testBufferedTableCommitActionsPreserveOptimizedLocationOverlapFailure() { |
There was a problem hiding this comment.
I'm not sure what this test validates? Does it mean that IcebergCatalogHandler.commitTransaction() never called this method?
| } | ||
|
|
||
| List<MetadataFileCleanup> pendingMetadataFileCleanups() { | ||
| return List.copyOf(pendingMetadataFileCleanups); |
There was a problem hiding this comment.
Perhaps we should move the batched call to CatalogUtil.deleteRemovedMetadataFiles() here to be symmetric with DirectTableCommitActions? WDYT?
| } | ||
|
|
||
| List<EntityWithPath> pendingUpdates() { | ||
| return List.copyOf(pendingUpdates); |
There was a problem hiding this comment.
also maybe move updateEntitiesPropertiesIfNotChanged() calls and matching "clean up" call here too?
| this.storageAccessConfigProvider = storageAccessConfigProvider; | ||
| this.fileIOFactory = fileIOFactory; | ||
| this.metaStoreManager = metaStoreManager; | ||
| this.directTableCommitActions = new DirectTableCommitActions(metaStoreManager); |
There was a problem hiding this comment.
A fresh LocalIcebergCatalog is created for each REST API call, including IcebergCatalogHandler.commitTransaction().
Ideally, the type of tableCommitActions to use should trickle down through the call chain as it is specific to overarching operation as a whole.
If you agree, this can be deferred to keep this PR's diff smaller.
|
This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days. |
|
This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days. |
Why
TransactionWorkspaceMetaStoreManagerimplemented the entire metastore interface even though it only buffered one write operation. Nearly every other method threw, and its delegate was unused. This made a catalog-specific transaction detail look like a general persistence implementation and coupled it to every change inPolarisMetaStoreManager.The new
TableCommitActionsabstraction represents only the side effects produced by a table commit: table-entity updates and metadata-file cleanup. Its direct implementation applies those actions immediately, while its buffered implementation collects them for an atomic multi-table commit.What changed
TransactionWorkspaceMetaStoreManagerwith package-privateTableCommitActions, using direct and buffered implementations for normal and multi-table commits.PolarisMetaStoreManagerimmutable and removed transaction-mode branches from the entity-update and metadata-cleanup call sites.Checklist
CHANGELOG.md(not needed; no intended user-visible behavior change)site/content/in-dev/unreleased(not needed; no API or configuration change)