-
Notifications
You must be signed in to change notification settings - Fork 2.4k
[HUDI-9158] Add storage-based lock provider abstract implementation #13103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@hudi-bot run azure |
...mmon/src/main/java/org/apache/hudi/client/transaction/lock/ConditionalWriteLockProvider.java
Outdated
Show resolved
Hide resolved
...common/src/main/java/org/apache/hudi/client/transaction/lock/ConditionalWriteLockConfig.java
Outdated
Show resolved
Hide resolved
...common/src/main/java/org/apache/hudi/client/transaction/lock/ConditionalWriteLockConfig.java
Outdated
Show resolved
Hide resolved
...common/src/main/java/org/apache/hudi/client/transaction/lock/ConditionalWriteLockConfig.java
Outdated
Show resolved
Hide resolved
...common/src/main/java/org/apache/hudi/client/transaction/lock/ConditionalWriteLockConfig.java
Outdated
Show resolved
Hide resolved
...common/src/main/java/org/apache/hudi/client/transaction/lock/ConditionalWriteLockConfig.java
Outdated
Show resolved
Hide resolved
...common/src/main/java/org/apache/hudi/client/transaction/lock/ConditionalWriteLockConfig.java
Outdated
Show resolved
Hide resolved
...common/src/main/java/org/apache/hudi/client/transaction/lock/ConditionalWriteLockConfig.java
Outdated
Show resolved
Hide resolved
...common/src/main/java/org/apache/hudi/client/transaction/lock/ConditionalWriteLockConfig.java
Outdated
Show resolved
Hide resolved
...common/src/main/java/org/apache/hudi/client/transaction/lock/ConditionalWriteLockConfig.java
Outdated
Show resolved
Hide resolved
...common/src/main/java/org/apache/hudi/client/transaction/lock/ConditionalWriteLockConfig.java
Outdated
Show resolved
Hide resolved
...common/src/main/java/org/apache/hudi/client/transaction/lock/ConditionalWriteLockConfig.java
Outdated
Show resolved
Hide resolved
...common/src/main/java/org/apache/hudi/client/transaction/lock/ConditionalWriteLockConfig.java
Outdated
Show resolved
Hide resolved
...mmon/src/main/java/org/apache/hudi/client/transaction/lock/ConditionalWriteLockProvider.java
Outdated
Show resolved
Hide resolved
...mmon/src/main/java/org/apache/hudi/client/transaction/lock/ConditionalWriteLockProvider.java
Outdated
Show resolved
Hide resolved
...mmon/src/main/java/org/apache/hudi/client/transaction/lock/ConditionalWriteLockProvider.java
Outdated
Show resolved
Hide resolved
...mmon/src/main/java/org/apache/hudi/client/transaction/lock/ConditionalWriteLockProvider.java
Outdated
Show resolved
Hide resolved
...mmon/src/main/java/org/apache/hudi/client/transaction/lock/ConditionalWriteLockProvider.java
Outdated
Show resolved
Hide resolved
...mmon/src/main/java/org/apache/hudi/client/transaction/lock/ConditionalWriteLockProvider.java
Outdated
Show resolved
Hide resolved
...mmon/src/main/java/org/apache/hudi/client/transaction/lock/ConditionalWriteLockProvider.java
Outdated
Show resolved
Hide resolved
...mmon/src/main/java/org/apache/hudi/client/transaction/lock/ConditionalWriteLockProvider.java
Outdated
Show resolved
Hide resolved
...mmon/src/main/java/org/apache/hudi/client/transaction/lock/ConditionalWriteLockProvider.java
Outdated
Show resolved
Hide resolved
...mmon/src/main/java/org/apache/hudi/client/transaction/lock/ConditionalWriteLockProvider.java
Outdated
Show resolved
Hide resolved
...mmon/src/main/java/org/apache/hudi/client/transaction/lock/ConditionalWriteLockProvider.java
Outdated
Show resolved
Hide resolved
...mmon/src/main/java/org/apache/hudi/client/transaction/lock/ConditionalWriteLockProvider.java
Outdated
Show resolved
Hide resolved
...mmon/src/main/java/org/apache/hudi/client/transaction/lock/ConditionalWriteLockProvider.java
Outdated
Show resolved
Hide resolved
lockFilePath, | ||
Thread.currentThread(), | ||
ACQUIRING); | ||
Thread.sleep(DEFAULT_LOCK_ACQUISITION_BUFFER); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LockManager#lock
already has retry logic when calling LockProvider#tryLock
. Should the retry logic here be removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are supposed to tryLock for the appropriate amount of time. I think the implementations in Zookeeper and Dynamo follow the same pattern here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are supposed to tryLock for the appropriate amount of time
This makes sense, but it does not mean that we should retry at this layer.
...mmon/src/main/java/org/apache/hudi/client/transaction/lock/ConditionalWriteLockProvider.java
Outdated
Show resolved
Hide resolved
...mmon/src/main/java/org/apache/hudi/client/transaction/lock/ConditionalWriteLockProvider.java
Outdated
Show resolved
Hide resolved
...mmon/src/main/java/org/apache/hudi/client/transaction/lock/ConditionalWriteLockProvider.java
Outdated
Show resolved
Hide resolved
...mmon/src/main/java/org/apache/hudi/client/transaction/lock/ConditionalWriteLockProvider.java
Outdated
Show resolved
Hide resolved
...on/src/test/java/org/apache/hudi/client/transaction/lock/ConditionalWriteLockConfigTest.java
Outdated
Show resolved
Hide resolved
...on/src/test/java/org/apache/hudi/client/transaction/lock/ConditionalWriteLockConfigTest.java
Outdated
Show resolved
Hide resolved
hudi-io/src/main/java/org/apache/hudi/storage/StorageSchemes.java
Outdated
Show resolved
Hide resolved
hudi-hadoop-common/src/test/java/org/apache/hudi/common/fs/TestStorageSchemes.java
Show resolved
Hide resolved
@hudi-bot run azure |
1 similar comment
@hudi-bot run azure |
...ent-common/src/main/java/org/apache/hudi/client/transaction/lock/StorageBasedLockConfig.java
Outdated
Show resolved
Hide resolved
...ent-common/src/main/java/org/apache/hudi/client/transaction/lock/StorageBasedLockConfig.java
Outdated
Show resolved
Hide resolved
...ent-common/src/main/java/org/apache/hudi/client/transaction/lock/StorageBasedLockConfig.java
Outdated
Show resolved
Hide resolved
...ent-common/src/main/java/org/apache/hudi/client/transaction/lock/StorageBasedLockConfig.java
Outdated
Show resolved
Hide resolved
@@ -125,13 +119,12 @@ private synchronized void setLock(StorageLockFile lockObj) { | |||
* ConditionalWriteLockConfig | |||
* @param conf Storage config, ignored. | |||
*/ | |||
public ConditionalWriteLockProvider(final LockConfiguration lockConfiguration, final StorageConfiguration<?> conf) { | |||
ConditionalWriteLockConfig config = new ConditionalWriteLockConfig.Builder() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FIx the doc too for the renaming.
...t-common/src/main/java/org/apache/hudi/client/transaction/lock/StorageBasedLockProvider.java
Show resolved
Hide resolved
@@ -276,9 +264,9 @@ private synchronized boolean isLockStillValid(StorageLockFile lock) { | |||
*/ | |||
@Override | |||
public synchronized boolean tryLock() { | |||
assertHeartBeatManagerExists(); | |||
assertHeartbeatManagerExists(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we just use ValidationUtils.checkState
instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not familiar with what this does?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this could work, but I think we want to throw HoodieLockException, so not sure if IllegalStateException makes sense.
...t-common/src/main/java/org/apache/hudi/client/transaction/lock/StorageBasedLockProvider.java
Show resolved
Hide resolved
...common/src/test/java/org/apache/hudi/client/transaction/lock/StorageBasedLockConfigTest.java
Outdated
Show resolved
Hide resolved
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/config/StorageBasedLockConfig.java
Outdated
Show resolved
Hide resolved
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/config/StorageBasedLockConfig.java
Outdated
Show resolved
Hide resolved
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/config/StorageBasedLockConfig.java
Outdated
Show resolved
Hide resolved
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/config/StorageBasedLockConfig.java
Outdated
Show resolved
Hide resolved
...t-common/src/main/java/org/apache/hudi/client/transaction/lock/StorageBasedLockProvider.java
Outdated
Show resolved
Hide resolved
...t-common/src/main/java/org/apache/hudi/client/transaction/lock/StorageBasedLockProvider.java
Show resolved
Hide resolved
// It does not make sense to have heartbeat alive extending the lock lease while | ||
// here we are trying | ||
// to expire the lock. | ||
if (heartbeatManager.hasActiveHeartbeat()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please do remember that shutdown hook can get called even in the event of graceful shutdown.
So, these methods should be idempotent when called again.
...t-common/src/main/java/org/apache/hudi/client/transaction/lock/StorageBasedLockProvider.java
Outdated
Show resolved
Hide resolved
...t-common/src/main/java/org/apache/hudi/client/transaction/lock/StorageBasedLockProvider.java
Outdated
Show resolved
Hide resolved
hudi-hadoop-common/src/test/java/org/apache/hudi/common/fs/TestStorageSchemes.java
Show resolved
Hide resolved
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/config/StorageBasedLockConfig.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1, LGTM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Blocked on my final review
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor nits. LGTM.
...t-common/src/main/java/org/apache/hudi/client/transaction/lock/StorageBasedLockProvider.java
Outdated
Show resolved
Hide resolved
hudi-hadoop-common/src/test/java/org/apache/hudi/common/fs/TestStorageSchemes.java
Outdated
Show resolved
Hide resolved
…lient/transaction/lock/ConditionalWriteLockConfig.java Co-authored-by: Y Ethan Guo <ethan.guoyihua@gmail.com>
…lient/transaction/lock/ConditionalWriteLockProvider.java Co-authored-by: Y Ethan Guo <ethan.guoyihua@gmail.com>
…lient/transaction/lock/ConditionalWriteLockProvider.java Co-authored-by: Y Ethan Guo <ethan.guoyihua@gmail.com>
…lient/transaction/lock/ConditionalWriteLockProvider.java Co-authored-by: Y Ethan Guo <ethan.guoyihua@gmail.com>
Co-authored-by: Y Ethan Guo <ethan.guoyihua@gmail.com>
0a1e4ac
to
2d596de
Compare
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/config/StorageBasedLockConfig.java
Outdated
Show resolved
Hide resolved
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/config/StorageBasedLockConfig.java
Outdated
Show resolved
Hide resolved
when(mockLockService.tryCreateOrUpdateLockFileWithRetry(any(), eq(nearExpiredLockFile), anyLong())) | ||
.thenReturn(Pair.of(LockUpdateResult.ACQUIRED_BY_OTHERS, null)); | ||
assertFalse(lockProvider.renewLock()); | ||
verify(mockLogger).error("Owner {}: Unable to renew lock as it is acquired by others.", this.ownerId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: checking logger is not the best way to validate the logic. If it's not easy to validate without this way, we should think about improving the interface in the future for testing. HUDI-9307 to track.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this one, it's just an additional check. The assert false above is sufficient for testing this code path.
I think we have a lot of different logger statements for the same return value so I actually think this is one scenario where validating this way makes sense.
...mmon/src/main/java/org/apache/hudi/client/transaction/lock/ConditionalWriteLockProvider.java
Outdated
Show resolved
Hide resolved
...t-common/src/main/java/org/apache/hudi/client/transaction/lock/StorageBasedLockProvider.java
Outdated
Show resolved
Hide resolved
...t-common/src/main/java/org/apache/hudi/client/transaction/lock/StorageBasedLockProvider.java
Outdated
Show resolved
Hide resolved
// If the next heartbeat run identifies our lock has expired we will error out. | ||
logger.warn("Owner {}: Unable to renew lock due to unknown error, could be transient.", ownerId); | ||
// Let heartbeat retry later. | ||
return true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this return false
based on the docs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docs should be updated. We should always retry renewal unless we receive a known fatal error code.
@alexr17 please update the RFC based on the latest code, including the configs, retries, shutdown hooks, etc., so that the RFC is consistent with the implementation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM overall. Please address remaining nits in a follow-up PR so we can land this PR to unblock stacked PRs on top of it.
…pache#13103) * Add initial changes for storage-based lock provider abstract implementation --------- Co-authored-by: Y Ethan Guo <ethan.guoyihua@gmail.com> (cherry picked from commit 3dc2df5)
…pache#13103) * Add initial changes for storage-based lock provider abstract implementation --------- Co-authored-by: Y Ethan Guo <ethan.guoyihua@gmail.com> (cherry picked from commit 3dc2df5)
…pache#13103) * Add initial changes for storage-based lock provider abstract implementation --------- Co-authored-by: Y Ethan Guo <ethan.guoyihua@gmail.com> (cherry picked from commit 3dc2df5)
Change Logs
Adds the abstract implementation of the storage-based lock provider using conditional writes.
See RFC: #12927
Previous PRs: #12958, #12954
Impact
Adds abstract lock provider implementation
Risk level (write none, low medium or high below)
None, without StorageLock implementation, this class will not be used.
Documentation Update
Config updates added here: #13104
Contributor's checklist