Copilot commented on code in PR #5095:
URL: https://github.com/apache/polaris/pull/5095#discussion_r3610638171
##########
persistence/relational-jdbc/src/main/java/org/apache/polaris/persistence/relational/jdbc/JdbcBasePersistenceImpl.java:
##########
@@ -340,6 +340,40 @@ public void deleteEntity(@Nonnull PolarisCallContext
callCtx, @Nonnull PolarisBa
}
}
+ @Override
+ public void deleteEntityAndCreateEntities(
+ @Nonnull PolarisCallContext callCtx,
+ @Nonnull PolarisBaseEntity entityToDelete,
+ @Nonnull List<PolarisBaseEntity> entitiesToCreate) {
+ ModelEntity modelEntity = ModelEntity.fromEntity(entityToDelete,
schemaVersion);
+ Map<String, Object> params =
+ Map.of(
+ "id",
+ modelEntity.getId(),
+ "catalog_id",
+ modelEntity.getCatalogId(),
+ "realm_id",
+ realmId);
+ try {
+ datasourceOperations.runWithinTransaction(
+ connection -> {
+ datasourceOperations.execute(
+ connection,
+ QueryGenerator.generateDeleteQuery(
+ ModelEntity.getAllColumnNames(schemaVersion),
ModelEntity.TABLE_NAME, params));
+ for (PolarisBaseEntity entityToCreate : entitiesToCreate) {
+ persistEntity(
+ callCtx, entityToCreate, null, connection,
datasourceOperations::execute);
+ }
Review Comment:
`deleteEntityAndCreateEntities(...)` currently always attempts to insert
each `entityToCreate` and will fail the whole transaction if the entity already
exists (e.g., a low-level retry), which does not match the idempotent-create
behavior in `writeEntities(...)` for `originalEntities == null` (it skips when
the entity is already present by id). This can cause the delete to be rolled
back even though the create side was already durably applied.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]