shangxinli commented on code in PR #20276:
URL: https://github.com/apache/hudi/pull/20276#discussion_r4298026964


##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/client/BaseHoodieWriteClient.java:
##########
@@ -1710,11 +1712,31 @@ protected void tryUpgrade(HoodieTableMetaClient 
metaClient, Option<String> insta
       metaClient.reloadTableConfig();
       metaClient.reloadActiveTimeline();
     }
+
+    backfillTableConfigs(metaClient);
+  }
+
+  private void backfillTableConfigs(HoodieTableMetaClient metaClient) {
+    if 
(!HoodieTableConfig.getMissingKeyGeneratorClass(metaClient.getTableConfig()).isPresent())
 {
+      return;
+    }
+    // another writer may have backfilled the table since this meta client 
loaded its config
+    metaClient.reloadTableConfig();
+    Option<String> missingKeyGeneratorClass = 
HoodieTableConfig.getMissingKeyGeneratorClass(metaClient.getTableConfig());
+    if (missingKeyGeneratorClass.isPresent()) {
+      log.info("Backfilling {}={} for table {}", 
HoodieTableConfig.KEY_GENERATOR_CLASS_NAME.key(),
+          missingKeyGeneratorClass.get(), metaClient.getBasePath());
+      Properties updatedProps = new Properties();
+      
updatedProps.setProperty(HoodieTableConfig.KEY_GENERATOR_CLASS_NAME.key(), 
missingKeyGeneratorClass.get());
+      HoodieTableConfig.update(metaClient.getStorage(), 
metaClient.getMetaPath(), updatedProps);

Review Comment:
   **minor:** tryUpgrade's javadoc says it is called within a lock, but 
HoodieFlinkWriteClient.tryUpgrade reaches it from 
StreamWriteOperatorCoordinator.start():243 with no txn manager - same exposure 
UpgradeDowngrade already has there, so possibly fine.



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