Hi All, Since the discrepancy is between JDBC at the new "atomic" DynamoDB Persistence, and the DynamoDB impl. is still beta/experimental, I guess the question is whether the JDBC impl. is correct.
My interpretation of this thread is that the JDBC impl. IS, indeed, correct given current Persistence SPI javadoc. TransactionalMetaStoreManagerImpl is currently used only for "in memory" persistence, which, in turn, has been proposed for deprecation [1]. The "atomic" DynamoDB Persistence does not yet have any MetaStore manager in the current codebase on "main", as far as I can tell. Consequently, I do not see any immediate need for Persistence SPI changes. That said, we should probably pay close attention to this discrepancy and resolve it under the recent "Catalog backend abstraction" proposal [2]. I suppose this proposal will eventually lead to a fresh SPI definition where we ought to carefully define expected behaviours from the caller side. Cheers, Dmitri. [1] https://lists.apache.org/thread/8w7qvt67wg4ljf55njc6z496tq77h6md [2] https://lists.apache.org/thread/01tonkljgt5npybtk71q2j425182pxq0 On Mon, Nov 30, 2026 at 7:57 PM Michael Collado <[email protected]> wrote: > I think the discrepancy is in the transactional metastore impl, which was > the only implementation when the contract on the interface was written: > > https://github.com/apache/polaris/blob/dc8eb486d0c983067369cae2fabf4c38a2af1f59/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/TransactionalMetaStoreManagerImpl.java#L1058-L1074 > . In that implementation, each entity is checked individually and > already-existing entities are returned alongside newly created ones as long > as all entities are written exactly as prescribed. > > Personally, I have a hard time imagining cases where we'd want > createEntities to succeed when only some of the entities existed. However, > i do think that changing createEntitiesIfNotExist to behave differently > would mean a major contract change, which probably shouldn't be taken > lightly. Reading the code of the AtomicOperationMetaStoreManager, the > current implementation feels like an outright bug. The DDB implementation > was written entirely with that implementation in mind and wasn't written to > support what is in the contract, but I think it could be updated to support > the contract. It does feel a bit like adding a lot of additional code to > support a case that may not exist in real life, but... > > Mike > > On Mon, Nov 30, 2026 at 2:37 PM Yufei Gu <[email protected]> wrote: > > > I'm leaning toward the solution to keep writeEntities() all-or-nothing. > > This gives us two options. > > 1. Introduce a new writeEntities-like method that doesn't enforce > > all-or-nothing, > > so that createEntitiesIfNotExist() can use it. > > 2. Changing the behavior of "createEntitiesIfNotExist" so that it also > > enforces all-or-nothing. > > > > I'm slightly leaning toward option 2, given that only tasking creation > > calls `createEntitiesIfNotExist`, which is easier to modify. Option 1 > > requires changes from all persistence backends. > > > > Yufei > > > > > > On Mon, Nov 30, 2026 at 11:39 AM Serhii Svynarchuk <[email protected]> > > wrote: > > > > > Hi Yufei, > > > > > > Thanks for clarifying. I checked the Polaris code and can confirm that > > > Iceberg’s REST multi-table commit uses > > > updateEntitiesPropertiesIfNotChanged(). The only production caller of > > > createEntitiesIfNotExist() I found is the table cleanup handler > > > < > > > > > > https://github.com/apache/polaris/blob/6800f2dbab6a2741c84f2702b5b4d25e9751380f/runtime/service/src/main/java/org/apache/polaris/service/task/TableCleanupTaskHandler.java#L140-L164 > > > >. > > > It dispatches the returned child tasks before deleting the table > > metadata, > > > and a retry rebuilds the batch with fresh IDs and names. > > > > > > For #6194 <https://github.com/apache/polaris/issues/6194>, would it > make > > > sense to keep writeEntities() all-or-nothing and give > > > createEntitiesIfNotExist() a separate operation that reuses same-ID > > > entities and atomically creates all missing ones? That would preserve > the > > > documented behavior across backends and give cleanup a clear guarantee > > that > > > every child task is persisted when the call succeeds. > > > > > > Thanks, > > > Serhii Svynarchuk > > > > > > On Mon, Nov 30, 2026 at 8:29 PM Yufei Gu <[email protected]> wrote: > > > > > > > Thanks for bringing this to the dev mailing list. Copied my response > > from > > > > the issue: > > > > > > > > I think there are mismatches between writeEntities() > > > > < > > > > > > > > > > https://github.com/apache/polaris/blob/dc8eb486d0c983067369cae2fabf4c38a2af1f59/polaris-core/src/main/java/org/apache/polaris/core/persistence/BasePersistence.java#L97-L132 > > > > > > > > > and createEntitiesIfNotExist(). writeEntities() promises an all or > > > nothing > > > > commit. The contract for createEntitiesIfNotExist() > > > > < > > > > > > > > > > https://github.com/apache/polaris/blob/dc8eb486d0c983067369cae2fabf4c38a2af1f59/polaris-core/src/main/java/org/apache/polaris/core/persistence/PolarisMetaStoreManager.java#L261-L282 > > > > > > > > > allows existing entities with the requested IDs to be reused. For > > > example, > > > > if A and B already exist and we request [A, B, C], the documented > > > behavior > > > > is to reuse A and B and create C. > > > > > > > > Today, both createEntitiesIfNotExist() > > > > < > > > > > > > > > > https://github.com/apache/polaris/blob/dc8eb486d0c983067369cae2fabf4c38a2af1f59/polaris-core/src/main/java/org/apache/polaris/core/persistence/AtomicOperationMetaStoreManager.java#L899-L913 > > > > > > > > > and updateEntitiesPropertiesIfNotChanged() > > > > < > > > > > > > > > > https://github.com/apache/polaris/blob/dc8eb486d0c983067369cae2fabf4c38a2af1f59/polaris-core/src/main/java/org/apache/polaris/core/persistence/AtomicOperationMetaStoreManager.java#L966-L995 > > > > > > > > > call writeEntities(). updateEntitiesPropertiesIfNotChanged() needs a > > > > transactional method, which is the right thing here. If we want to > > > preserve > > > > the documented behavior of createEntitiesIfNotExist(), it should use > a > > > > separate persistence operation to preserve its documented behavior. > We > > > may > > > > introduce a nontransactional batch API for that. > > > > > > > > As far as I can tell, no REST endpoint calls > > createEntitiesIfNotExist(). > > > In > > > > particular, the Iceberg commitTransaction() handler rejects staged > > > creates > > > > < > > > > > > > > > > https://github.com/apache/polaris/blob/dc8eb486d0c983067369cae2fabf4c38a2af1f59/runtime/service/src/main/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalogHandler.java#L1535-L1541 > > > > > > > > > before loading any tables, then commits the pending updates > > > > < > > > > > > > > > > https://github.com/apache/polaris/blob/dc8eb486d0c983067369cae2fabf4c38a2af1f59/runtime/service/src/main/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalogHandler.java#L1604-L1608 > > > > > > > > > through updateEntitiesPropertiesIfNotChanged(). The create behavior > > > > discussed in #6194 <https://github.com/apache/polaris/issues/6194> > > > > therefore does not affect that endpoint. > > > > > > > > > > > > Yufei > > > > > > > > > > > > On Mon, Nov 30, 2026 at 9:32 AM Serhii Svynarchuk < > [email protected]> > > > > wrote: > > > > > > > > > Hi all, > > > > > > > > > > While working on issue #6194 < > > > > > https://github.com/apache/polaris/issues/6194>, > > > > > I noticed that JDBC and DynamoDB handle createEntitiesIfNotExist > > > > > differently when only some of the requested entities already exist. > > > > > > > > > > Suppose A and B already exist with the requested IDs, C is new, and > > we > > > > > call createEntitiesIfNotExist([A, > > > > > B, C]). > > > > > > > > > > - *JDBC* succeeds, reuses A and B, and creates C in one > > transaction. > > > > > This matches the current Javadoc and the shared test > > > > > testCreateEntitiesAlreadyExisting. Javadoc > > > > > < > > > > > > > > > > > > > > > https://github.com/apache/polaris/blob/main/polaris-core/src/main/java/org/apache/polaris/core/persistence/PolarisMetaStoreManager.java#L261-L278 > > > > > > > > > > > - *DynamoDB* returns ENTITY_ALREADY_EXISTS and leaves C absent. > > > > DynamoDB > > > > > PR #6144 <https://github.com/apache/polaris/pull/6144> > > > > > > > > > > Which behavior should all persistence backends implement? Should > the > > > call > > > > > succeed by reusing entities with matching IDs and atomically > creating > > > the > > > > > missing ones, or should it return a conflict and create nothing > when > > > only > > > > > some of the requested IDs already exist? > > > > > > > > > > Thanks, > > > > > Serhii > > > > > > > > > > > > > > >
