This is an automated email from the ASF dual-hosted git repository. codope pushed a commit to branch release-0.12.0 in repository https://gitbox.apache.org/repos/asf/hudi.git
commit c647af536e08a289537512b97a74bd1ba3ede0e6 Author: Danny Chan <[email protected]> AuthorDate: Fri Jul 29 23:32:19 2022 +0800 [HUDI-4505] Returns instead of throws if lock file exists for FileSystemBasedLockProvider (#6242) To avoid unnecessary exception throws --- .../transaction/lock/FileSystemBasedLockProvider.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/hudi-client/hudi-client-common/src/main/java/org/apache/hudi/client/transaction/lock/FileSystemBasedLockProvider.java b/hudi-client/hudi-client-common/src/main/java/org/apache/hudi/client/transaction/lock/FileSystemBasedLockProvider.java index 96a42e8409..4135ef9acd 100644 --- a/hudi-client/hudi-client-common/src/main/java/org/apache/hudi/client/transaction/lock/FileSystemBasedLockProvider.java +++ b/hudi-client/hudi-client-common/src/main/java/org/apache/hudi/client/transaction/lock/FileSystemBasedLockProvider.java @@ -54,8 +54,8 @@ public class FileSystemBasedLockProvider implements LockProvider<String>, Serial private static final String LOCK_FILE_NAME = "lock"; private final int lockTimeoutMinutes; - private transient FileSystem fs; - private transient Path lockFile; + private final transient FileSystem fs; + private final transient Path lockFile; protected LockConfiguration lockConfiguration; public FileSystemBasedLockProvider(final LockConfiguration lockConfiguration, final Configuration configuration) { @@ -87,8 +87,13 @@ public class FileSystemBasedLockProvider implements LockProvider<String>, Serial try { synchronized (LOCK_FILE_NAME) { // Check whether lock is already expired, if so try to delete lock file - if (fs.exists(this.lockFile) && checkIfExpired()) { - fs.delete(this.lockFile, true); + if (fs.exists(this.lockFile)) { + if (checkIfExpired()) { + fs.delete(this.lockFile, true); + LOG.warn("Delete expired lock file: " + this.lockFile); + } else { + return false; + } } acquireLock(); return fs.exists(this.lockFile); @@ -123,7 +128,7 @@ public class FileSystemBasedLockProvider implements LockProvider<String>, Serial } try { long modificationTime = fs.getFileStatus(this.lockFile).getModificationTime(); - if (System.currentTimeMillis() - modificationTime > lockTimeoutMinutes * 60 * 1000) { + if (System.currentTimeMillis() - modificationTime > lockTimeoutMinutes * 60 * 1000L) { return true; } } catch (IOException | HoodieIOException e) {
