-
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
Sabre\DAV\Exception\NotFound exception in PROPFIND response when file does not have a read permission bit #40460
Comments
I have been able to mitigate the issue by skipping the file in the PROPFIND response if it is unreadable, but I'm not sure if this causes any other issues. Commit: mdusher@3e971a6 |
@jvillafanez what do you think? |
Uploading over the WebUI or over the sync client?
Why do you have to remove the read permissions? - This is not a normal procedure and no normal user has the possibility to access the DB to modify the permissions. Those are not normal steps to reproduce. why this file is uploaded and changed the behavior to read-only "automagically"
The pull request just ignores files that exist and won't be shown in the WebUI and the sync clients, this will generate appearing and disappearing files without a reason when you run a |
I checked in an instance, I have arrond 500K files with other permisions that 27:
But with 26 I have none in about 3 million files
@mdusher Could you please check how many files have permissions with 26? |
Could it be race condition? 1.- You upload a lot of files Step 4- Running an |
streaming vs no streamingI think ownCloud is streaming the responses, at least for common webdav endpoints. This leads to faster response time because the data is sent as soon as it's available. However, as shown in this ticket, errors aren't properly handled because part of the data has already been sent. Response headers are already sent with a 207 status, and some data has reached the client. You can't change the status code to a 404 and ignore all the data sent. There should be already an config option to set the streaming option off (I'm not sure if we have an option or it's hardcoded). If the streaming is off, all the data needs to be available in the server before sending it to the client. This leads to a very slow response time for large responses, specially with an infinity-depth propfind because the server need to check all the files. However, if an error happens, since no data has been sent yet, a proper error response could be sent. I think the sabreDav should have a plan on what to do with the errors that happens in the response if streaming is active. I quite convinced that we depend on what sabreDav provides to deal with this issue, if it provides anything. read permission missingAs far as I know, that comes from the FS. There is no reason for ownCloud to remove the permission, specially when no user can fiddle with permissions except for shares (which have their own permissions). Without valid steps to reproduce the missing permission I don't think we can do anything. Manually changing the permission in the DB is fine to reach a similar state in order to fix a different issue, which would be the streaming one, but the streaming issue is much bigger and needs a different approach. What's more, fixing one issue won't fix the other. about the provided patchI don't think it's a good idea. The actual storage implementation should be the one deciding whether the file should be skipped entirely or not. Skipping a file in the sabre connector seems a bad choice because any other component below the connector, and in particular the ownCloud FS, will still consider the file as valid but without read permission. The sabre connector might need to deal with the error somehow. The main responsibility should be to transform the average FS view and actions into a sabreDav tree node. There should be no room to manipulate the data in a different way other than presentation From my side, I think there are 2 problems: the "NotFound" exception happening (which should be handled somehow), and the exception (in fact any exception) breaking the XML format and causing issues to the clients. |
@jvillafanez's summary covers what I would like to see resolved
And thank you for taking the time to give feedback on the work around. I do agree that the sabre connector should just be for presentation - my line of thinking was mostly about reducing the blast radius for the user (ie. only thinking 1 file is missing, rather than multiple). Users tend to panic when they can't see their data :) @cdamken To answer your questions:
The reason for removing the read permissions is that it is the only way I know of to replicate the NotFound exception. I do not have an understanding of how these permission are initially set, when they may be modified or what might modify them so this was the quickest way.
The user who reported the issue to me was using the sync client (2.11.1).
Yes, it is part of a shared folder.
26 is just an example - there is about 240 files in the filecache that do not have a read permission bit set out of ~460 million files.
It is entirely possible it is a race condition. I do not think it would be due to the replication as my understanding is that this is done asynchronously after the file is created. There has also been instances where we have run |
@DeepDiver1975 any hints or ideas? See #40460 (comment) |
@mdusher could you please check which kind of files are all that are in the list? Knowing that: 1.- The files should be reachable by the apache user (are added and removed only over the owncloud) A "quick" test o workaround only for @mdusher could be that if the permit is 26 we force as 27 when the file is added. @IljaN @jvillafanez But what I can see is that all these files can't be read:
They have the 1 (First bit) in 0 and if you compare with #40460 (comment) |
@cdamken These are the mimetypes of the files:
I checked the permissions and owner of all the files and all but 8 of the files are readable by the apache user, 7 of those no longer exist and 1 is a file I was using to attempt to replicate this issue so is not in a normal state. |
@jvillafanez could you build in the patch #40480 some logging where we can see: the owner of the file or folder, the user who accessed it and the name of the file or folder?
This looks like an error or the mime types are not defined.
are those folders in a subfolder from a share or is the share?
This looks like an EOS problem, or who could put files directly with a different user that is not apache? - workaround change the permits to owner apache, group apache and 750 to the file or folder.
We can clean with an and could you try the patch, and see if the problem does not happen again? |
I don't think it's possible. The storage doesn't know who is accessing to it. The owner of the storage is unreliable because the external storages don't have owner or the owner is considered to be he active user (so it could change when another user access the storage); I think we'll end up showing misleading information. |
Ok, then we need that @mdusher tests our patch |
We are hesitant to apply this patch as it seems to have a bit of risk associated with it. As per @jvillafanez's note on the pull request:
If I understand this correctly, with the #40480 patch applied - if the storage was to become temporarily unavailable and this condition was met, the metadata would be removed from the filecache. This would result in shares becoming disconnected from the file and eventually being removed which would be a huge support overhead for us should we be required to restore them. As I've mentioned previously, the problem we would like to see resolved is the XML format becoming invalid due to exceptions being thrown in the streamed response and this still occurs with the patch applied. |
It is quite known that in error cases the streamed propfind response is useless. Has bee discussed quite often and agreed on 'being okay' as the clients will fall back to non-infinite-depth propfind mode. What would need to be done is that errors are caught and added to the propfind response with the correct http status code. Needs some analysis ..... |
Did some digging in sabre/dav. Somehow I can't step in to this method: Also receiving "Can not traverse a closed generator" exception with a debugger attached which leads to a 500. Maybe XDebug evaluates generators accidentally? |
It seems we need to deal with the exception inside the generator (inside https://github.com/sabre-io/dav/blob/ee802da2ad998be6c6773ddcb7d4700cc7dc27a7/lib/DAV/Server.php#L959). As as simple example:
the code runs until the number 5 (echoing the exception message) but it doesn't proceed with the rest of the numbers, so when the generator leaks the exception it seems it's automatically closed and the Note that even jumping to the next item by calling the I've also checked that there is no value returned from the Taking this limitation into account, a "classic" foreach loop (as it's already done) will be better because we can't handle the exception and the loop would break anyway. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 10 days if no further activity occurs. Thank you for your contributions. |
This issue has been automatically closed. |
I have been unable to find out how the affected file ends up with no read permission bit set on it to start with, but have been able to replicate it by manually removing the read permission that is set in the oc_filecache.
Steps to reproduce
Example using owncloud/server:10.11 docker image
Expected behaviour
There should be no exception in the PROPFIND response.
Actual behaviour
A
Sabre\DAV\Exception\NotFound
exception is printed mid-PROPFIND response making the response invalid.The behaviour of the client varies.
Server configuration
Example above uses a fresh owncloud/server:10.11 docker image with no changes.
Logs
Web server error log
ownCloud log (data/owncloud.log)
The text was updated successfully, but these errors were encountered: