Repository navigation
Lock correct paths when moving mount - #17070
Conversation
|
Maybe an exception is too "hard" anyway, we might want to log warnings instead, as they might point at programming errors. |
|
It looks like this block https://github.com/owncloud/core/blob/master/lib/private/files/view.php#L701 was supposed to be the part that unlocks the moved path. But for some reason the failure is when unlocking $path1, not $path2. |
|
Remember that a lock is based on storage id + internal path. It looks like after moving the mount, the storage id changes, so it doesn't match the same lock. |
|
Something to think about when moving shared mount points "/files/sharex" to "/files/sub/sharex": Do we need to lock 3 paths ?
The current implementation locks $path1 as "home::owner::/files/outgoingshares/sharex" (due to the internal path resolution) and "home::recipient::/files/sub/sharex", both with LOCK_EXCLUSIVE We might want to put the locks only on the recipient's paths. Do we really need to lock the owner's path when the recipient is moving mounts ? What kind of concurrency could happen ? |
|
I think we probably don't need to lock the owner's path at all when moving a mount, as it neither affects the files inside or it nor the parent folders in the owner's tree. So we need to change this code to always lock:
|
|
I think in most cases it probably seldom makes sense to call lockPath() with EXCLUSIVE on the root of a storage. So one possibility would be to modify |
|
Looks like it's not a good idea to throw exceptions when unlocking non-locked paths, because: sometimes two shutdown handlers might run in parallel, the first one being "release_all" but the other one being a stream wrapper closing a file for which the lock was already removed |
There was a problem hiding this comment.
Add an else for other types?
There was a problem hiding this comment.
Because aquireLock without any other value then self::LOCK_SHARED will create a exclusive lock
4ca3cb3 to
9259900
Compare
|
To test:
This already worked before, but the paths used for locking were wrong, so https://github.com/owncloud/core/blob/master/lib/private/files/view.php#L696 did not unlock anything. (can be observed by making the MemcacheLockingWrapper throw exceptions when unlocking a non-locked path, something we don't want to have permanently though) @icewind1991 @nickvergessen please review |
|
Explanation for the decision here: #17070 (comment) and the comment after that. |
|
@nickvergessen I removed throwing exceptions on releaseLock, because it might fail in some legitimate cases like shutdown handlers. |
|
This PR blocks #17030 |
|
@nickvergessen @icewind1991 there is a tiny tiny chance that this might fix #17029 too because this is also about the rename/move lock paths. I'll also try and run smashbox later. |
Well the problem is we need to update the |
|
👍 looks good |
|
When moving a shared mount we only need to update one entry in the oc_share table, and it's the one from the recipient. Locking the root of any storage doesn't have any effect because no one can rename the parent of it since it has no parent. The point of having a shared lock on a folder is to avoid someone else either touching that folder or any parent exclusively (move/delete) which can never happen in the case of a root folder. |
|
Thanks for the explanation |
|
In the case of shared files, we might still need an exclusive lock when the file is being overwritten. Internally the shared file is the shared storage's root. |
|
The only one situation I think where the shared storage root must be locked is for file shares, but not for all file actions. Move, rename or unshare from self as recipient has no effect on the contents, so it doesn't make sense to lock it for those. (if we did, it means that no other recipient would be allowed to edit the file during these operations) However read would require a shared lock and write an exclusive one. |
|
Hmmmm, how about adding a flag " |
|
If I don't find any better idea until tomorrow, I'll just go ahead with the extra argument. |
|
|
If while process A uploads the file I do the UPDATE statement with the CLI MySQL client, it goes through. So why wouldn't the one from process B ? Maybe process B is somehow stuck in a weird transaction. |
|
I'll check the other selects on that table and check for unclosed cursors |
|
No luck adding closeCursor() to queries related to oc_share... 😦 |
|
Next up: enabling debugging on the MySQL side to find out about implicit rollbacks |
|
And here we go: 5 Query must be the PUT upload from process A. For some reason there's a "ROLLBACK" at the end! |
|
I debugged up to the end of the request, including destructors and shutdown handlers. There is no exception happening anywhere. I tried removing the "INNER JOIN" in share.php and adding close cursor in many places. None of this helped so far. |
|
Ok, after a second look at the SQL logs, I see there is a "START TRANSACTION" a few lines before the broken update. It means something starts a transaction but doesn't commit at the end. I suspect there might be a swallowed LockedException that might make another piece of code bypass the commit(). I'll check the places where beginTransaction() is called. |
|
Ok got it, it's indeed the scanner. A LockedException occurs and it makes it jump past the "commit()" and be caught later... |
b6d0690 to
8859004
Compare
|
A new inspection was created. |
|
And here is the fix: 8859004 I hope I'll now be able to finish testing this PR. |
|
|
=> totally unrelated to this PR or touched code paths. |
|
also this happens when using SFTP + share, not on regular root. |
|
This PR is ready to review @icewind1991 @nickvergessen |
|
👍 looks good |
|
@nickvergessen second review ? |
|
Yeah, let me run SB first just to make sure nothing breaks ;) |
|
Okay, so expecting a merge in the next 3 hours then ? 😉 |
|
|
👍 thanks for tackling this down @PVince81 now grab some 🍺 |
|
Thanks a lot! Merging. |
Lock correct paths when moving mount

This will make tests fail, for example:
We seem to have a path mismatch issue when moving mount points.
CC @icewind1991 this is the problem I mentioned to you
Might explain the failure in #17030 (comment)