-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Implement high level file locking #11804
Comments
To discuss:
|
|
|
note regarding timeout: webdav lock support timeouts as well - we need to keep these values in sync |
The locking also needs to be multi-level, which means that an operation on level 1 (user renames folder) could also cause additional locks to be created. One example is that whenever the user accesses the storage, sometimes we need to adjust the mount points in case of conflicts. Adjusting the mount points would itself be a sub-transaction. Maybe we should rather talk about transactions and provide methods "beginTransaction($files)" with a list of files to lock. Then "endTransaction($files)" to end it (or use a $handle). Let's say renaming a file consists of calling "file_exists($target)" then "rename($source, $target)". $handle = $view->beginTransaction(array($source, $target));
if (!$view->file_exists($target)) { // for the sake of the example
$view->rename($source, $target);
}
$view->endTransaction($handle); Inside of |
Another case appeared on my own server today: double deletion over WebDAV: #11910 |
Some ideas:
|
related #11734 |
|
|
|
|
|
|
|
|
@jnfrmarks @PVince81 do we have smashbox tests which are failing as of today because of missing locking? If not we shall implement them asap. THX |
testConcurrentDirMove might be one, but fails only randomly on some envs. If we had a way to slow down the server (or dynamically add breakpoints with XDebug 😉) it could then become easier to reproduce such issues consistently. |
There is another fundamental issue that we'll eventually need to think of, related to APIs: so far we ask every app to use the public API, which is the node based files API (OC::$server->getUserFolder()). That API uses the View. So far so good, this means app will benefit from locking too. The trouble is that now we're changing the trashbin and versions app to use the Storage instead of the Node API. This is because using the node API would lock several times. It starts to feel like in the end the Storage API will need to be made public eventually... which is not really what we wanted. Originally I thought we could have a method |
Well this would also mean that apps like trashbin and versions should be able to work with the public node API too in the end (and not use the private View or Storage API) |
|
We can probably discuss the individual cases in separate tickets once the main work is merged. |
Note for testers: to enable this feature you need to:
|
Redis already works if you configure redis as your memcache backend |
Raised owncloud/smashbox#94 about writing a special app that could help recreate the race conditions more consistently. |
|
|
|
|
More issues and test steps documented here: #16664 |
Please review docs owncloud-archive/documentation#1182 |
@icewind1991 @DeepDiver1975 what about "short waiting time when acquiring before abort" ? In the files_locking app we had a usleep(). |
raised wait-retry as #17016 |
Most of this has either been implemented already or raised as separate tickets. We can either close it or keep it to keep an overview (but then remove the severity tags?) |
There are tickets for the remaining issues, tasks => closing |
Currently the files_locking app only works on storage level, which is not enough to guarantee atomicity of operations. This is because we have hooks and proxies and apps are able to perform additional filesystem operations.
A high-level file locking mechanism should be implemented to guarantee atomicity of file operations on a higher level.
For example, this is what happens when renaming an encrypted file:
$view->rename()
Since files_locking only operates on storage level, only step 3) is locked.
If after step 3) someone renamed the new file to yet another name, they will get a "share key not found" error.
The high-level locking mechanism would work as follows:
$view->rename()
Also note that files_locking does not lock folders.
There's also the open question whether parent folders should be locked and whether folder locking is feasible at all.
Here is an example of what kind of race conditions happen due to lack of high-level locking: #11795
(rename a folder while the sync client is uploading files into it)
@craigpg @karlitschek @MTRichards @DeepDiver1975 @icewind1991 @schiesbn @bantu
The text was updated successfully, but these errors were encountered: