Uh oh!
There was an error while loading. Please reload this page.
[HUDI-9158] Add storage-based lock provider abstract implementation - #13103
Conversation
alexr17
commented
Apr 8, 2025
@hudi-bot run azure |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| lockFilePath, | ||
| Thread.currentThread(), | ||
| ACQUIRING); | ||
| Thread.sleep(DEFAULT_LOCK_ACQUISITION_BUFFER); |
There was a problem hiding this comment.
LockManager#lock already has retry logic when calling LockProvider#tryLock. Should the retry logic here be removed?
There was a problem hiding this comment.
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.
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.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
alexr17
commented
Apr 9, 2025
@hudi-bot run azure |
1 similar comment
alexr17
commented
Apr 9, 2025
@hudi-bot run azure |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| * @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.
FIx the doc too for the renaming.
Uh oh!
There was an error while loading. Please reload this page.
| @Override | ||
| public synchronized boolean tryLock() { | ||
| assertHeartBeatManagerExists(); | ||
| assertHeartbeatManagerExists(); |
There was a problem hiding this comment.
maybe we just use ValidationUtils.checkState instead
There was a problem hiding this comment.
I'm not familiar with what this does?
There was a problem hiding this comment.
I guess this could work, but I think we want to throw HoodieLockException, so not sure if IllegalStateException makes sense.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| // 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.
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.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
…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>
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| 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.
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.
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.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| // 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.
Should this return false based on the docs?
There was a problem hiding this comment.
Docs should be updated. We should always retry renewal unless we receive a known fatal error code.
yihua
commented
Apr 11, 2025
@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. |
yihua
left a comment
There was a problem hiding this comment.
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