-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[HUDI-4760] Fixing repeated trigger of data file creations w/ clustering #6561
Merged
nsivabalan
merged 7 commits into
apache:master
from
nsivabalan:clusteringRepeatedTrigger
Sep 26, 2022
Merged
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
a6cf2db
Fixing repeated trigger of clustering execution
nsivabalan cb99645
Fixing proper validation
nsivabalan 402f917
adding tests
nsivabalan 7163ee6
addressing comments
nsivabalan b4152f3
removing unncessary comments
nsivabalan cad9207
fixing build fialure
nsivabalan f9810e7
adding docs
nsivabalan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,8 @@ | |
|
||
package org.apache.hudi.client; | ||
|
||
import org.apache.hudi.avro.model.HoodieClusteringGroup; | ||
import org.apache.hudi.avro.model.HoodieClusteringPlan; | ||
import org.apache.hudi.client.common.HoodieSparkEngineContext; | ||
import org.apache.hudi.client.embedded.EmbeddedTimelineService; | ||
import org.apache.hudi.client.utils.TransactionUtils; | ||
|
@@ -37,7 +39,9 @@ | |
import org.apache.hudi.common.table.timeline.HoodieActiveTimeline; | ||
import org.apache.hudi.common.table.timeline.HoodieInstant; | ||
import org.apache.hudi.common.table.timeline.HoodieTimeline; | ||
import org.apache.hudi.common.util.ClusteringUtils; | ||
import org.apache.hudi.common.util.Option; | ||
import org.apache.hudi.common.util.collection.Pair; | ||
import org.apache.hudi.config.HoodieWriteConfig; | ||
import org.apache.hudi.data.HoodieJavaRDD; | ||
import org.apache.hudi.exception.HoodieClusteringException; | ||
|
@@ -356,6 +360,7 @@ public HoodieWriteMetadata<JavaRDD<WriteStatus>> cluster(String clusteringInstan | |
LOG.info("Starting clustering at " + clusteringInstant); | ||
HoodieWriteMetadata<HoodieData<WriteStatus>> writeMetadata = table.cluster(context, clusteringInstant); | ||
HoodieWriteMetadata<JavaRDD<WriteStatus>> clusteringMetadata = writeMetadata.clone(HoodieJavaRDD.getJavaRDD(writeMetadata.getWriteStatuses())); | ||
validateClusteringCommit(clusteringMetadata, clusteringInstant, table); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's add a comment here why validation has to be here |
||
// TODO : Where is shouldComplete used ? | ||
if (shouldComplete && clusteringMetadata.getCommitMetadata().isPresent()) { | ||
completeTableService(TableServiceType.CLUSTER, clusteringMetadata.getCommitMetadata().get(), table, clusteringInstant); | ||
|
@@ -403,6 +408,19 @@ private void completeClustering(HoodieReplaceCommitMetadata metadata, | |
LOG.info("Clustering successfully on commit " + clusteringCommitTime); | ||
} | ||
|
||
private void validateClusteringCommit(HoodieWriteMetadata<JavaRDD<WriteStatus>> clusteringMetadata, String clusteringCommitTime, HoodieTable table) { | ||
if (clusteringMetadata.getWriteStatuses().isEmpty()) { | ||
HoodieClusteringPlan clusteringPlan = ClusteringUtils.getClusteringPlan( | ||
table.getMetaClient(), HoodieTimeline.getReplaceCommitRequestedInstant(clusteringCommitTime)) | ||
.map(Pair::getRight).orElseThrow(() -> new HoodieClusteringException( | ||
"Unable to read clustering plan for instant: " + clusteringCommitTime)); | ||
throw new HoodieClusteringException("Clustering plan produced 0 WriteStatus for " + clusteringCommitTime | ||
+ " #groups: " + clusteringPlan.getInputGroups().size() + " expected at least " | ||
+ clusteringPlan.getInputGroups().stream().mapToInt(HoodieClusteringGroup::getNumOutputFileGroups).sum() | ||
+ " write statuses"); | ||
} | ||
} | ||
|
||
private void updateTableMetadata(HoodieTable table, HoodieCommitMetadata commitMetadata, | ||
HoodieInstant hoodieInstant) { | ||
boolean isTableServiceAction = table.isTableServiceAction(hoodieInstant.getAction()); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's at least leave a comment (in this PR) that this line was dereferencing RDD 2d time writing out files twice