-
Bug
-
Resolution: Unresolved
-
Minor
-
None
-
4.3
-
None
-
MOODLE_403_STABLE
On a site with a large number of files (on the site I tested on, the files table contains 41 million records):
- Open any form with an editor field
- Click the "Insert image" button
- Click "Browse repositories"
- Open the browser's developer tools and select the Network tab.
- Select the "Site files" repository.
- In the search field, enter ".jpg" and press "Enter" to search.
- Expected: After a short delay, search results are displayed
- Actual:
- The loading spinner is displayed indefinitely
- Observing the network panel, the request to /respository/respository_ajax.php?action=search continues running. In parallel, the editor is making requests to autosave_ajax.php. These timeout trying to get a session lock which is help by respository_ajax.php.
- Closing the file manager does not cancel the respository_ajax.php request. As a result attempting to navigate away from the page also results in a session lock timeout.
This is the query being run:
SELECT $select
|
FROM {files} f
|
LEFT JOIN {files_reference} r
|
ON f.referencefileid = r.id
|
JOIN {context} c
|
ON f.contextid = c.id
|
WHERE c.contextlevel <> :contextlevel
|
AND f.filename <> :directory
|
AND f.filename LIKE %:query%;
|
It's not really surprising that this is slow on a site with 41 million file records. I'm not sure there's much we could do to make the query itself quicker. We might need to think of an alternative way of searching server files that scales. Could Global Search help here?
At the very least, closing the file manager should cancel any in progress AJAX requests to repository_ajax.php.