danny0405 commented on code in PR #18350:
URL: https://github.com/apache/hudi/pull/18350#discussion_r3049240330


##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/metadata/HoodieBackedTableMetadataWriter.java:
##########
@@ -1747,22 +1745,25 @@ public void update(HoodieRestoreMetadata 
restoreMetadata, String instantTime) {
       // We cannot create a deltaCommit at instantTime now because a future 
(rollback) block has already been written to the logFiles.
       // We need to choose a timestamp which would be a validInstantTime for 
MDT. This is either a commit timestamp completed on the dataset
       // or a new timestamp which we use for MDT clean, compaction etc.
-      String syncCommitTime = createRestoreInstantTime();
-      processAndCommit(syncCommitTime, () -> {
-        // For Files partition.
-        Map<String, HoodieData<HoodieRecord>> partitionRecords = new 
HashMap<>();
-        
partitionRecords.putAll(HoodieTableMetadataUtil.convertMissingPartitionRecords(engineContext,
-            partitionsToDelete, partitionFilesToAdd, partitionFilesToDelete, 
syncCommitTime));
-        // For ColumnStats partition if enabled.
-        if 
(dataMetaClient.getTableConfig().getMetadataPartitions().contains(COLUMN_STATS.getPartitionPath()))
 {
-          partitionRecords.putAll(convertToColumnStatsRecord(
-              partitionFilesToAdd, partitionFilesToDelete, engineContext, 
dataMetaClient,
-              dataWriteConfig.getMetadataConfig(), 
Option.of(dataWriteConfig.getRecordMerger().getRecordType()),
-              
dataWriteConfig.getMetadataConfig().getColumnStatsIndexParallelism()));
-        }
-        return partitionRecords;
+      
writeClient.getTransactionManager().executeStateChangeWithInstant(metadataTableCommit
 -> {
+        String syncCommitTime = createRestoreTimestamp(metadataTableCommit);
+        processAndCommit(syncCommitTime, () -> {
+          // For Files partition.
+          Map<String, HoodieData<HoodieRecord>> partitionRecords = new 
HashMap<>();
+          
partitionRecords.putAll(HoodieTableMetadataUtil.convertMissingPartitionRecords(engineContext,
+              partitionsToDelete, partitionFilesToAdd, partitionFilesToDelete, 
syncCommitTime));
+          // For ColumnStats partition if enabled.
+          if 
(dataMetaClient.getTableConfig().getMetadataPartitions().contains(COLUMN_STATS.getPartitionPath()))
 {
+            partitionRecords.putAll(convertToColumnStatsRecord(
+                partitionFilesToAdd, partitionFilesToDelete, engineContext, 
dataMetaClient,
+                dataWriteConfig.getMetadataConfig(), 
Option.of(dataWriteConfig.getRecordMerger().getRecordType()),
+                
dataWriteConfig.getMetadataConfig().getColumnStatsIndexParallelism()));
+          }
+          return partitionRecords;
+        });
+        // empty result
+        return Option.empty();
       });
-      closeInternal();
     } catch (IOException e) {
       throw new HoodieMetadataException("IOException during MDT restore sync", 
e);
     }

Review Comment:
   add it back.



-- 
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]

Reply via email to