Rajeev-01 commented on code in PR #13740:
URL: https://github.com/apache/hudi/pull/13740#discussion_r2289699555
##########
hudi-common/src/main/java/org/apache/hudi/common/util/ConfigUtils.java:
##########
@@ -685,11 +686,37 @@ public static TypedProperties fetchConfigs(
public static void recoverIfNeeded(HoodieStorage storage, StoragePath
cfgPath,
StoragePath backupCfgPath) throws
IOException {
+ boolean needCopy = false;
if (!storage.exists(cfgPath)) {
- // copy over from backup
- try (InputStream in = storage.open(backupCfgPath);
- OutputStream out = storage.create(cfgPath, false)) {
- FileIOUtils.copy(in, out);
+ needCopy = true;
+ } else {
+ TypedProperties props = new TypedProperties();
+ try (InputStream in = storage.open(cfgPath)) {
+ props.load(in);
+ if (!props.containsKey(TABLE_CHECKSUM.key()) ||
!HoodieTableConfig.validateChecksum(props)) {
+ // the cfg file is invalid
+ storage.deleteFile(cfgPath);
+ needCopy = true;
+ }
+ }
+ }
+ if (needCopy && storage.exists(backupCfgPath)) {
Review Comment:
Need not be true, since we are checking if the existing properties is also
valid, backup may or may not be present. If present we can proceed by checking
the validity of backup and proceed by retrieving otherwise delete and fail.
--
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]