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 >
