Nextcloud version (eg, 20.0.5): 28.0.2
Operating system and version (eg, Ubuntu 20.04): AlmaLinux 8.9
Apache or nginx version (eg, Apache 2.4.25): Apache 2.4.37
PHP version (eg, 7.4): 8.0.30
The issue you are facing:
I am seeing a constant spew of
{"reqId":"EKkY7U5bTUvDriPxJba7","level":3,"time":"2024-02-25T08:36:13+00:00","remoteAddr":"","user":"--","app":"PHP","method":"","url":"--","message":"file_get_contents(/var/lib/nextcloud/data/brian/files/DesktopHome/.wine.old/fake_windows/users/brian/My Documents/.wine.old/fake_windows/users/brian/My Documents/.wine.old/fake_windows/users/brian/My Documents/.wine.old/fake_windows/users/brian/My Documents/.wine.old/fake_windows/users/brian/My Documents/.wine.old/fake_windows/users/brian/My Documents/.wine.old/fake_windows/users/brian/My Documents/.wine.old/fake_windows/users/brian/My Documents/.wine.old/fake_windows/users/brian/My Documents/.wine.old/dosdevices/e:/.wine.old/dosdevices/z:/net/pc/home/brian/.shotwell/thumbs/thumbs128/thumb0000000000001878.jpg): Failed to open stream: No such file or directory at /usr/share/nextcloud/lib/private/Files/Storage/Local.php#327","userAgent":"--","version":"28.0.1.1","data":{"app":"PHP"}}
in my logs. When I query the oc_filecache table I can indeed see 1.4 million:
# echo 'select count(*) from oc_filecache where path like "%/DesktopHome/%";' | mysql -t nextclouddb
+----------+
| count(*) |
+----------+
| 1453080 |
+----------+
such entries where there is no actual file on the filesystem. These are orphaned entries in the database.
Is this the first time you’ve seen this error? (Y/N): Y
Steps to replicate it:
Unknown
The output of your Nextcloud log in Admin > Logging:
It’s empty. Or maybe just taking a really long time to render due to the load the constant spew of the above is having on the database.
I have 1.4M records in the oc_filecache table. I am sure the vast majority of them are indeed orphaned files all below the /var/lib/nextcloud/data/brian/files/DesktopHome/ path. I’d like to just remove anything from oc_filecache that is in that path but I am not sure that just issuing a MySQL command to do that won’t break the database consistency in some way. I.e. if those records are referenced somewhere else that will be orphaned in the DB.
I did try to run:
# sudo -u apache php /usr/share/nextcloud/occ files:cleanup
0 orphaned file cache entries deleted
0 orphaned mount entries deleted
but as you can see it has had no effect.
How can I efficiently just remove these orphaned oc_filecache entries?