-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Fix releasing a shared lock multiple times #21074
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 releasing a shared lock multiple times #21074
Conversation
b2f4e92 to
cf05823
Compare
|
Thanks for your patch 🎉 If the LockPlugin already obtains the lock why not remove the shared lock in createFile? 🤔 |
Thanks for the quick response! In my debug session, I found that Since it's a PUT request for a new file, perhaps it makes some sense that initially the |
That makes sense. So it's maybe enough to remove the lock release from createFile? But making the locking provider more stable is also a good thing. I'm just trying to understand why a code path runs twice. |
In the current code I like that it's clear what part is responsible for releasing each lock - it's literally all in the same file/function. If I find it a bit confusing that It seems a bit scary to me that if |
Signed-off-by: Jaakko Salo <[email protected]>
ce3adb1 to
a279736
Compare
When uploading new files, getNodeForPath() will not succeed yet so the lock cannot be acquired. In that case, don't try to unlock it either. Signed-off-by: Jaakko Salo <[email protected]>
a279736 to
6886b46
Compare
MorrisJobke
left a comment
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.
Code looks good 👍
|
Thanks for your first pull request and welcome to the community! Feel free to keep them coming! If you are looking for issues to tackle then have a look at this selection: https://github.com/nextcloud/server/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22 |
|
/backport to stable19 |
|
/backport to stable18 |
|
/backport to stable17 |
|
I closed the ones to 17 and 18, because they do not apply clean. |
This patch makes
MemcacheLockingProviderhandle multiple releases of the same shared lock gracefully.Previously, the lock will get negative values that cause problems as seen in #21073
During PUT requests,
server/apps/dav/lib/Connector/Sabre/Directory.php
Line 157 in 5e35594
server/apps/dav/lib/Connector/Sabre/LockPlugin.php
Line 83 in 5e35594
LockPluginnever acquired the lock.MemcacheLockingProvideralready had some logic to handle multiple releases (negative going lock values), but it was subject to a race condition.