singhpk234 commented on code in PR #2219: URL: https://github.com/apache/polaris/pull/2219#discussion_r2248582752
########## 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: is sending entity which is not committed i.e `entity` the right thing to throw back in the exception https://github.com/apache/polaris/blob/main/polaris-core/src/main/java/org/apache/polaris/core/persistence/EntityAlreadyExistsException.java#L33 Error message has the entity id message in it and the message in this case is not correct, i don;t know what else to throw though Hence was requesting to add a test ? -- 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