nsivabalan commented on code in PR #7605:
URL: https://github.com/apache/hudi/pull/7605#discussion_r1061889375


##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/table/action/restore/RestoreUtils.java:
##########
@@ -43,4 +45,21 @@ public static HoodieRestorePlan 
getRestorePlan(HoodieTableMetaClient metaClient,
     return TimelineMetadataUtils.deserializeAvroMetadata(
         
metaClient.getActiveTimeline().readRestoreInfoAsBytes(requested).get(), 
HoodieRestorePlan.class);
   }
+
+  /**
+   * Get the restore time for a restore instant
+   * @param table          the HoodieTable
+   * @param restoreInstant Instant referring to restore action
+   * @return restore time of the rollback instant
+   * @throws IOException
+   *
+   * */
+  public static String getRestoreTime(HoodieTable table, HoodieInstant 
restoreInstant) throws IOException {
+    HoodieRestorePlan plan = getRestorePlan(table.getMetaClient(), 
restoreInstant);

Review Comment:
   I am thinking if we can add an entry to HoodieRestorePlan (avro model) to 
store the savepoint commit timestamp only. that would make life easier. 



##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/client/BaseHoodieWriteClient.java:
##########
@@ -840,11 +841,25 @@ public boolean rollback(final String commitInstantTime, 
Option<HoodiePendingRoll
    */
   public HoodieRestoreMetadata restoreToInstant(final String instantTime, 
boolean initialMetadataTableIfNecessary) throws HoodieRestoreException {
     LOG.info("Begin restore to instant " + instantTime);
-    final String restoreInstantTime = 
HoodieActiveTimeline.createNewInstantTime();
+    final String restoreInstantTime;
     Timer.Context timerContext = metrics.getRollbackCtx();
+    Option<HoodieRestorePlan> restorePlanOption;
     try {
-      HoodieTable<T, I, K, O> table = initTable(WriteOperationType.UNKNOWN, 
Option.of(restoreInstantTime), initialMetadataTableIfNecessary);
-      Option<HoodieRestorePlan> restorePlanOption = 
table.scheduleRestore(context, restoreInstantTime, instantTime);
+      //Use the previous restore if it failed
+      HoodieTable<T, I, K, O> table = initTable(WriteOperationType.UNKNOWN, 
Option.empty(), initialMetadataTableIfNecessary);
+      Option<HoodieInstant> failedRestore = 
table.getRestoreTimeline().filterInflightsAndRequested().lastInstant();

Review Comment:
   why just check for lastInstant. it can be anything right. 
   



##########
hudi-common/src/main/java/org/apache/hudi/common/table/timeline/HoodieActiveTimeline.java:
##########
@@ -578,6 +578,21 @@ public HoodieInstant 
transitionRestoreRequestedToInflight(HoodieInstant requeste
     return inflight;
   }
 
+  /**
+   * Transition Restore State from inflight to requested.
+   *
+   * @param inflightInstant inflight instant
+   * @return commit instant
+   */
+  public HoodieInstant transitionRestoreInflightToRequested(HoodieInstant 
inflightInstant) {
+    
ValidationUtils.checkArgument(inflightInstant.getAction().equals(HoodieTimeline.RESTORE_ACTION),
 "Transition to requested attempted for a restore instant with diff action "
+        + inflightInstant);
+    ValidationUtils.checkArgument(inflightInstant.isInflight(), "Transition to 
requested attempted for an instant not in inflight state " + inflightInstant);
+    HoodieInstant requested = new HoodieInstant(State.REQUESTED, 
RESTORE_ACTION, inflightInstant.getTimestamp());
+    transitionState(inflightInstant, requested, Option.empty());

Review Comment:
   not sure if we can do this. we can just delete the inflight and make 
progress. we don't want to requested to be overwritten just incase. 



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