n3nash commented on a change in pull request #2359:
URL: https://github.com/apache/hudi/pull/2359#discussion_r578216168
##########
File path:
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/client/AbstractHoodieWriteClient.java
##########
@@ -749,22 +739,49 @@ private HoodieTimeline
getInflightTimelineExcludeCompactionAndClustering(HoodieT
}
/**
- * Cleanup all pending commits.
+ * Rollback all failed writes.
*/
- private void rollbackPendingCommits() {
+ public Boolean rollbackFailedWrites() {
HoodieTable<T, I, K, O> table = createTable(config, hadoopConf);
- HoodieTimeline inflightTimeline =
getInflightTimelineExcludeCompactionAndClustering(table);
- List<String> commits =
inflightTimeline.getReverseOrderedInstants().map(HoodieInstant::getTimestamp)
- .collect(Collectors.toList());
- for (String commit : commits) {
- if (HoodieTimeline.compareTimestamps(commit,
HoodieTimeline.LESSER_THAN_OR_EQUALS,
+ List<String> instantsToRollback = getInstantsToRollback(table);
+ for (String instant : instantsToRollback) {
+ if (HoodieTimeline.compareTimestamps(instant,
HoodieTimeline.LESSER_THAN_OR_EQUALS,
HoodieTimeline.FULL_BOOTSTRAP_INSTANT_TS)) {
- rollBackInflightBootstrap();
+ rollbackFailedBootstrap();
break;
} else {
- rollback(commit);
+ rollback(instant);
}
}
+ // Delete any heartbeat files for already rolled back commits
+ try {
+
HeartbeatUtils.cleanExpiredHeartbeats(this.heartbeatClient.getExistingHeartbeatInstantFileNames(),
+ createMetaClient(true), basePath);
+ } catch (IOException io) {
+ LOG.error("Unable to delete heartbeat files", io);
+ }
+ return true;
+ }
+
+ private List<String> getInstantsToRollback(HoodieTable<T, I, K, O> table) {
+ if (config.getFailedWritesCleanPolicy().isEager()) {
Review comment:
Would like to keep if-else since I don't see the types of policies
growing at this point.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]