snazy commented on code in PR #2219: URL: https://github.com/apache/polaris/pull/2219#discussion_r2247639330
########## persistence/relational-jdbc/src/main/java/org/apache/polaris/persistence/relational/jdbc/JdbcBasePersistenceImpl.java: ########## @@ -183,11 +183,17 @@ private void persistEntity( entity.getParentId(), entity.getTypeCode(), entity.getName()); - throw new EntityAlreadyExistsException(existingEntity, e); - } else { - throw new RuntimeException( - String.format("Failed to write entity due to %s", e.getMessage()), e); + // This happens in two scenarios: + // 1. PRIMARY KEY violated + // 2. UNIQUE CONSTRAINT on (realm_id, catalog_id, parent_id, type_code, name) violated + // With SERIALIZABLE isolation, the conflicting entity may _not_ be visible and + // existingEntity can be null, which would cause an NPE in + // EntityAlreadyExistsException.message(). + throw new EntityAlreadyExistsException( + existingEntity != null ? existingEntity : entity, e); Review Comment: That should IMHO be added as part of testing against different isolation level against the implementation. -- 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: issues-unsubscr...@polaris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org