-
Notifications
You must be signed in to change notification settings - Fork 2.5k
[HUDI-2285][HUDI-2476] Metadata table synchronous design. Rebased and Squashed from pull/3426 #3590
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -61,6 +61,7 @@ | |
| import org.apache.hudi.exception.HoodieRollbackException; | ||
| import org.apache.hudi.exception.HoodieSavepointException; | ||
| import org.apache.hudi.index.HoodieIndex; | ||
| import org.apache.hudi.metadata.HoodieTableMetadataWriter; | ||
| import org.apache.hudi.metrics.HoodieMetrics; | ||
| import org.apache.hudi.table.BulkInsertPartitioner; | ||
| import org.apache.hudi.table.HoodieTable; | ||
|
|
@@ -241,13 +242,16 @@ void emitCommitMetrics(String instantTime, HoodieCommitMetadata metadata, String | |
| } | ||
| } | ||
|
|
||
| /** | ||
| * Any pre-commit actions like conflict resolution or updating metadata table goes here. | ||
| * @param instantTime commit instant time. | ||
| * @param metadata commit metadata for which pre commit is being invoked. | ||
| */ | ||
| protected void preCommit(String instantTime, HoodieCommitMetadata metadata) { | ||
| // no-op | ||
| // TODO : Conflict resolution is not supported for Flink & Java engines | ||
| } | ||
|
|
||
| protected void syncTableMetadata() { | ||
| // no-op | ||
| // Create a Hoodie table after starting the transaction which encapsulated the commits and files visible. | ||
| // Important to create this after the lock to ensure latest commits show up in the timeline without need for reload | ||
|
||
| HoodieTable table = createTable(config, hadoopConf); | ||
| table.getMetadataWriter().ifPresent(w -> ((HoodieTableMetadataWriter)w).update(metadata, instantTime)); | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -404,16 +408,6 @@ protected void preWrite(String instantTime, WriteOperationType writeOperationTyp | |
| HoodieTableMetaClient metaClient) { | ||
| setOperationType(writeOperationType); | ||
| this.lastCompletedTxnAndMetadata = TransactionUtils.getLastCompletedTxnInstantAndMetadata(metaClient); | ||
| this.txnManager.beginTransaction(Option.of(new HoodieInstant(State.INFLIGHT, metaClient.getCommitActionType(), instantTime)), lastCompletedTxnAndMetadata | ||
| .isPresent() | ||
| ? Option.of(lastCompletedTxnAndMetadata.get().getLeft()) : Option.empty()); | ||
| try { | ||
| if (writeOperationType != WriteOperationType.CLUSTER && writeOperationType != WriteOperationType.COMPACT) { | ||
| syncTableMetadata(); | ||
| } | ||
| } finally { | ||
| this.txnManager.endTransaction(); | ||
| } | ||
| this.asyncCleanerService = AsyncCleanerService.startAsyncCleaningIfEnabled(this); | ||
| } | ||
|
|
||
|
|
@@ -443,9 +437,6 @@ protected void postCommit(HoodieTable<T, I, K, O> table, HoodieCommitMetadata me | |
| // We cannot have unbounded commit files. Archive commits if we have to archive | ||
| HoodieTimelineArchiveLog archiveLog = new HoodieTimelineArchiveLog(config, table); | ||
| archiveLog.archiveIfRequired(context); | ||
| if (operationType != null && operationType != WriteOperationType.CLUSTER && operationType != WriteOperationType.COMPACT) { | ||
| syncTableMetadata(); | ||
| } | ||
| } catch (IOException ioe) { | ||
| throw new HoodieIOException(ioe.getMessage(), ioe); | ||
| } finally { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.