singhpk234 commented on code in PR #3352:
URL: https://github.com/apache/polaris/pull/3352#discussion_r2660633864


##########
persistence/relational-jdbc/src/main/java/org/apache/polaris/persistence/relational/jdbc/JdbcBasePersistenceImpl.java:
##########
@@ -137,6 +139,14 @@ public void writeEntities(
       @Nonnull PolarisCallContext callCtx,
       @Nonnull List<PolarisBaseEntity> entities,
       List<PolarisBaseEntity> originalEntities) {
+    Set<Long> seenEntityIds = new HashSet<>();
+    for (PolarisBaseEntity entity : entities) {
+      if (!seenEntityIds.add(entity.getId())) {
+        throw new RetryOnConcurrencyException(
+            "Multiple updates to entity id '%s' in the same transaction", 
entity.getId());
+      }
+    }

Review Comment:
     Here's the difference and why its required:
   
     PostgreSQL SERIALIZABLE:
     - Uses Serializable Snapshot Isolation (SSI)
     - When it detects a write-write conflict within the same transaction, it 
typically throws SQLSTATE 40001 (serialization_failure) immediately
     - It's designed to fail fast rather than retry
   
     CockroachDB SERIALIZABLE:
     - Has automatic retry logic built-in at the database level
     - When it detects a conflict, it enters an internal retry loop hoping the 
conflict resolves
     - For conflicts within the same transaction (unresolvable), it can get 
stuck retrying
   



-- 
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]

Reply via email to