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
{{ message }}
Repository navigation
Acquire locks before post-hooks, release afterwards #16829
In another window or WebDAV, rename "folder" to "re"
Wait for all operations to finish
Check the versions of "re/re.txt"
The versions are still there. The reason is because renaming the folder also triggered the version copying logic, so this might be sheer luck.
However the file rename fails with 500, logs contain this:
{"reqId":"E6zC8T1E4xL1Sej3uG5G","remoteAddr":"127.0.0.1","app":"PHP","message":"Argument 1 passed to OCA\\Files\\Helper::formatFileInfo() must implement interface OCP\\Files\\FileInfo, boolean given, called in \/srv\/www\/htdocs\/owncloud\/apps\/files\/lib\/app.php on line 122 and defined at \/srv\/www\/htdocs\/owncloud\/apps\/files\/lib\/helper.php#135","level":3,"time":"2015-06-12T13:44:55+00:00","method":"GET","url":"\/owncloud\/index.php\/apps\/files\/ajax\/rename.php?dir=%2Ffolder&newname=re.txt&file=test.txt"}
{"reqId":"E6zC8T1E4xL1Sej3uG5G","remoteAddr":"127.0.0.1","app":"PHP","message":"Call to a member function getMimetype() on boolean at \/srv\/www\/htdocs\/owncloud\/apps\/files\/lib\/helper.php#77","level":3,"time":"2015-06-12T13:44:55+00:00","method":"GET","url":"\/owncloud\/index.php\/apps\/files\/ajax\/rename.php?dir=%2Ffolder&newname=re.txt&file=test.txt"}
The concurrency case happened at the time where both tried to copy the same versions.
The expected behavior is that the folder rename is locked until the post hook is done moving the versions.
Please note that post hooks are already included in the lock transaction in the code path for WebDAV PUT of small files. So if we say we still don't want to include post hooks, we'll need to change that code path to exclude them too.
But I'd prefer if we would include them. Maybe we need to call changeLock again to SHARED.
Ok I think I now see your point about "apps cannot modify the file in post hooks".
On the other hand, apps that want to modify the real file in pre or post hooks should then be ported to use storage wrappers instead.
Activity
PVince81 commentedon Jun 9, 2015
Marking as bug as this is a potential bug.
Might be possible to trigger this somehow with carefully placed "sleep()" statements.
icewind1991 commentedon Jun 9, 2015
We already lock around pre-hooks, it's post-hooks that I'm unsure off
PVince81 commentedon Jun 9, 2015
Right, post-hooks.
Would it hurt to lock there ? Any negative consequences that comes to mind ?
[-]Acquire locks before prehooks[/-][+]Acquire locks after post-hooks[/+][-]Acquire locks after post-hooks[/-][+]Acquire locks before post-hooks, release afterwards[/+]icewind1991 commentedon Jun 9, 2015
if we lock around post-hooks then hooks can no longer write to the file.
I'm not sure if we currently have any hooks that write to the file but we have had those in the past and I would say there are valid use cases for it
PVince81 commentedon Jun 9, 2015
Hmm ok, so it means if an app really would do something with the file in a post-hook, it would go over the view anyway and re-lock the file.
Only if someone would rename/move away the file between the operation and the post-hook, then shit could happen.
I'll try and find a concrete case with reproduction steps then.
PVince81 commentedon Jun 12, 2015
Steps:
The versions are still there. The reason is because renaming the folder also triggered the version copying logic, so this might be sheer luck.
However the file rename fails with 500, logs contain this:
The concurrency case happened at the time where both tried to copy the same versions.
The expected behavior is that the folder rename is locked until the post hook is done moving the versions.
PVince81 commentedon Jun 12, 2015
Please note that post hooks are already included in the lock transaction in the code path for WebDAV PUT of small files. So if we say we still don't want to include post hooks, we'll need to change that code path to exclude them too.
But I'd prefer if we would include them. Maybe we need to call changeLock again to SHARED.
icewind1991 commentedon Jun 12, 2015
Ok, I'll make a PR with shared locks around post-hooks so we can properly observe the impact
PVince81 commentedon Jun 12, 2015
In theory we can already observe them with Webdav PUT of small files 😉
Yes, please do. Thanks.
PVince81 commentedon Jun 12, 2015
You'll need to call
changeLock()to convert the locks from EXCLUSIVE back to SHARED.Had to do it for #16900
PVince81 commentedon Jun 18, 2015
Ok I think I now see your point about "apps cannot modify the file in post hooks".
On the other hand, apps that want to modify the real file in pre or post hooks should then be ported to use storage wrappers instead.
PVince81 commentedon Jun 18, 2015
PR here #17030