Hi Serhii, We should certainly keep these concerns in mind while we develo and review the new SPI for the "backend abstraction" proposal. I do believe a new SPI will be required.
Consequently, the exact java methods involved in these use case are probably going to be different. The use cases are still valid, though, so thanks for raising this issue! Cheers, Dmitri. On Wed, Dec 2, 2026 at 8:51 AM Serhii Svynarchuk <[email protected]> wrote: > Thanks for the perspectives. Would the A, B, C example from #6194 be useful > in the catalog backend contract sketch? If A and B already exist with the > requested IDs and C is new, should the batch reuse A and B and create C in > one transaction, or return a conflict and leave C absent? If callers should > check for existing entities first, it would also help to spell out what > happens if another writer creates one of those entities before the batch > runs. > JB’s point about batch size seems worth tracking separately. I checked the > cleanup path, and a table with 34 distinct manifests that still exist would > generate at least 34 tasks in a single batch. If that path is wired to the > atomic DynamoDB backend, the batch would exceed its current 33-entity > create limit. > > Thanks, > Serhii > > On Wed, Dec 2, 2026 at 2:48 AM Yufei Gu <[email protected]> wrote: > > > The skip logic in JDBC writeEntities() clearly violates the > > all-or-nothing transactional principle. > > > > While this logic might be useful for the use case in > > testCreateEntitiesWithConflict, it shouldn't complicate things at the > > metastore interface and persistence levels. Instead, existence can be > > checked before submitting the creation batch. > > > > I'm not aware of any use case for creating multiple tables without > > checking their existence first; this is probably why only Task > > creation currently uses createEntitiesIfNotExist(). Even for tasks, > > the caller can check existence before the batch creation. > > > > Ultimately, we should not mix these conditional semantics with a > > method intended for transactional operations. > > > > Yufei > > > > On Mon, Nov 30, 2026 at 8:42 PM Jean-Baptiste Onofré <[email protected]> > > wrote: > > > > > > Hi all, > > > > > > I agree with Dmitri: JDBC is correct, and I don't think we need a > > > Persistence SPI signature change now. > > > > > > I think we are mixing two separate properties: > > > 1. Atomicity: if the call fails, nothing from the batch is written. If > > > it succeeds, every entity is durable. > > > 2. Reply/retry: what happens when an entity already exists with the > same > > id. > > > > > > JDBC respects atomicity: it runs in a single transaction. Reusing A > > > and B and inserting C is not a partial write, as A, B and C call exist > > > after the commit. So I don't see an all-or-nothing violation in #6194. > > > > > > About reply/retry, DynamoDB looks like the outlier on main: > > > - JDBC skips entities with an existing id. > > > - AbstractTransactionPersistence.writeEntitites() explicitly treats a > > > same-id create as a success, per entity (though it rewrites the > > > entity, where JDBC skips it). > > > - NoSQL doesn't use writeEntities(), but also accepts an existing > > > entity if it is unchanged. > > > - testCreateEntitiesAlreadyExisting covers this case in the shared > tests. > > > > > > That said, the writeEntities() Javadoc doesn't mention same-id > > > creates, so I understand how we got there. The manager relies on it > > > implicitly. > > > > > > So I would propose to: > > > 1. Keep the createEntitiesIfNoExist() contract. Yufei, your option 2 > > > is tempting with a single caller, but as Mike said, it's a contract > > > change, and it would touch JDBC, in-memory, NoSQL and the shared test. > > > 2. Clarify the writeEntities() Java for same-id creates. > > > 3. Align DynamoDB: when the transaction is cancelled because some > > > entities exist with the same id, retry with only the missing ones, > > > still in a single transaction. A different id under the same name > > > remains a conflict. > > > 4. Close #6194, or repurpose it. > > > > > > Two related points that I noted while investigating to reply here: > > > - DynamoDB rejects create batches of more than 33 entities (100 > > > actions, 3 per entity). The only production caller, > > > TableCleanupTaskHandler, creates one task per manifest plus one per > > > metadata file batch, in a single call. So dropping a table with more > > > than 33 manifests would fail to schedule the cleanup. As that caller > > > generates new ids and names for each retry, I think this limit matters > > > more in practice than the partial overlap. It's not a problem today as > > > the backend is not wired yet, but we should address it imho. > > > - #4939 (staged creates in commitTransaction) proposes to send creates > > > and updates in a single writeEntities() call. If it moves forward, > > > create semantics become relevant for a REST endpoint, and the current > > > Javadoc doesn't allow mixing creates and updates. > > > > > > I agree that the "Catalog backend abstraction" proposal is the right > > > place to define this properly: same-id reply, same id with different > > > content, name conflicts, and batch size limits. > > > > > > Thoughts? > > > > > > Regards > > > JB > > > > > > On Tue, Dec 1, 2026 at 3:28 AM Dmitri Bourlatchkov via dev > > > <[email protected]> wrote: > > > > > > > > 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 > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >
