diff --git a/runtime/service/src/test/java/org/apache/polaris/service/quarkus/catalog/AbstractIcebergCatalogTest.java b/runtime/service/src/test/java/org/apache/polaris/service/quarkus/catalog/AbstractIcebergCatalogTest.java index d1d3868ade..8c4bf7cc72 100644 --- a/runtime/service/src/test/java/org/apache/polaris/service/quarkus/catalog/AbstractIcebergCatalogTest.java +++ b/runtime/service/src/test/java/org/apache/polaris/service/quarkus/catalog/AbstractIcebergCatalogTest.java @@ -106,6 +106,7 @@ import org.apache.polaris.core.entity.PolarisEntityType; import org.apache.polaris.core.entity.PrincipalEntity; import org.apache.polaris.core.entity.TaskEntity; +import org.apache.polaris.core.exceptions.CommitConflictException; import org.apache.polaris.core.persistence.MetaStoreManagerFactory; import org.apache.polaris.core.persistence.PolarisEntityManager; import org.apache.polaris.core.persistence.PolarisMetaStoreManager; @@ -2127,7 +2128,7 @@ public void testConcurrencyConflictUpdateTableDuringFinalTransaction() { Schema expected = update.apply(); Assertions.assertThatThrownBy(() -> update.commit()) - .isInstanceOf(CommitFailedException.class) + .isInstanceOf(CommitConflictException.class) .hasMessageContaining("conflict_table"); } diff --git a/service/common/src/main/java/org/apache/polaris/service/admin/PolarisAdminService.java b/service/common/src/main/java/org/apache/polaris/service/admin/PolarisAdminService.java index 9ef57701d4..c39c69977f 100644 --- a/service/common/src/main/java/org/apache/polaris/service/admin/PolarisAdminService.java +++ b/service/common/src/main/java/org/apache/polaris/service/admin/PolarisAdminService.java @@ -41,7 +41,6 @@ import org.apache.iceberg.catalog.TableIdentifier; import org.apache.iceberg.exceptions.AlreadyExistsException; import org.apache.iceberg.exceptions.BadRequestException; -import org.apache.iceberg.exceptions.CommitFailedException; import org.apache.iceberg.exceptions.NoSuchNamespaceException; import org.apache.iceberg.exceptions.NotFoundException; import org.apache.iceberg.exceptions.ValidationException; @@ -92,6 +91,7 @@ import org.apache.polaris.core.entity.PrincipalRoleEntity; import org.apache.polaris.core.entity.table.IcebergTableLikeEntity; import org.apache.polaris.core.entity.table.federated.FederatedEntities; +import org.apache.polaris.core.exceptions.CommitConflictException; import org.apache.polaris.core.persistence.PolarisEntityManager; import org.apache.polaris.core.persistence.PolarisMetaStoreManager; import org.apache.polaris.core.persistence.PolarisResolvedPathWrapper; @@ -880,7 +880,7 @@ private void validateUpdateCatalogDiffOrThrow( .orElseThrow(() -> new NotFoundException("Catalog %s not found", name)); if (currentCatalogEntity.getEntityVersion() != updateRequest.getCurrentEntityVersion()) { - throw new CommitFailedException( + throw new CommitConflictException( "Failed to update Catalog; currentEntityVersion '%s', expected '%s'", currentCatalogEntity.getEntityVersion(), updateRequest.getCurrentEntityVersion()); } @@ -932,7 +932,7 @@ private void validateUpdateCatalogDiffOrThrow( getCurrentPolarisContext(), null, updatedEntity)))) .orElseThrow( () -> - new CommitFailedException( + new CommitConflictException( "Concurrent modification on Catalog '%s'; retry later", name)); return returnedEntity; } @@ -1048,7 +1048,7 @@ public void deletePrincipal(String name) { "Cannot update a federated principal: %s", currentPrincipalEntity.getName()); } if (currentPrincipalEntity.getEntityVersion() != updateRequest.getCurrentEntityVersion()) { - throw new CommitFailedException( + throw new CommitConflictException( "Failed to update Principal; currentEntityVersion '%s', expected '%s'", currentPrincipalEntity.getEntityVersion(), updateRequest.getCurrentEntityVersion()); } @@ -1069,7 +1069,7 @@ public void deletePrincipal(String name) { getCurrentPolarisContext(), null, updatedEntity)))) .orElseThrow( () -> - new CommitFailedException( + new CommitConflictException( "Concurrent modification on Principal '%s'; retry later", name)); return returnedEntity; } @@ -1220,7 +1220,7 @@ public void deletePrincipalRole(String name) { .orElseThrow(() -> new NotFoundException("PrincipalRole %s not found", name)); if (currentPrincipalRoleEntity.getEntityVersion() != updateRequest.getCurrentEntityVersion()) { - throw new CommitFailedException( + throw new CommitConflictException( "Failed to update PrincipalRole; currentEntityVersion '%s', expected '%s'", currentPrincipalRoleEntity.getEntityVersion(), updateRequest.getCurrentEntityVersion()); } @@ -1242,7 +1242,7 @@ public void deletePrincipalRole(String name) { getCurrentPolarisContext(), null, updatedEntity)))) .orElseThrow( () -> - new CommitFailedException( + new CommitConflictException( "Concurrent modification on PrincipalRole '%s'; retry later", name)); return returnedEntity; } @@ -1347,7 +1347,7 @@ public void deleteCatalogRole(String catalogName, String name) { .orElseThrow(() -> new NotFoundException("CatalogRole %s not found", name)); if (currentCatalogRoleEntity.getEntityVersion() != updateRequest.getCurrentEntityVersion()) { - throw new CommitFailedException( + throw new CommitConflictException( "Failed to update CatalogRole; currentEntityVersion '%s', expected '%s'", currentCatalogRoleEntity.getEntityVersion(), updateRequest.getCurrentEntityVersion()); } @@ -1371,7 +1371,7 @@ public void deleteCatalogRole(String catalogName, String name) { updatedEntity)))) .orElseThrow( () -> - new CommitFailedException( + new CommitConflictException( "Concurrent modification on CatalogRole '%s'; retry later", name)); return returnedEntity; } diff --git a/service/common/src/main/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalog.java b/service/common/src/main/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalog.java index 7300d21c3d..8acd8622d7 100644 --- a/service/common/src/main/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalog.java +++ b/service/common/src/main/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalog.java @@ -2354,7 +2354,7 @@ private void updateTableLike(TableIdentifier identifier, PolarisEntity entity) { throw new NotFoundException("Parent path does not exist for %s", identifier); case BaseResult.ReturnStatus.TARGET_ENTITY_CONCURRENTLY_MODIFIED: - throw new CommitFailedException( + throw new CommitConflictException( "Failed to commit Table or View %s because it was concurrently modified", identifier); default: diff --git a/service/common/src/main/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalogHandler.java b/service/common/src/main/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalogHandler.java index d8ceea08da..ebcbd4bc71 100644 --- a/service/common/src/main/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalogHandler.java +++ b/service/common/src/main/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalogHandler.java @@ -996,7 +996,7 @@ public void commitTransaction(CommitTransactionRequest commitTransactionRequest) metaStoreManager.updateEntitiesPropertiesIfNotChanged( callContext.getPolarisCallContext(), pendingUpdates); if (!result.isSuccess()) { - // TODO: Retries and server-side cleanup on failure + // TODO: Retries and server-side cleanup on failure, review possible exceptions throw new CommitFailedException( "Transaction commit failed with status: %s, extraInfo: %s", result.getReturnStatus(), result.getExtraInformation());