Oc_filecache role in Nextcloud

Hi, i am wondering if someone can help me to understand the role of oc_filechache.

Recently I encountered a problem with corrupted datasets in oc_filecache. Reparing Table does not help so it was necessary to truncate the table.

After that all of my clients hat to resync completely with the server.

Because I tried to create a trigger in zabbix monitoring when file count decreased above a certain percentage (to get an alarm if a high amount of files are deleted). I used the monitor API and fetched the file count there.

Now my question:

The file count over the api never degreases no matter how much files are deleted.

But: As truncating my oc_filecache table I got alarm messages and saw. that file count in the maintenance api dropped to zero and started to increase.

Obviously, oc_filecache is the central database for all files in Nextcloud.

Here my questions:

  • Is there any other way to repair oc_filecache to prevent truncating and rebuilding the index?
  • Why is it that the filecount in the maintenance api does not reflect the real file count?

You have a few command line commands to “repair” or clean up the filecache table:
https://docs.nextcloud.com/server/latest/admin_manual/occ_command.html#scan

Filecache table does not only have one entry per file, it also holds entries for different versions, deleted objects, shared objects, app data, …

For the API, I don’t know, it is just the number of “real” files in a user’s folder?

Are you referring to data from the serverinfo endpoint? If so, it is not updated in real-time (and only every 3 hours by default). See Serverinfo: Configuration.

Recently I encountered a problem with corrupted datasets in oc_filecache

Can you elaborate?

Reparing Table does not help so it was necessary to truncate the table.

What about restoring from a backup?

Is there any other way to repair oc_filecache to prevent truncating and rebuilding the index?

Backups, generally. But it really depends on the specifics.

For example, there is a huge difference between a problem with your database server versus something with Nextcloud’s use of the database (the former can’t be repaired by Nextcloud Server).