-
Notifications
You must be signed in to change notification settings - Fork 228
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
Fix helix-lock regression #2698
Conversation
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.
Great analysis @MarkGaox - Thanks for fixing the old regression( since Dec 2020).
I am reviewing the change, but wanted to provide initial comment.
...x-lock/src/test/java/org/apache/helix/lock/helix/TestZKHelixNonblockingLockWithPriority.java
Show resolved
Hide resolved
helix-lock/src/main/java/org/apache/helix/lock/helix/ZKDistributedNonblockingLock.java
Outdated
Show resolved
Hide resolved
helix-lock/src/test/java/org/apache/helix/lock/helix/TestZKHelixNonblockingLock.java
Outdated
Show resolved
Hide resolved
This PR is approved by @desaikomal. And it's ready to merge. |
// higher priority lock request will try to preempt current lock owner | ||
LockInfo unlockOrLockRequestLockInfo = new LockInfo(_record); | ||
// Any unlock request from non-lock owners is blocked. | ||
if (unlockOrLockRequestLockInfo.getOwner().equals(LockConstants.DEFAULT_USER_ID)) { |
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.
The behavior of current codebase is requestor.unlock()
will return true when it's priority is larger than the current lock owner. However, what actually happened inside is the requestor didn't release the lock even if unlock returns true, the current code just changed requestor lock's pendingTimeOut and the requestor still has to call tryLock()
to acquire the lock, which is not a really efficient. Based on offline discussion with @xyuanlu, the ideal behavior is that unlock()
should return false when the lock requestor is not the lock owner. And requestors should call tryLock()
to acquire the lock.
Issues
(#200 - Link your issue number here: You can write "Fixes #XXX". Please use the proper keyword so that the issue gets closed automatically. See https://docs.github.com/en/github/managing-your-work-on-github/linking-a-pull-request-to-an-issue
Any of the following keywords can be used: close, closes, closed, fix, fixes, fixed, resolve, resolves, resolved)
Description
There are two separate regressions in this PR
The current lock owner won’t clean up itself and release the lock since it’s using the old helix-lock version which doesn’t react to lock requests with higher priority.
unlock()
a lock if its priority is larger than the priority recorded in the lock. This should be avoided as well. If the non-lock owners want to acquire a lock, it should only calltryLock()
.To resolve the two issue discussed above
update()
handles a unlock request but the requestor is not the current owner of the lock.(Write a concise description including what, why, how)
Tests
mvn test -Dtest=TestZKHelixNonblockingLock,TestZKHelixNonblockingLockWithPriority -pl helix-lock
(List the names of added unit/integration tests)
(If CI test fails due to known issue, please specify the issue and test PR locally. Then copy & paste the result of "mvn test" to here.)
Changes that Break Backward Compatibility (Optional)
(Consider including all behavior changes for public methods or API. Also include these changes in merge description so that other developers are aware of these changes. This allows them to make relevant code changes in feature branches accounting for the new method/API behavior.)
Documentation (Optional)
(Link the GitHub wiki you added)
Commits
Code Quality
(helix-style-intellij.xml if IntelliJ IDE is used)