oc_files_metadata corrupt

Nextcloud version _(eg, 29.0.4)
Operating system and version Unraid, Docker Containers by linuxserver

The issue you are facing: Unable to sync files. MariaDB appears to be corrupt. I am unable to use OPTIMIZE TABLE to repair it and it errors out with a 1030 error when trying to dump it.

MariaDB [nextcloud]> CHECK TABLE oc_files_metadata;
±----------------------------±------±---------±-------------------------------------------------------+
| Table | Op | Msg_type | Msg_text |
±----------------------------±------±---------±-------------------------------------------------------+
| nextcloud.oc_files_metadata | check | Warning | InnoDB: Index PRIMARY is marked as corrupted |
| nextcloud.oc_files_metadata | check | Warning | InnoDB: Index files_meta_fileid is marked as corrupted |
| nextcloud.oc_files_metadata | check | error | Corrupt |
±----------------------------±------±---------±-------------------------------------------------------+
3 rows in set (0.001 sec)

Is this the first time you’ve seen this error? (Y/N): Y

Steps to replicate it:

  1. Constant issue with DB
  2. May have been caused by deleting an old file within nextcloud?

No, this is something that would have to happen outside of Nextcloud. Hardware problem, database server bug, filesystem corruption, improper shutdown, mistake when moving around your underling database files, etc.

I would suggest:

  • returning to a known working database backup
  • confirming you’re running a reasonable MariaDB branch (i.e. an LTS branch which at the moment that would be 10.6.x, 10.11.x, or 11.4)
  • confirming you’re running the latest patch release within it (i.e. 10.6.18)
  • see if there’s enough info in your various system log files to isolate the timing of when this likely started so you can maybe determine a root cause

MariaDB releases: https://mariadb.com/kb/en/mariadb-server-release-dates/