Don't query Sabre parent nodes#28853
Conversation
This should be fine unless you're deleting a parent (at any level) of another folder that is being deleted at the same. In this case it's fine because there are operations that are happening in the contents of the folder. I think just disabling the ACL plugin should be enough to solve the problem. |
It's not. I already tried: both fixes are needed else the 423 Locked exceptions will creep in. |
| } | ||
|
|
||
| // check the path, also called when the path has been entered manually eg via a file explorer | ||
| if (\OC\Files\Filesystem::isForbiddenFileOrDir($path)) { |
There was a problem hiding this comment.
any reason for this duplication? it will a comment if any.
| } | ||
|
|
||
| // Is it the root node? | ||
| if ($path === '') { |
There was a problem hiding this comment.
move this check up, before any complex operation?
| throw new \Sabre\DAV\Exception\Forbidden(); | ||
| } | ||
|
|
||
| $path = trim($path, '/'); |
There was a problem hiding this comment.
we could move this before the isForbiddenFileOrDir check
There was a problem hiding this comment.
hah... seems it's also duplicated in ObjectTree...
|
|
||
| $path = trim($path, '/'); | ||
|
|
||
| if (isset($this->cache[$path]) && $this->cache[$path] !== false) { |
There was a problem hiding this comment.
this also might be possible to move it before the isForbiddenFileOrDir check, to return the cache data as soon as we can
|
|
||
| if (!$info) { | ||
| $this->cache[$path] = false; | ||
| throw new \Sabre\DAV\Exception\NotFound('File with name ' . $path . ' could not be located'); |
There was a problem hiding this comment.
Do we want to cache this exception? I mean, if the file doesn't exists at some point, it won't likely exists during the rest of the request, so we might not want to go through all the steps again to get another NotFound. On the other hand, it might be fine since it's expected the exception isn't catched until the top level to send the message to the client.
There was a problem hiding this comment.
the exception is cached already with the value false for future checks
|
@jvillafanez I actually copied getNodeForPath from the old ObjectTree::getNodeForPath and removed every bit related to chunking or part files. Then I added a few lines at the top to compute the correct path. The result is what you see above. I'll still have a look at your proposals for optimization, might be a good opportunity. Before I do, do you agree with the general approach ? I'm not sure if @DeepDiver1975 would appreciate that we brought back the Tree implementation but so far I don't see any better way. Too bad Sabre doesn't have a "getNodeForPath" event that plugins could override. |
|
The only option left that I see in addition to this one is to override the RootCollection instead of the \OCA\DAV\Tree. I don't know what is the best option. The other option would be to modify the View and change or add a method to get the file info without triggering a scan, but in addition to be risky (too many components might be affected) we'll need to evaluate what could be the consecuences of fetching not up-to-date data. |
We already have our own RootCollection. Sadly the API
I looked into this here: #28855. You're right that it's risky so I'm less happy with #28855 than with #28853 |
|
|
|
In theory we could invent a new interface that allows our sabre collections to provide "getNodeForPath" for a subpath. If implemented, call it. Else fall back to traversing with |
|
|
We might not even need But I also found this... #21401 |
|
Now from reading the comments, it seems that doing the I think re-adding |
|
I have the feeling that this is going a bit too far already with risk of regressions or at least performance regressions... If I don't find a solution until next week I'll revert the web UI to use the old DAV endpoint for the time being. |
|
After mounting an external storage the web ui has a spinner spinning forever, refresh doesn't help. logs: |
|
Retested, external storage is not required, it fails just opening files view 👎 : |
|
argh... I was doing something experimental and moved around code but made the mistake to commit the removal of said code |
|
b481a9f to
03329e2
Compare
|
@SergioBertolinSG please try again, thanks |
|
@jvillafanez mind rechecking ? In general I'm not too happy about this but it feels like it's the best compromise so far. I hope we can eventually get rid of |
54ad05d to
451c835
Compare
|
Transferred to @DeepDiver1975 for hijacking |
451c835 to
cccee14
Compare
Codecov Report
@@ Coverage Diff @@
## master #28853 +/- ##
============================================
+ Coverage 62.6% 62.64% +0.03%
- Complexity 17584 17598 +14
============================================
Files 1038 1039 +1
Lines 57920 57956 +36
============================================
+ Hits 36263 36305 +42
+ Misses 21657 21651 -6
Continue to review full report at Codecov.
|
cccee14 to
a1298bc
Compare
a1298bc to
43ab959
Compare
|
👍 for @DeepDiver1975's changes |
|
I see some tab issues, fixing... (copy-pasted code from Sabre that has spaces instead of tabs) |
When dealing with file access, the old DAV had a shortcut way to directly access a file node without having to traverse all parents. The new DAV endpoint needs this as well: - added \OCA\DAV\Tree implementation with shortcut for "files" - disable DAVACL plugin as it would also query all parents There are several reasons for avoiding to query the parents: - it causes file cache access for each node, not removable as it needs to check for existence - with external storages and update detection, querying a folder node causes update detection to kick in and the scanner to do its work, the scanner will set additional locks that might needlessly prevent concurrent access.
43ab959 to
483d060
Compare
|
I've squashed the tab fixes into the second commit and rebased onto master. If CI passes let's merge this and backport. |
|
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Description
When dealing with file access, the old DAV had a shortcut way to
directly access a file node without having to traverse all parents.
The new DAV endpoint needs this as well:
There are several reasons for avoiding to query the parents:
to check for existence
causes update detection to kick in and the scanner to do its work, the
scanner will set additional locks that might needlessly prevent
concurrent access.
The sad part is that any future Sabre plugin without caring for the above has a risk of retriggering these issues. So any Sabre plugin dealing with files must be aware of this and avoid needlessly querying every parent node.
Related Issue
Fixes #28779
Motivation and Context
Read from #28779 (comment).
But also this will improve performance or at least bring it closer to the one from the old DAV endpoint by avoiding additional file cache queries.
How Has This Been Tested?
Test steps from above ticket: deletion of three folders simultaneously on an external storage with update detection kept enabled.
Screenshots (if appropriate):
Types of changes
Checklist: