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


##########
hudi-common/src/main/java/org/apache/hudi/common/table/HoodieTableConfig.java:
##########
@@ -540,27 +541,33 @@ private static void modify(HoodieStorage storage, 
StoragePath metadataFolder, Pr
       // 3. delete the properties file, reads will go to the backup, until we 
are done.
       deleteFile(storage, cfgPath);
 
-      // 4. Upsert and save back.
+      // 4. Upsert and save back, by writing to a temporary file and then 
renaming it
       String checksum;
-      try (OutputStream out = storage.create(cfgPath, true)) {
+      StoragePath tmpCfgPath = new StoragePath(cfgPath.toString() + 
TEMP_SUFFIX);
+      try (OutputStream out = storage.create(tmpCfgPath, true)) {
         propsToUpdate.accept(props, modifyProps);
         propsToDelete.forEach(propToDelete -> props.remove(propToDelete));
-        checksum = storeProperties(props, out, cfgPath);
+        checksum = storeProperties(props, out, tmpCfgPath);
       }
+      storage.rename(tmpCfgPath, cfgPath);

Review Comment:
   should we use `HoodieStorage.createImmutableFileInPath` that can ensure the 
file creation atomicity, BTW, the tmp file is also well handled for any 
exception case.



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