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
Move in, Move in overwrite and Move out fail using WebDAV with locking #17029
{"reqId":"5at1fJdV3+W5ruk+uhYL","remoteAddr":"192.168.178.32","app":"PHP","message":"Call to a member function getPath() on a non-object at \/home\/nickv\/ownCloud\/Smashbox\/master\/lib\/private\/share\/share.php#134","level":3,"time":"2015-06-19T07:02:48+00:00"}
@icewind1991$meta = $view->getFileInfo($path); in line 133 returns false, so of course the method does not exist then.
If I understand the explanation of @nickvergessen correctly we already obtain the lock in the view on file_put_contents. If this is the case I don't see a difference in calling getAccessList() before or after we wrap the stream. The first lock will always be already there.
imo the way to solve this would to have getAccessList work correctly on files that aren't saved in the cache yet (the file does exist since fopen($path,'w') creates it but the cache is only updated after the write is complete) #17071 was an attempt at that.
I don't think this is the correct way to solve the problem, having the lock actually lock the file even for the current process prevents getting unexpected results when trying to do fs work in the middle of an existing fs operation, having a storage wrapper call getFileInfo on a file that hasn't been created yet should not return an unspecified maybe-valid-but-relies-completely-on-the-storage-backend result, this should return an error value (or an exception, a man can dream...).
A write lock is not just to keep other processes from reading the file, it should also prevent the same process from reading the file since we can't guarantee correct behavior when reading a file that's being written to.
In the past we've had to fix multiple bugs that we're caused by wrappers/hooks/etc interfering with filesystem operations. Locking should make filesystem operations atomic and prevent unexpected behavior, something we cant do if the same process can simply ignore the lock.
Locking should make filesystem operations atomic and prevent unexpected behavior, something we cant do if the same process can simply ignore the lock.
Well I see the idea behind that, the problem is... they are not. Any hook, storage wrapper, ... that is called in the action, needs to be able to behave like it did in the past. This is exactly why our test is failing atm. Getting the user's an item is shared with is not something randoom (typo intended).
It is done by encryption (to generate/copy keys), activity (to generate the activities), ...
The patch you suggest at #17071 falls back to the parent item. However, that information is simply wrong. If a file is shared directly, the directory will not contain those users, which is why the smashbox execution I did fails (it fails differently compared to before the patch):
OC\Encryption\Exceptions\DecryptionFailedException - Message: Can not decrypt this file, probably this is a shared file. Please ask the file owner to reshare the file with you.
So the keys of the people sharing the file but not any parent, are not there anymore (assumption, but somehow some keys are missing). We could try and gather all necessary information, before creating the lock. But this means huge overhead (we don't know which methods will be called, so we have to call all of them ....) and then we would still need to tunnel all information to all methods out there, which currently call any filesystem related method directly.
Feel free to suggest a new way, that is "better" then #17164 while still solving the issues we are seeing. At least #17071 is not the right solution.
but smashbox didn't find it because for some mysterious reasons WebDAV upload works and doesn't reach that code path. However web UI upload triggers the issue.
Note that is only used to pass by chance, when using a local storage backend the fopen call creates the file, with most external storages the file will only be created after the file handle is closed so it has always been broken on external storages
So @icewind1991 did you have a better idea? I know locking is experimental, but not being able to do webdav move_in, move_in_overwrite and move_out seems like a real draw back, just for the sane of theory-crafting which can not be met at the current time.
If not then I will fix the unit tests on my PR so they pass and we can go with the non-ideal-world solution rather than a broken one, deal?
Activity
PVince81 commentedon Jun 18, 2015
This issue title sounds like a cheat code
nickvergessen commentedon Jun 19, 2015
@icewind1991
$meta = $view->getFileInfo($path);in line 133 returns false, so of course the method does not exist then.icewind1991 commentedon Jun 19, 2015
I can't reproduce any of the failures locally...
DeepDiver1975 commentedon Jun 19, 2015
are you executing the smashbox test test_sharePermissions? - It also fails on jenkins: https://ci.owncloud.org/job/smashbox/TEST_NAME=test_sharePermissions,compiler=g++,label=master,mirallBranch=v1.8.1,qt=qt4,serverVersion=owncloud8.1-locking/55/console
PVince81 commentedon Jun 19, 2015
Same for me, running this:
no errors.
Oh, let me try again with
-ato run all test cases...DeepDiver1975 commentedon Jun 19, 2015
haha - that bloody switch
PVince81 commentedon Jun 19, 2015
Tried again twice with the bloody switch, but still no failure
PVince81 commentedon Jun 19, 2015
@nickvergessen you could also reproduce this locally, consistently ?
Can you do a "flushall" on redis before you do ?
Maybe there are stray keys
DeepDiver1975 commentedon Jun 19, 2015
even if - on jenkins it's falling apart with http 500
PVince81 commentedon Jun 19, 2015
Then we might need to setup a VM with the same setup.
My current setup where tests pass is:
DeepDiver1975 commentedon Jun 19, 2015
test1 is using apcu - related?
19 remaining items
schiessle commentedon Jun 24, 2015
If I understand the explanation of @nickvergessen correctly we already obtain the lock in the view on file_put_contents. If this is the case I don't see a difference in calling getAccessList() before or after we wrap the stream. The first lock will always be already there.
icewind1991 commentedon Jun 25, 2015
imo the way to solve this would to have
getAccessListwork correctly on files that aren't saved in the cache yet (the file does exist since fopen($path,'w') creates it but the cache is only updated after the write is complete) #17071 was an attempt at that.nickvergessen commentedon Jun 25, 2015
From @icewind1991 at #17164 (comment)
nickvergessen commentedon Jun 25, 2015
Well I see the idea behind that, the problem is... they are not. Any hook, storage wrapper, ... that is called in the action, needs to be able to behave like it did in the past. This is exactly why our test is failing atm. Getting the user's an item is shared with is not something randoom (typo intended).
It is done by encryption (to generate/copy keys), activity (to generate the activities), ...
The patch you suggest at #17071 falls back to the parent item. However, that information is simply wrong. If a file is shared directly, the directory will not contain those users, which is why the smashbox execution I did fails (it fails differently compared to before the patch):
So the keys of the people sharing the file but not any parent, are not there anymore (assumption, but somehow some keys are missing). We could try and gather all necessary information, before creating the lock. But this means huge overhead (we don't know which methods will be called, so we have to call all of them ....) and then we would still need to tunnel all information to all methods out there, which currently call any filesystem related method directly.
Feel free to suggest a new way, that is "better" then #17164 while still solving the issues we are seeing. At least #17071 is not the right solution.
PVince81 commentedon Jun 25, 2015
This issue also seems to break regular file upload, see #17153
PVince81 commentedon Jun 25, 2015
but smashbox didn't find it because for some mysterious reasons WebDAV upload works and doesn't reach that code path. However web UI upload triggers the issue.
Will investigate WebDAV separately.
PVince81 commentedon Jun 25, 2015
Ok got it: when uploading small files with WebDAV (non-chunking), we only set a shared lock on the target file https://github.com/owncloud/core/blob/master/lib/private/connector/sabre/file.php#L117. Then we write into a PART file, so at this point we can still call getFileInfo on the final file path. It's only during the final rename https://github.com/owncloud/core/blob/master/lib/private/connector/sabre/file.php#L205 that the target path gets an exclusive lock.
So basically if we used PART files for cross-storage moves, we could use the same logic eventually... (#13379)
icewind1991 commentedon Jun 25, 2015
Note that is only used to pass by chance, when using a local storage backend the
fopencall creates the file, with most external storages the file will only be created after the file handle is closed so it has always been broken on external storagesnickvergessen commentedon Jun 26, 2015
So @icewind1991 did you have a better idea? I know locking is experimental, but not being able to do webdav move_in, move_in_overwrite and move_out seems like a real draw back, just for the sane of theory-crafting which can not be met at the current time.
If not then I will fix the unit tests on my PR so they pass and we can go with the non-ideal-world solution rather than a broken one, deal?
cc @DeepDiver1975
PVince81 commentedon Jun 26, 2015
This is worse than just move in: web upload is also broken.
icewind1991 commentedon Jun 26, 2015
Ok I was able to reproduce that, will look into it
nickvergessen commentedon Jun 29, 2015
Seems like #17030 and #17071 had sufficient success. Tests are passing again: closing.