dimas-b commented on code in PR #1285:
URL: https://github.com/apache/polaris/pull/1285#discussion_r2096452402


##########
service/common/src/main/java/org/apache/polaris/service/catalog/iceberg/CatalogHandlerUtils.java:
##########
@@ -433,39 +446,173 @@ protected TableMetadata commit(TableOperations ops, 
UpdateTableRequest request)
               2.0 /* exponential */)
           .onlyRetryOn(CommitFailedException.class)
           .run(
-              taskOps -> {
+              (taskOps) -> {
                 TableMetadata base = isRetry.get() ? taskOps.refresh() : 
taskOps.current();
-                isRetry.set(true);
 
-                // validate requirements
+                TableMetadata.Builder metadataBuilder = 
TableMetadata.buildFrom(base);
+                TableMetadata newBase = base;
                 try {
-                  request.requirements().forEach(requirement -> 
requirement.validate(base));
+                  request.requirements().forEach((requirement) -> 
requirement.validate(base));
                 } catch (CommitFailedException e) {
-                  // wrap and rethrow outside of tasks to avoid unnecessary 
retry
-                  throw new ValidationFailureException(e);
+                  if (!isRollbackCompactionEnabled()) {
+                    throw new ValidationFailureException(e);
+                  }
+                  UpdateRequirement.AssertRefSnapshotID assertRefSnapshotId =
+                      findAssertRefSnapshotID(request);
+                  MetadataUpdate.SetSnapshotRef setSnapshotRef = 
findSetSnapshotRefUpdate(request);
+
+                  if (assertRefSnapshotId == null || setSnapshotRef == null) {
+                    // This implies the request was not trying to add a 
snapshot.
+                    throw new ValidationFailureException(e);
+                  }
+
+                  // snapshot-id the client expects the table 
current_snapshot_id
+                  long expectedCurrentSnapshotId = 
assertRefSnapshotId.snapshotId();

Review Comment:
   This catch block is huge... Would you mind extracting it into a method?



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