This is an automated email from the ASF dual-hosted git repository.
codope pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hudi.git
The following commit(s) were added to refs/heads/master by this push:
new 4dbe5b80d39 [HUDI-8035] Fetching commit metadata from timeline fails
during upgrade (#11711)
4dbe5b80d39 is described below
commit 4dbe5b80d394d44b94b47a8442bb1b9c9a79c4cf
Author: Lokesh Jain <[email protected]>
AuthorDate: Thu Aug 1 13:38:51 2024 +0530
[HUDI-8035] Fetching commit metadata from timeline fails during upgrade
(#11711)
---
.../hudi/common/table/timeline/HoodieInstant.java | 18 ++++++++++++++----
.../table/timeline/TestHoodieActiveTimeline.java | 1 +
2 files changed, 15 insertions(+), 4 deletions(-)
diff --git
a/hudi-common/src/main/java/org/apache/hudi/common/table/timeline/HoodieInstant.java
b/hudi-common/src/main/java/org/apache/hudi/common/table/timeline/HoodieInstant.java
index c8f1bd615c8..f21092d345b 100644
---
a/hudi-common/src/main/java/org/apache/hudi/common/table/timeline/HoodieInstant.java
+++
b/hudi-common/src/main/java/org/apache/hudi/common/table/timeline/HoodieInstant.java
@@ -24,6 +24,7 @@ import org.apache.hudi.storage.StoragePathInfo;
import java.io.Serializable;
import java.util.Comparator;
+import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
@@ -111,6 +112,8 @@ public class HoodieInstant implements Serializable,
Comparable<HoodieInstant> {
private final String action;
private final String timestamp;
private final String completionTime;
+ // Marker for older formats, we need the state transition time (pre table
version 7)
+ private boolean isLegacy = false;
/**
* Load the instant from the meta FileStatus.
@@ -136,10 +139,17 @@ public class HoodieInstant implements Serializable,
Comparable<HoodieInstant> {
state = State.COMPLETED;
}
}
- completionTime = timestamps.length > 1
- ? timestamps[1]
+ if (state == State.COMPLETED) {
+ if (timestamps.length > 1) {
+ completionTime = timestamps[1];
+ } else {
// for backward compatibility with 0.x release.
- : state == State.COMPLETED ? pathInfo.getModificationTime() + "" :
null;
+ completionTime = HoodieInstantTimeGenerator.formatDate(new
Date(pathInfo.getModificationTime()));
+ isLegacy = true;
+ }
+ } else {
+ completionTime = null;
+ }
} else {
throw new IllegalArgumentException("Failed to construct HoodieInstant: "
+ String.format(FILE_NAME_FORMAT_ERROR, fileName));
}
@@ -270,7 +280,7 @@ public class HoodieInstant implements Serializable,
Comparable<HoodieInstant> {
private String getCompleteFileName(String completionTime) {
ValidationUtils.checkArgument(!StringUtils.isNullOrEmpty(completionTime),
"Completion time should not be empty");
- String timestampWithCompletionTime = timestamp + "_" + completionTime;
+ String timestampWithCompletionTime = isLegacy ? timestamp : timestamp +
"_" + completionTime;
switch (action) {
case HoodieTimeline.COMMIT_ACTION:
case HoodieTimeline.COMPACTION_ACTION:
diff --git
a/hudi-hadoop-common/src/test/java/org/apache/hudi/common/table/timeline/TestHoodieActiveTimeline.java
b/hudi-hadoop-common/src/test/java/org/apache/hudi/common/table/timeline/TestHoodieActiveTimeline.java
index def0268e5c0..46c33d526b9 100755
---
a/hudi-hadoop-common/src/test/java/org/apache/hudi/common/table/timeline/TestHoodieActiveTimeline.java
+++
b/hudi-hadoop-common/src/test/java/org/apache/hudi/common/table/timeline/TestHoodieActiveTimeline.java
@@ -719,6 +719,7 @@ public class TestHoodieActiveTimeline extends
HoodieCommonTestHarness {
assertNull(instants.get(0).getCompletionTime(), "Requested instant does
not have completion time");
assertNull(instants.get(1).getCompletionTime(), "Inflight instant does not
have completion time");
assertNotNull(instants.get(2).getCompletionTime(), "Completed instant has
modification time as completion time for 0.x release");
+ assertEquals(instants.get(2).getTimestamp() +
HoodieTimeline.COMMIT_EXTENSION, instants.get(2).getFileName(), "Instant file
name should not have completion time");
}
/**