danny0405 commented on code in PR #13368:
URL: https://github.com/apache/hudi/pull/13368#discussion_r2113011328


##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/client/BaseHoodieTableServiceClient.java:
##########
@@ -1136,36 +1135,48 @@ public boolean rollback(final String commitInstantTime, 
Option<HoodiePendingRoll
       Option<HoodieInstant> commitInstantOpt = 
Option.fromJavaOptional(table.getActiveTimeline().getCommitsTimeline().getInstantsAsStream()
           .filter(instant -> EQUALS.test(instant.requestedTime(), 
commitInstantTime))
           .findFirst());
-      if (commitInstantOpt.isPresent() || pendingRollbackInfo.isPresent()) {
-        LOG.info("Scheduling Rollback at instant time : {} "
-                + "(exists in active timeline: {}), with rollback plan: {} for 
table {}",
-            rollbackInstantTime, commitInstantOpt.isPresent(), 
pendingRollbackInfo.isPresent(), config.getBasePath());
-        Option<HoodieRollbackPlan> rollbackPlanOption = 
pendingRollbackInfo.map(entry -> Option.of(entry.getRollbackPlan()))
-            .orElseGet(() -> table.scheduleRollback(context, 
rollbackInstantTime, commitInstantOpt.get(), false, 
config.shouldRollbackUsingMarkers(),
-                false));
-        if (rollbackPlanOption.isPresent()) {
-          // There can be a case where the inflight rollback failed after the 
instant files
-          // are deleted for commitInstantTime, so that commitInstantOpt is 
empty as it is
-          // not present in the timeline.  In such a case, the hoodie instant 
instance
-          // is reconstructed to allow the rollback to be reattempted, and the 
deleteInstants
-          // is set to false since they are already deleted.
-          // Execute rollback
-          HoodieRollbackMetadata rollbackMetadata = 
commitInstantOpt.isPresent()
-              ? table.rollback(context, rollbackInstantTime, 
commitInstantOpt.get(), true, skipLocking)
-              : table.rollback(context, rollbackInstantTime, 
table.getMetaClient().createNewInstant(
-                  HoodieInstant.State.INFLIGHT, 
rollbackPlanOption.get().getInstantToRollback().getAction(), commitInstantTime),
-              false, skipLocking);
-          if (timerContext != null) {
-            long durationInMs = metrics.getDurationInMs(timerContext.stop());
-            metrics.updateRollbackMetrics(durationInMs, 
rollbackMetadata.getTotalFilesDeleted());
+      Option<HoodieRollbackPlan> rollbackPlanOption;
+      String rollbackInstantTime;
+      if (pendingRollbackInfo.isPresent()) {
+        rollbackPlanOption = 
Option.of(pendingRollbackInfo.get().getRollbackPlan());
+        rollbackInstantTime = 
pendingRollbackInfo.get().getRollbackInstant().requestedTime();
+      } else {
+        if (!skipLocking) {
+          txnManager.beginTransaction(Option.empty(), Option.empty());
+        }
+        try {
+          rollbackInstantTime = suppliedRollbackInstantTime.orElseGet(() -> 
createNewInstantTime(false));
+          if (commitInstantOpt.isEmpty()) {

Review Comment:
   we can move it to 1144 to avoid unnecessary lock.



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