jonvex commented on code in PR #7605:
URL: https://github.com/apache/hudi/pull/7605#discussion_r1063758391
##########
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();
+ if (failedRestore.isPresent() &&
instantTime.equals(RestoreUtils.getRestoreTime(table, failedRestore.get()))) {
+ if (failedRestore.get().isRequested()) {
+
table.getActiveTimeline().transitionRestoreRequestedToInflight(failedRestore.get());
+ }
+ restoreInstantTime = failedRestore.get().getTimestamp();
+ restorePlanOption =
Option.of(RestoreUtils.getRestorePlan(table.getMetaClient(),
failedRestore.get()));
+ } else {
+ restoreInstantTime = HoodieActiveTimeline.createNewInstantTime();
+ table = initTable(WriteOperationType.UNKNOWN,
Option.of(restoreInstantTime), initialMetadataTableIfNecessary);
+ restorePlanOption = table.scheduleRestore(context, restoreInstantTime,
instantTime);
Review Comment:
Ok I did this but it's pretty ugly because I have to return 3 things
--
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]