[Bug]: ScanFiles never performed and slow with big tables #40018
Labels
0. Needs triage
Pending check for reproducibility or if it fits our roadmap
feature: filesystem
performance 🚀
technical debt
Bug description
Given the background job
ScanFiles
, if arunScanner
fails for a particular user, the nextgetUserToScan
returns the same user and the code will immediately stop scanning, causing the other users not to be scanned. This can happen for an indefinite amount of time, perhaps forever.server/apps/files/lib/BackgroundJob/ScanFiles.php
Lines 110 to 117 in 590b1d9
Also in MySQL, if the
filecache
table is huge (like >1 million rows) it could happen that the InnoDB chooses the wrong indexes, causing a slow query when the returned set is empty (more than 10 seconds), this is related to #24401.Steps to reproduce
Scan not performed
To check the broken code you should try to insert a broken
oc_filecache
, if you are unlucky enough it will forever scan only the user with the storage 1.Slow queries in MySQL
This is an example with a small table:
It first filters all target files using
Index range scan on f using fs_size over (size < 0)
, then performs aCovering index lookup on using mount_user_storage
for each returned row (in this example, 1).This is an example on a large table:
It first gets all storages with
Covering index scan on m using mount_user_storage
and gets 3 storages, then for each storage it does aIndex lookup on f using fs_storage_path_hash
.This happens because the engine estimates that the rows returned by
Index lookup on f using fs_storage_path_hash
are 3089 instead of 346344*3.I don't think we can completely blame the engine, because if you add a record that could be returned by this query, we get :
It now estimates 2150 rows, whereas 20*2 are returned.
Now, if we force the index on
fs_size
, we get the same result for small tables:Expected behavior
For the broken scan it should still trying all the other users.
For the slow queries it should use the right index or perform a better query.
Installation method
None
Nextcloud Server version
26
Operating system
Debian/Ubuntu
PHP engine version
PHP 8.1
Web server
None
Database engine version
Other
Is this bug present after an update or on a fresh install?
None
Are you using the Nextcloud Server Encryption module?
Encryption is Disabled
What user-backends are you using?
Configuration report
No response
List of activated Apps
No response
Nextcloud Signing status
No response
Nextcloud Logs
No response
Additional info
No response
The text was updated successfully, but these errors were encountered: