You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
User renames file
System calls $view->rename()
File is renamed on the storage
Encryption keys are renamed
Version files are renamed
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:
User renames files
System calls $view->rename()
A lock is set on source and target file names
File is renamed on the storage
Encryption keys are renamed
Versions are renamed
Lock is released
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)
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)".
The rename.php from the ajax call would then call:
$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 $view->rename() there will be another call to $view->beginTransaction(array($source, $target)) that increments the lock count for these files. This is in case $view->rename() is called alone.
also lock properly for system-wide external storage mount points (to be discussed)
This is once again an opportunity to mention my idea of getting rid of "applicable" for external storages but using the "sharing" approach instead (admin mounts ext storage locally, shares with applicable users/groups), to avoid requiring custom code specific to ext storage and simply reuse the sharing one: System external storage mounts as shares instead #11182
@icewind1991@DeepDiver1975 what about "short waiting time when acquiring before abort" ?
Currently it seems to directly acquire a lock or fail directly.
In the files_locking app we had a usleep().
But anyway, this is more about tweaking locking performance.
Activity
PVince81 commentedon Oct 28, 2014
To discuss:
DeepDiver1975 commentedon Oct 28, 2014
PVince81 commentedon Oct 28, 2014
DeepDiver1975 commentedon Oct 28, 2014
note regarding timeout: webdav lock support timeouts as well - we need to keep these values in sync
PVince81 commentedon Oct 28, 2014
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)".
The rename.php from the ajax call would then call:
Inside of
$view->rename()there will be another call to$view->beginTransaction(array($source, $target))that increments the lock count for these files. This is in case$view->rename()is called alone.PVince81 commentedon Nov 2, 2014
Another case appeared on my own server today: double deletion over WebDAV: #11910
PVince81 commentedon Mar 24, 2015
Some ideas:
storages)
karlitschek commentedon Mar 26, 2015
related #11734
PVince81 commentedon Apr 28, 2015
PVince81 commentedon Apr 28, 2015
PVince81 commentedon Apr 28, 2015
52 remaining items
icewind1991 commentedon May 26, 2015
Redis already works if you configure redis as your memcache backend
PVince81 commentedon May 26, 2015
Raised owncloud/smashbox#94 about writing a special app that could help recreate the race conditions more consistently.
PVince81 commentedon May 27, 2015
PVince81 commentedon May 27, 2015
PVince81 commentedon May 29, 2015
This is once again an opportunity to mention my idea of getting rid of "applicable" for external storages but using the "sharing" approach instead (admin mounts ext storage locally, shares with applicable users/groups), to avoid requiring custom code specific to ext storage and simply reuse the sharing one: System external storage mounts as shares instead #11182
PVince81 commentedon May 29, 2015
PVince81 commentedon Jun 1, 2015
More issues and test steps documented here: #16664
carlaschroder commentedon Jun 2, 2015
Please review docs owncloud-archive/documentation#1182
PVince81 commentedon Jun 18, 2015
@icewind1991 @DeepDiver1975 what about "short waiting time when acquiring before abort" ?
Currently it seems to directly acquire a lock or fail directly.
In the files_locking app we had a usleep().
But anyway, this is more about tweaking locking performance.
PVince81 commentedon Jun 18, 2015
raised wait-retry as #17016
PVince81 commentedon Jun 23, 2015
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?)
PVince81 commentedon Jun 29, 2015
There are tickets for the remaining issues, tasks => closing