Skip to content

Commit 0cf173f

Browse files
committed
wrap delete all in transaction
1 parent f93e5a8 commit 0cf173f

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

extension/persistence/relational-jdbc/src/main/java/org/apache/polaris/extension/persistence/relational/jdbc/JdbcBasePersistenceImpl.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -251,12 +251,15 @@ public void deleteAllEntityGrantRecords(
251251
@Override
252252
public void deleteAll(@Nonnull PolarisCallContext callCtx) {
253253
try {
254-
datasourceOperations.executeUpdate(generateDeleteAll(ModelEntity.class, realmId));
255-
datasourceOperations.executeUpdate(generateDeleteAll(ModelGrantRecord.class, realmId));
256-
datasourceOperations.executeUpdate(
257-
generateDeleteAll(ModelPrincipalAuthenticationData.class, realmId));
258-
datasourceOperations.executeUpdate(
259-
generateDeleteAll(ModelPolicyMappingRecord.class, realmId));
254+
datasourceOperations.runWithinTransaction(
255+
statement -> {
256+
statement.executeUpdate(generateDeleteAll(ModelEntity.class, realmId));
257+
statement.executeUpdate(generateDeleteAll(ModelGrantRecord.class, realmId));
258+
statement.executeUpdate(
259+
generateDeleteAll(ModelPrincipalAuthenticationData.class, realmId));
260+
statement.executeUpdate(generateDeleteAll(ModelPolicyMappingRecord.class, realmId));
261+
return true;
262+
});
260263
} catch (SQLException e) {
261264
throw new RuntimeException(
262265
String.format("Failed to delete all due to %s", e.getMessage()), e);

0 commit comments

Comments
 (0)