Server unavailable: "oc_filecache is corrupted"

Nextcloud version : 18.0.7
Operating system and version : Debian 10
Apache version : 2.4.38
PHP version : 7.3.19-1

The issue you are facing:
I can’t access my server neither via app nor via browser. The Nextcloud log gives me error messages like this one, containing the message “oc_filecache is corrupted”:

Error message
{
  "reqId": "wsQp9I5SWsPYmRfo6i88",
  "level": 3,
  "time": "2020-09-18T09:45:03+00:00",
  "remoteAddr": "",
  "user": "--",
  "app": "files",
  "method": "",
  "url": "--",
  "message": {
    "Exception": "Doctrine\\DBAL\\Exception\\DriverException",
    "Message": "An exception occurred while executing 'SELECT `fileid` FROM `oc_filecache` WHERE (`storage` = ?) AND (`path_hash` = ?)' with params [4, \"d41d8cd98f00b204e9800998ecf8427e\"]:\n\nSQLSTATE[HY000]: General error: 1712 Index oc_filecache is corrupted",
    "Code": 0,
    "Trace": [
      {
        "file": "/var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php",
        "line": 169,
        "function": "convertException",
        "class": "Doctrine\\DBAL\\Driver\\AbstractMySQLDriver",
        "type": "->",
        "args": [
          "An exception occurred while executing 'SELECT `fileid` FROM `oc_filecache` WHERE (`storage` = ?) AND (`path_hash` = ?)' with params [4, \"d41d8cd98f00b204e9800998ecf8427e\"]:\n\nSQLSTATE[HY000]: General error: 1712 Index oc_filecache is corrupted",
          {
            "errorInfo": [
              "HY000",
              1712,
              "Index oc_filecache is corrupted"
            ],
            "__class__": "Doctrine\\DBAL\\Driver\\PDOException"
          }
        ]
      },
      {
        "file": "/var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php",
        "line": 145,
        "function": "wrapException",
        "class": "Doctrine\\DBAL\\DBALException",
        "type": "::",
        "args": [
          {
            "__class__": "Doctrine\\DBAL\\Driver\\PDOMySql\\Driver"
          },
          {
            "errorInfo": [
              "HY000",
              1712,
              "Index oc_filecache is corrupted"
            ],
            "__class__": "Doctrine\\DBAL\\Driver\\PDOException"
          },
          "An exception occurred while executing 'SELECT `fileid` FROM `oc_filecache` WHERE (`storage` = ?) AND (`path_hash` = ?)' with params [4, \"d41d8cd98f00b204e9800998ecf8427e\"]:\n\nSQLSTATE[HY000]: General error: 1712 Index oc_filecache is corrupted"
        ]
      },
      {
        "file": "/var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php",
        "line": 911,
        "function": "driverExceptionDuringQuery",
        "class": "Doctrine\\DBAL\\DBALException",
        "type": "::",
        "args": [
          {
            "__class__": "Doctrine\\DBAL\\Driver\\PDOMySql\\Driver"
          },
          {
            "errorInfo": [
              "HY000",
              1712,
              "Index oc_filecache is corrupted"
            ],
            "__class__": "Doctrine\\DBAL\\Driver\\PDOException"
          },
          "SELECT `fileid` FROM `oc_filecache` WHERE (`storage` = ?) AND (`path_hash` = ?)",
          {
            "1": 4,
            "2": "d41d8cd98f00b204e9800998ecf8427e"
          }
        ]
      },
      {
        "file": "/var/www/nextcloud/lib/private/DB/Connection.php",
        "line": 199,
        "function": "executeQuery",
        "class": "Doctrine\\DBAL\\Connection",
        "type": "->",
        "args": [
          "SELECT `fileid` FROM `oc_filecache` WHERE (`storage` = ?) AND (`path_hash` = ?)",
          [
            4,
            "d41d8cd98f00b204e9800998ecf8427e"
          ],
          [
            1,
            2
          ],
          null
        ]
      },
      {
        "file": "/var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Query/QueryBuilder.php",
        "line": 200,
        "function": "executeQuery",
        "class": "OC\\DB\\Connection",
        "type": "->",
        "args": [
          "SELECT `fileid` FROM `oc_filecache` WHERE (`storage` = :dcValue1) AND (`path_hash` = :dcValue2)",
          {
            "dcValue1": 4,
            "dcValue2": "d41d8cd98f00b204e9800998ecf8427e"
          },
          {
            "dcValue1": 1,
            "dcValue2": 2
          }
        ]
      },
      {
        "file": "/var/www/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php",
        "line": 215,
        "function": "execute",
        "class": "Doctrine\\DBAL\\Query\\QueryBuilder",
        "type": "->",
        "args": []
      },
      {
        "file": "/var/www/nextcloud/lib/private/Files/Cache/Cache.php",
        "line": 466,
        "function": "execute",
        "class": "OC\\DB\\QueryBuilder\\QueryBuilder",
        "type": "->",
        "args": []
      },
      {
        "file": "/var/www/nextcloud/lib/private/Files/Mount/MountPoint.php",
        "line": 271,
        "function": "getId",
        "class": "OC\\Files\\Cache\\Cache",
        "type": "->",
        "args": [
          ""
        ]
      },
      {
        "file": "/var/www/nextcloud/lib/private/Files/Filesystem.php",
        "line": 441,
        "function": "getStorageRootId",
        "class": "OC\\Files\\Mount\\MountPoint",
        "type": "->",
        "args": []
      },
      {
        "file": "/var/www/nextcloud/lib/private/Files/Filesystem.php",
        "line": 377,
        "function": "initMountPoints",
        "class": "OC\\Files\\Filesystem",
        "type": "::",
        "args": [
          "tusk"
        ]
      },
      {
        "file": "/var/www/nextcloud/lib/private/legacy/util.php",
        "line": 309,
        "function": "init",
        "class": "OC\\Files\\Filesystem",
        "type": "::",
        "args": [
          "tusk",
          "/tusk/files"
        ]
      },
      {
        "file": "/var/www/nextcloud/lib/private/Files/Utils/Scanner.php",
        "line": 116,
        "function": "setupFS",
        "class": "OC_Util",
        "type": "::",
        "args": [
          "tusk"
        ]
      },
      {
        "file": "/var/www/nextcloud/lib/private/Files/Utils/Scanner.php",
        "line": 155,
        "function": "getMounts",
        "class": "OC\\Files\\Utils\\Scanner",
        "type": "->",
        "args": [
          ""
        ]
      },
      {
        "file": "/var/www/nextcloud/apps/files/lib/BackgroundJob/ScanFiles.php",
        "line": 83,
        "function": "backgroundScan",
        "class": "OC\\Files\\Utils\\Scanner",
        "type": "->",
        "args": [
          ""
        ]
      },
      {
        "file": "/var/www/nextcloud/apps/files/lib/BackgroundJob/ScanFiles.php",
        "line": 111,
        "function": "runScanner",
        "class": "OCA\\Files\\BackgroundJob\\ScanFiles",
        "type": "->",
        "args": [
          {
            "__class__": "OC\\User\\User"
          }
        ]
      },
      {
        "file": "/var/www/nextcloud/lib/private/BackgroundJob/Job.php",
        "line": 61,
        "function": "run",
        "class": "OCA\\Files\\BackgroundJob\\ScanFiles",
        "type": "->",
        "args": [
          null
        ]
      },
      {
        "file": "/var/www/nextcloud/lib/private/BackgroundJob/TimedJob.php",
        "line": 55,
        "function": "execute",
        "class": "OC\\BackgroundJob\\Job",
        "type": "->",
        "args": [
          {
            "__class__": "OC\\BackgroundJob\\JobList"
          },
          {
            "__class__": "OC\\Log"
          }
        ]
      },
      {
        "file": "/var/www/nextcloud/cron.php",
        "line": 125,
        "function": "execute",
        "class": "OC\\BackgroundJob\\TimedJob",
        "type": "->",
        "args": [
          {
            "__class__": "OC\\BackgroundJob\\JobList"
          },
          {
            "__class__": "OC\\Log"
          }
        ]
      }
    ],
    "File": "/var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php",
    "Line": 106,
    "Previous": {
      "Exception": "Doctrine\\DBAL\\Driver\\PDOException",
      "Message": "SQLSTATE[HY000]: General error: 1712 Index oc_filecache is corrupted",
      "Code": "HY000",
      "Trace": [
        {
          "file": "/var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php",
          "line": 903,
          "function": "execute",
          "class": "Doctrine\\DBAL\\Driver\\PDOStatement",
          "type": "->",
          "args": []
        },
        {
          "file": "/var/www/nextcloud/lib/private/DB/Connection.php",
          "line": 199,
          "function": "executeQuery",
          "class": "Doctrine\\DBAL\\Connection",
          "type": "->",
          "args": [
            "SELECT `fileid` FROM `oc_filecache` WHERE (`storage` = ?) AND (`path_hash` = ?)",
            [
              4,
              "d41d8cd98f00b204e9800998ecf8427e"
            ],
            [
              1,
              2
            ],
            null
          ]
        },
        {
          "file": "/var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Query/QueryBuilder.php",
          "line": 200,
          "function": "executeQuery",
          "class": "OC\\DB\\Connection",
          "type": "->",
          "args": [
            "SELECT `fileid` FROM `oc_filecache` WHERE (`storage` = :dcValue1) AND (`path_hash` = :dcValue2)",
            {
              "dcValue1": 4,
              "dcValue2": "d41d8cd98f00b204e9800998ecf8427e"
            },
            {
              "dcValue1": 1,
              "dcValue2": 2
            }
          ]
        },
        {
          "file": "/var/www/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php",
          "line": 215,
          "function": "execute",
          "class": "Doctrine\\DBAL\\Query\\QueryBuilder",
          "type": "->",
          "args": []
        },
        {
          "file": "/var/www/nextcloud/lib/private/Files/Cache/Cache.php",
          "line": 466,
          "function": "execute",
          "class": "OC\\DB\\QueryBuilder\\QueryBuilder",
          "type": "->",
          "args": []
        },
        {
          "file": "/var/www/nextcloud/lib/private/Files/Mount/MountPoint.php",
          "line": 271,
          "function": "getId",
          "class": "OC\\Files\\Cache\\Cache",
          "type": "->",
          "args": [
            ""
          ]
        },
        {
          "file": "/var/www/nextcloud/lib/private/Files/Filesystem.php",
          "line": 441,
          "function": "getStorageRootId",
          "class": "OC\\Files\\Mount\\MountPoint",
          "type": "->",
          "args": []
        },
        {
          "file": "/var/www/nextcloud/lib/private/Files/Filesystem.php",
          "line": 377,
          "function": "initMountPoints",
          "class": "OC\\Files\\Filesystem",
          "type": "::",
          "args": [
            "tusk"
          ]
        },
        {
          "file": "/var/www/nextcloud/lib/private/legacy/util.php",
          "line": 309,
          "function": "init",
          "class": "OC\\Files\\Filesystem",
          "type": "::",
          "args": [
            "tusk",
            "/tusk/files"
          ]
        },
        {
          "file": "/var/www/nextcloud/lib/private/Files/Utils/Scanner.php",
          "line": 116,
          "function": "setupFS",
          "class": "OC_Util",
          "type": "::",
          "args": [
            "tusk"
          ]
        },
        {
          "file": "/var/www/nextcloud/lib/private/Files/Utils/Scanner.php",
          "line": 155,
          "function": "getMounts",
          "class": "OC\\Files\\Utils\\Scanner",
          "type": "->",
          "args": [
            ""
          ]
        },
        {
          "file": "/var/www/nextcloud/apps/files/lib/BackgroundJob/ScanFiles.php",
          "line": 83,
          "function": "backgroundScan",
          "class": "OC\\Files\\Utils\\Scanner",
          "type": "->",
          "args": [
            ""
          ]
        },
        {
          "file": "/var/www/nextcloud/apps/files/lib/BackgroundJob/ScanFiles.php",
          "line": 111,
          "function": "runScanner",
          "class": "OCA\\Files\\BackgroundJob\\ScanFiles",
          "type": "->",
          "args": [
            {
              "__class__": "OC\\User\\User"
            }
          ]
        },
        {
          "file": "/var/www/nextcloud/lib/private/BackgroundJob/Job.php",
          "line": 61,
          "function": "run",
          "class": "OCA\\Files\\BackgroundJob\\ScanFiles",
          "type": "->",
          "args": [
            null
          ]
        },
        {
          "file": "/var/www/nextcloud/lib/private/BackgroundJob/TimedJob.php",
          "line": 55,
          "function": "execute",
          "class": "OC\\BackgroundJob\\Job",
          "type": "->",
          "args": [
            {
              "__class__": "OC\\BackgroundJob\\JobList"
            },
            {
              "__class__": "OC\\Log"
            }
          ]
        },
        {
          "file": "/var/www/nextcloud/cron.php",
          "line": 125,
          "function": "execute",
          "class": "OC\\BackgroundJob\\TimedJob",
          "type": "->",
          "args": [
            {
              "__class__": "OC\\BackgroundJob\\JobList"
            },
            {
              "__class__": "OC\\Log"
            }
          ]
        }
      ],
      "File": "/var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php",
      "Line": 119,
      "Previous": {
        "Exception": "PDOException",
        "Message": "SQLSTATE[HY000]: General error: 1712 Index oc_filecache is corrupted",
        "Code": "HY000",
        "Trace": [
          {
            "file": "/var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php",
            "line": 117,
            "function": "execute",
            "class": "PDOStatement",
            "type": "->",
            "args": [
              null
            ]
          },
          {
            "file": "/var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php",
            "line": 903,
            "function": "execute",
            "class": "Doctrine\\DBAL\\Driver\\PDOStatement",
            "type": "->",
            "args": []
          },
          {
            "file": "/var/www/nextcloud/lib/private/DB/Connection.php",
            "line": 199,
            "function": "executeQuery",
            "class": "Doctrine\\DBAL\\Connection",
            "type": "->",
            "args": [
              "SELECT `fileid` FROM `oc_filecache` WHERE (`storage` = ?) AND (`path_hash` = ?)",
              [
                4,
                "d41d8cd98f00b204e9800998ecf8427e"
              ],
              [
                1,
                2
              ],
              null
            ]
          },
          {
            "file": "/var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Query/QueryBuilder.php",
            "line": 200,
            "function": "executeQuery",
            "class": "OC\\DB\\Connection",
            "type": "->",
            "args": [
              "SELECT `fileid` FROM `oc_filecache` WHERE (`storage` = :dcValue1) AND (`path_hash` = :dcValue2)",
              {
                "dcValue1": 4,
                "dcValue2": "d41d8cd98f00b204e9800998ecf8427e"
              },
              {
                "dcValue1": 1,
                "dcValue2": 2
              }
            ]
          },
          {
            "file": "/var/www/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php",
            "line": 215,
            "function": "execute",
            "class": "Doctrine\\DBAL\\Query\\QueryBuilder",
            "type": "->",
            "args": []
          },
          {
            "file": "/var/www/nextcloud/lib/private/Files/Cache/Cache.php",
            "line": 466,
            "function": "execute",
            "class": "OC\\DB\\QueryBuilder\\QueryBuilder",
            "type": "->",
            "args": []
          },
          {
            "file": "/var/www/nextcloud/lib/private/Files/Mount/MountPoint.php",
            "line": 271,
            "function": "getId",
            "class": "OC\\Files\\Cache\\Cache",
            "type": "->",
            "args": [
              ""
            ]
          },
          {
            "file": "/var/www/nextcloud/lib/private/Files/Filesystem.php",
            "line": 441,
            "function": "getStorageRootId",
            "class": "OC\\Files\\Mount\\MountPoint",
            "type": "->",
            "args": []
          },
          {
            "file": "/var/www/nextcloud/lib/private/Files/Filesystem.php",
            "line": 377,
            "function": "initMountPoints",
            "class": "OC\\Files\\Filesystem",
            "type": "::",
            "args": [
              "tusk"
            ]
          },
          {
            "file": "/var/www/nextcloud/lib/private/legacy/util.php",
            "line": 309,
            "function": "init",
            "class": "OC\\Files\\Filesystem",
            "type": "::",
            "args": [
              "tusk",
              "/tusk/files"
            ]
          },
          {
            "file": "/var/www/nextcloud/lib/private/Files/Utils/Scanner.php",
            "line": 116,
            "function": "setupFS",
            "class": "OC_Util",
            "type": "::",
            "args": [
              "tusk"
            ]
          },
          {
            "file": "/var/www/nextcloud/lib/private/Files/Utils/Scanner.php",
            "line": 155,
            "function": "getMounts",
            "class": "OC\\Files\\Utils\\Scanner",
            "type": "->",
            "args": [
              ""
            ]
          },
          {
            "file": "/var/www/nextcloud/apps/files/lib/BackgroundJob/ScanFiles.php",
            "line": 83,
            "function": "backgroundScan",
            "class": "OC\\Files\\Utils\\Scanner",
            "type": "->",
            "args": [
              ""
            ]
          },
          {
            "file": "/var/www/nextcloud/apps/files/lib/BackgroundJob/ScanFiles.php",
            "line": 111,
            "function": "runScanner",
            "class": "OCA\\Files\\BackgroundJob\\ScanFiles",
            "type": "->",
            "args": [
              {
                "__class__": "OC\\User\\User"
              }
            ]
          },
          {
            "file": "/var/www/nextcloud/lib/private/BackgroundJob/Job.php",
            "line": 61,
            "function": "run",
            "class": "OCA\\Files\\BackgroundJob\\ScanFiles",
            "type": "->",
            "args": [
              null
            ]
          },
          {
            "file": "/var/www/nextcloud/lib/private/BackgroundJob/TimedJob.php",
            "line": 55,
            "function": "execute",
            "class": "OC\\BackgroundJob\\Job",
            "type": "->",
            "args": [
              {
                "__class__": "OC\\BackgroundJob\\JobList"
              },
              {
                "__class__": "OC\\Log"
              }
            ]
          },
          {
            "file": "/var/www/nextcloud/cron.php",
            "line": 125,
            "function": "execute",
            "class": "OC\\BackgroundJob\\TimedJob",
            "type": "->",
            "args": [
              {
                "__class__": "OC\\BackgroundJob\\JobList"
              },
              {
                "__class__": "OC\\Log"
              }
            ]
          }
        ],
        "File": "/var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php",
        "Line": 117
      }
    },
    "CustomMessage": "--"
  },
  "userAgent": "--",
  "version": "18.0.7.1"
}

Also the occ command is not running. It returns a similar message, also containing the oc_filecache is corrupted" message:

occ error message

An unhandled exception has been thrown:
PDOException: SQLSTATE[HY000]: General error: 1712 Index oc_filecache is corrupted in /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:117
Stack trace:
#0 /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php(117): PDOStatement->execute(NULL)
#1 /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(903): Doctrine\DBAL\Driver\PDOStatement->execute()
#2 /var/www/nextcloud/lib/private/DB/Connection.php(199): Doctrine\DBAL\Connection->executeQuery(‘SELECT filecac...', Array, Array, NULL) #3 /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Query/QueryBuilder.php(200): OC\DB\Connection->executeQuery('SELECT filecac…’, Array, Array)
#4 /var/www/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php(215): Doctrine\DBAL\Query\QueryBuilder->execute()
#5 /var/www/nextcloud/lib/private/Files/Cache/Cache.php(153): OC\DB\QueryBuilder\QueryBuilder->execute()
#6 /var/www/nextcloud/lib/private/Files/View.php(1329): OC\Files\Cache\Cache->get(‘news/config’)
#7 /var/www/nextcloud/lib/private/Files/View.php(1384): OC\Files\View->getCacheEntry(Object(OCA\Files_Trashbin\Storage), ‘news/config’, ‘/news/config’)
#8 /var/www/nextcloud/lib/private/Files/Node/Root.php(200): OC\Files\View->getFileInfo(’/news/config’)
#9 /var/www/nextcloud/lib/private/Files/Node/Folder.php(146): OC\Files\Node\Root->get(’/news/config’)
#10 [internal function]: OC\Files\Node\Folder->nodeExists(‘news/config’)
#11 /var/www/nextcloud/lib/private/Files/Node/LazyRoot.php(65): call_user_func_array(Array, Array)
#12 /var/www/nextcloud/lib/private/Files/Node/LazyRoot.php(384): OC\Files\Node\LazyRoot->__call(‘nodeExists’, Array)
#13 /var/www/nextcloud/apps/news/lib/AppInfo/Application.php(109): OC\Files\Node\LazyRoot->nodeExists(‘news/config’)
#14 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OCA\News\AppInfo\Application->OCA\News\AppInfo{closure}(Object(OC\AppFramework\DependencyInjection\DIContainer))
#15 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(113): Pimple\Container->offsetGet(‘ConfigView’)
#16 /var/www/nextcloud/lib/private/AppFramework/DependencyInjection/DIContainer.php(408): OC\AppFramework\Utility\SimpleContainer->query(‘ConfigView’)
#17 /var/www/nextcloud/lib/private/AppFramework/DependencyInjection/DIContainer.php(386): OC\AppFramework\DependencyInjection\DIContainer->queryNoFallback(‘ConfigView’)
#18 /var/www/nextcloud/apps/news/lib/AppInfo/Application.php(128): OC\AppFramework\DependencyInjection\DIContainer->query(‘ConfigView’)
#19 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OCA\News\AppInfo\Application->OCA\News\AppInfo{closure}(Object(OC\AppFramework\DependencyInjection\DIContainer))
#20 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(113): Pimple\Container->offsetGet(‘OCA\News\Config…’)
#21 /var/www/nextcloud/lib/private/AppFramework/DependencyInjection/DIContainer.php(408): OC\AppFramework\Utility\SimpleContainer->query(‘OCA\News\Config…’)
#22 /var/www/nextcloud/lib/private/AppFramework/DependencyInjection/DIContainer.php(386): OC\AppFramework\DependencyInjection\DIContainer->queryNoFallback(‘OCA\News\Config…’)
#23 /var/www/nextcloud/apps/news/lib/AppInfo/Application.php(178): OC\AppFramework\DependencyInjection\DIContainer->query(‘OCA\News\Config…’)
#24 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OCA\News\AppInfo\Application->OCA\News\AppInfo{closure}(Object(OC\AppFramework\DependencyInjection\DIContainer))
#25 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(113): Pimple\Container->offsetGet(‘OCA\News\Config…’)
#26 /var/www/nextcloud/lib/private/AppFramework/DependencyInjection/DIContainer.php(408): OC\AppFramework\Utility\SimpleContainer->query(‘OCA\News\Config…’)
#27 /var/www/nextcloud/lib/private/AppFramework/DependencyInjection/DIContainer.php(386): OC\AppFramework\DependencyInjection\DIContainer->queryNoFallback(‘OCA\News\Config…’)
#28 /var/www/nextcloud/apps/news/lib/AppInfo/Application.php(185): OC\AppFramework\DependencyInjection\DIContainer->query(‘OCA\News\Config…’)
#29 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OCA\News\AppInfo\Application->OCA\News\AppInfo{closure}(Object(OC\AppFramework\DependencyInjection\DIContainer))
#30 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(113): Pimple\Container->offsetGet(‘FeedIo\FeedIo’)
#31 /var/www/nextcloud/lib/private/AppFramework/DependencyInjection/DIContainer.php(408): OC\AppFramework\Utility\SimpleContainer->query(‘FeedIo\FeedIo’)
#32 /var/www/nextcloud/lib/private/AppFramework/DependencyInjection/DIContainer.php(386): OC\AppFramework\DependencyInjection\DIContainer->queryNoFallback(‘FeedIo\FeedIo’)
#33 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(70): OC\AppFramework\DependencyInjection\DIContainer->query(‘FeedIo\FeedIo’, true)
#34 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(100): OC\AppFramework\Utility\SimpleContainer->buildClass(Object(ReflectionClass))
#35 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(115): OC\AppFramework\Utility\SimpleContainer->resolve(‘OCA\News\Comman…’)
#36 /var/www/nextcloud/lib/private/AppFramework/DependencyInjection/DIContainer.php(415): OC\AppFramework\Utility\SimpleContainer->query(‘OCA\News\Comman…’)
#37 /var/www/nextcloud/lib/private/ServerContainer.php(134): OC\AppFramework\DependencyInjection\DIContainer->queryNoFallback(‘OCA\News\Comman…’)
#38 /var/www/nextcloud/lib/private/Console/Application.php(220): OC\ServerContainer->query(‘OCA\News\Comman…’)
#39 /var/www/nextcloud/lib/private/Console/Application.php(135): OC\Console\Application->loadCommandsFromInfoXml(Array)
#40 /var/www/nextcloud/console.php(98): OC\Console\Application->loadCommands(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#41 /var/www/nextcloud/occ(11): require_once(’/var/www/nextcl…’)
#42 {main}

This is my config.php:

config file
<?php
$CONFIG = array (
  'passwordsalt' => *removed*,
  'secret' => *removed*,
  'trusted_domains' => 
  *removed*
  'datadirectory' => '/media/Nextcloud-Data/NC-Data',
  'dbtype' => 'mysql',
  'version' => '18.0.7.1',
  'overwrite.cli.url' =>*removed*,
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'ncadmin',
  'dbpassword' =>*removed*,
  'installed' => true,
  'instanceid' => *removed*,
  'memcache.local' => '\\OC\\Memcache\\Redis',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' => 
  array (
    'host' => '/var/run/redis/redis.sock',
    'port' => 0,
    'timeout' => 0.0,
    'password' => *removed*,
  ),
  'tempdirectory' => '/media/Nextcloud-Data/nc-tmp',
  'mail_smtpmode' => 'sendmail',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_from_address' => 'admin',
  'mail_domain' => 'ownyourbits.com',
  'preview_max_x' => '2048',
  'preview_max_y' => '2048',
  'jpeg_quality' => '60',
  'overwriteprotocol' => 'https',
  'maintenance' => false,
  'logfile' => '/media/Nextcloud-Data/nc-log/nextcloud.log',
  'loglevel' => 2,
);

This appeared approx two weeks ago. I didn’t change anything in the configuration to that time.
Any idea how I can get my oc_filecache table fixed?

There are repair commands you can run in the database:

Original: In this case, simply restarting MariaDB already did the job.

Edit: I was wrong when I said, restarting MariaDB did the job. My tables stayed corrupted even when using the MYSQL CHECK and REPAIR commands. For that reason, I created a sql dump of the database and removed the whole database to recreate it. Unfortunately, my dump was incomplete.
So I wanted to manually recreate the database and rescan all my files. i used

    CREATE DATABASE IF NOT EXISTS nextcloud CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
    GRANT ALL PRIVILEGES on nextcloud.* to 'username'@'localhost';
    FLUSH privileges;

according to the installation manual ( https://docs.nextcloud.com/server/18/admin_manual/configuration_database/linux_database_configuration.html ). But I don’t know how I can get Nextcloud to recreate all needed tables again. is there an occ command for this?

I had similar issue yesterday, unfortunately the issue reappeared even if I restored the table from my backup (from 10 days ago). So I had to recreate the table (empty) and then have Nextcloud populate it again. Unfortunately this way you lose your shares and what’s worse your labels :frowning:

Hi mehturt,
as described in my edited post above, opposing to your situation, I deleted not only the corrupted table, but the complete database. After recreating the databaseso I need to recreate all tables know. How did you recreate your table? Did you use any nextcloud tool for this?

I dropped the table and restored from backup (I make weekly DB backups using mysqldump).
Unfortunately, when the table is corrupted, the backup (mysqldump) does not work, but I did not have any notification on this.

I’ve been having this same issue recently.

Mobile app says can’t sync because of maintenance mode and when I go to check it up it says internal server error. Log says repeatedly when trying to access files:

Error message: Doctrine\DBAL\Exception\DriverException: An exception occurred while executing a query: SQLSTATE[HY000]: General error: 1712 Index oc_filecache is corrupted

  • Have been working properly for a long time but happening in recent versions
  • I have my tables set up correctly as InnoDB
  • Restarting mysql service solves the problem until it happens again after random time from several hours to days

I have 21.0.2 installed. I remember the instance working just fine prior 21.0.0. No issues in Security & setup warnings, I never have those. Sometimes after upgrade I have to run occ db:add-missing-indices but mostly it’s all fine. I have been trying some things like this but they haven’t helped. I’m kinda hopeless against this issue. It would be a pain to do a clean reinstall because I have lots of data and several external storages attached…

Help?

I can only try to remember what I did back then…
I tried the MYSQL CHECK and REPAIR commands. Probably something similar exists for InnoDB.
Since that did not work, I created a dump of my whole database in order to drop the database and recreate it again. Unfortunately, the database system wasn’t able to create the whole dump, probably because of the corrupted table.
So I ended up with creating a new database and rescan all my files. However, as @mehturt pointed out, this will result in a loss of all shares, labels etc. In my case, that wasn’t such a big deal.

In my case it was, I was trying to use labels for my documents, as opposed to sort them in folders. So I was very disappointed. Not sure if there’s a way to prevent this, or at least how to catch this problem early.