yihua commented on code in PR #5837:
URL: https://github.com/apache/hudi/pull/5837#discussion_r928144340
##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/client/HoodieTimelineArchiver.java:
##########
@@ -491,14 +503,33 @@ private Stream<HoodieInstant> getInstantsToArchive() {
// active timeline. This is required by metadata table,
// see HoodieTableMetadataUtil#processRollbackMetadata for details.
if (HoodieTableMetadata.isMetadataTable(config.getBasePath())) {
- HoodieTableMetaClient dataMetaClient = HoodieTableMetaClient.builder()
-
.setBasePath(HoodieTableMetadata.getDatasetBasePath(config.getBasePath()))
+ HoodieTableMetaClient metadataTableMetaClient =
HoodieTableMetaClient.builder()
Review Comment:
This is the meta client for the data table, not the metadata table.
##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/client/HoodieTimelineArchiver.java:
##########
@@ -491,14 +503,33 @@ private Stream<HoodieInstant> getInstantsToArchive() {
// active timeline. This is required by metadata table,
// see HoodieTableMetadataUtil#processRollbackMetadata for details.
if (HoodieTableMetadata.isMetadataTable(config.getBasePath())) {
- HoodieTableMetaClient dataMetaClient = HoodieTableMetaClient.builder()
-
.setBasePath(HoodieTableMetadata.getDatasetBasePath(config.getBasePath()))
+ HoodieTableMetaClient metadataTableMetaClient =
HoodieTableMetaClient.builder()
+ .setBasePath(getDatasetBasePath(config.getBasePath()))
.setConf(metaClient.getHadoopConf())
.build();
- Option<String> earliestActiveDatasetCommit =
dataMetaClient.getActiveTimeline().firstInstant().map(HoodieInstant::getTimestamp);
- if (earliestActiveDatasetCommit.isPresent()) {
+ Option<HoodieInstant> earliestActiveDatasetCommit =
metadataTableMetaClient.getActiveTimeline().firstInstant();
+
+ // There are chances that there could be holes in the timeline due to
archival and savepoint interplay.
+ // So, the first non-savepoint commit in the data timeline is considered
as beginning of the active timeline.
+ HoodieTableMetaClient dataTableMetaClient =
HoodieTableMetaClient.builder()
+
.setBasePath(getDataTableBasePathFromMetadataTable(config.getBasePath()))
+ .setConf(metaClient.getHadoopConf())
+ .build();
+ Set<String> savepointTimestamps =
dataTableMetaClient.getActiveTimeline().getInstants()
+ .filter(entry ->
entry.getAction().equals(HoodieTimeline.SAVEPOINT_ACTION))
+ .map(HoodieInstant::getTimestamp)
+ .collect(Collectors.toSet());
+ Option<HoodieInstant> firstNonSavepointCommit =
earliestActiveDatasetCommit;
+ if (!savepointTimestamps.isEmpty()) {
+ firstNonSavepointCommit =
Option.fromJavaOptional(dataTableMetaClient.getActiveTimeline().getInstants()
+ .filter(entry ->
!savepointTimestamps.contains(entry.getTimestamp()))
+ .findFirst());
+ }
Review Comment:
Should the new logic be guarded by `config.shouldArchiveBeyondSavepoint()`
as well? So that, if the feature flag is off and there are savepoints in the
data table, there is no behavior change, i.e., archival does not go beyond
saved commits in the metadata table either.
##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/client/HoodieTimelineArchiver.java:
##########
@@ -491,14 +503,33 @@ private Stream<HoodieInstant> getInstantsToArchive() {
// active timeline. This is required by metadata table,
// see HoodieTableMetadataUtil#processRollbackMetadata for details.
if (HoodieTableMetadata.isMetadataTable(config.getBasePath())) {
- HoodieTableMetaClient dataMetaClient = HoodieTableMetaClient.builder()
-
.setBasePath(HoodieTableMetadata.getDatasetBasePath(config.getBasePath()))
+ HoodieTableMetaClient metadataTableMetaClient =
HoodieTableMetaClient.builder()
+ .setBasePath(getDatasetBasePath(config.getBasePath()))
.setConf(metaClient.getHadoopConf())
.build();
- Option<String> earliestActiveDatasetCommit =
dataMetaClient.getActiveTimeline().firstInstant().map(HoodieInstant::getTimestamp);
- if (earliestActiveDatasetCommit.isPresent()) {
+ Option<HoodieInstant> earliestActiveDatasetCommit =
metadataTableMetaClient.getActiveTimeline().firstInstant();
+
+ // There are chances that there could be holes in the timeline due to
archival and savepoint interplay.
+ // So, the first non-savepoint commit in the data timeline is considered
as beginning of the active timeline.
+ HoodieTableMetaClient dataTableMetaClient =
HoodieTableMetaClient.builder()
+
.setBasePath(getDataTableBasePathFromMetadataTable(config.getBasePath()))
+ .setConf(metaClient.getHadoopConf())
+ .build();
Review Comment:
You can reuse the data table meta client above.
--
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]