User x still has unscanned files after running background scan, background scan might be stopped prematurely

Hi there,

I found by accident the following entries (every 10-15 minutes) in https:/mynextcloud/settings/admin/logging:

User x still has unscanned files after running background scan,
background scan might be stopped prematurely

Nextcloud version (eg, 20.0.5): Nextcloud Hub II (23.0.1)
Operating system and version (eg, Ubuntu 20.04): Docker

    image: mariadb:10.5
    image: redis:alpine
    image: nextcloud:fpm-alpine
    image: nextcloud:fpm-alpine
    image: nginxproxy/acme-companion

I tried occ files:scan x --unscanned, occ files:scan x, but message is still appearing again and again :frowning:

Can you help me how to fix it and/or advise what’s going wrong here?

Thanks a lot!
Thomas

Habe die Nextcloud 23.0.1 und bei mir tritt der gleiche Warnung im Abstand von 15 min auf.
User X still has unscanned files after running background scan, background scan might be stopped prematurely

Also seeing this after an update from 22.2.3 to 22.2.5.
I opened an issue for it: https://github.com/nextcloud/server/issues/31283

2 Likes

Alright, summary for the forum peeps:

  • Very likely some data inconsistency in your database that existed for quite long and just now surfaced.
  • It’s nothing problematic, only some file cache entries that point into the woods.
  • You can find them in your database via:
    SELECT DISTINCT * FROM oc_filecache AS f INNER JOIN oc_mounts AS m ON m.storage_id = f.storage WHERE size < 0 AND parent > 1;
    
  • You can remove the relevant entries by their fileid listed in the first column of your results:
    DELETE FROM oc_filecache WHERE fileid = <your id>
    
  • MAKE SURE TO BACKUP YOUR DATABASE BEFORE (or at least this table!)

/S

6 Likes

this didn’t help for me.
I see 4 odd looking cache entries with “news” as name and path when I run this command “SELECT DISTINCT * FROM oc_filecache AS f INNER JOIN oc_mounts AS m ON m.storage_id = f.storage WHERE size < 0 AND parent > -1;”

edit: actually is 1 entry 4 times.

fileid 	storage 	path 	path_hash 	parent 	name 	mimetype 	mimepart 	size 	mtime 	storage_mtime 	encrypted 	unencrypted_size 	etag 	permissions 	checksum 	
108 	1 	news 	508c75c8507a2ae5223dfd2faeb98122 	1 	news 	2 	1 	-1 	1496476044 	1496476044 	0 	0 	5932698ce1bfd 	31

Danke für die Lösung. Bei mir hat es wunderbar geklappt. Der Fehler ist beseitigt.
Danke für die Lösung.

Thank you very much. I was looking everywhere for my MariaDB 100% CPU Issue. I was close to finding it when i saw the queries to oc_filecache but didnt know what to do until ive seen the error “unscanned files after running background scan” which brought me here. You have earned my heart.

Hey there! I have a similar problem, but in my case the output of SELECT DISTINCT * FROM oc_filecache AS f INNER JOIN oc_mounts AS m ON m.storage_id = f.storage WHERE size < 0 AND parent > 1; is 285 rows long. Is there a way to automate the DELETE FROM oc_filecache WHERE fileid = <your id> command? Is there something similar to a bashscript possible in mysql?

Sorry for the noobish question and my missing mysql skills :wink:

@Talus_Unheil: I ran the following command to delete the rows that match the condition as proposed by @simonspa in this comment:

DELETE f FROM filecache AS f INNER JOIN mounts AS m ON m.storage_id = f.storage WHERE size < 0 AND parent > 1;

Also note that in newer NextCloud versions, the table prefix oc_ has been dropped. So filecache instead of oc_filecache and mounts instead of oc_mounts.

4 Likes

Query OK, 264 rows affected (0.097 sec)

Thank you very much – that saved me A LOT of time :wink:

1 Like

Hello All,

I had this problem too but I could not get it working with this solution.
Since tampering with the database furthermore seems risky i decided to delete the entire user.

I think mine relates to something else. When I run files scan manually I get this error,

Exception during scan: Invalid path: /.htaccess

Details here Exception during scan: Invalid path - #2 by terrox

I get this error, too. If I understand it correctly, the problem lies in an inconsistency because some entries are linked to files that no longer exist.

Shouldn’t there be a consistency check tool directly in the Nextcloud application that rechecks all internal links and corrects them if necessary? Such a tool would of course have to be executable via the GUI so that this troubleshooting can also be carried out in a shared hosting environment without shell access.

1 Like

i am sorry to say i have the same errors here and would love to Fix it, I inder stand that you have a solution for this but being new to this problem i dont know how to use the commands that you showed he in this group … can to dump it down for me please.

John G,