Oc_filecache doesn't exist in engine

Hi guys, my server was running well until I the following error appear:

Nextcloud version: 12.0.4
Operating system and version: Raspbian Stretch 9.3
Apache version: 2.4.25-3
PHP version: 7.0.19-1

The issue you are facing:

Is this the first time you’ve seen this error?: Y

Steps to replicate it: it just appeared :frowning:

The output of your Nextcloud log in Admin > Logging: Can’t access web interface

Internal Server Error

The server encountered an internal error and was unable to complete your request.
Please contact the server administrator if this error reappears multiple times, please include the technical details below in your report.
More details can be found in the server log.

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'instanceid' => 'instanceid123',
  'passwordsalt' => 'supersecretpasssalt',
  'secret' => 'supersecret',
  'trusted_domains' => 
  array (
    0 => 'mydomain.com',
  ),
  'datadirectory' => '/media/nextcloud-data',
  'overwrite.cli.url' => 'https://mydomain.com',
  'dbtype' => 'mysql',
  'version' => '12.0.4.3',
  'dbname' => 'nextcloud516970',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'nextcloud',
  'dbpassword' => 'mysupersecretpassword',
  'installed' => true,
  'memcache.local' => '\\OC\\Memcache\\Redis',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' => 
  array (
    'host' => '/var/run/redis/redis.sock',
    'port' => 0,
    'password' => 'mysupersecretpassword',
    'timeout' => 1.5,
  ),
 'maintenance' => false,
  'theme' => '',
  'loglevel' => 2,
);

The output of your Apache/nginx/system log in /var/log/____: apache is running good

Apparently the table oc_filecache is corrupted:

Next Doctrine\DBAL\Exception\DriverException: An exception occurred while executing 'SELECT `fileid`, `storage`, `path`, `path_hash`, `parent`, `name`, `mimetype`, `mimepart`, `size`, `mtime`,
					   `storage_mtime`, `encrypted`, `etag`, `permissions`, `checksum`
				FROM `oc_filecache` WHERE `storage` = ? AND `path_hash` = ?' with params [1, "e029105427ddbaca919c2efde8b7ba73"]:

SQLSTATE[42S02]: Base table or view not found: 1932 Table 'nextcloud516970.oc_filecache' doesn't exist in engine in /var/www/html/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php:116
Stack trace:
#0 /var/www/html/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php(128): Doctrine\DBAL\Driver\AbstractMySQLDriver->convertException('An exception oc...', Object(Doctrine\DBAL\Driver\PDOException))
#1 /var/www/html/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(855): Doctrine\DBAL\DBALException::driverExceptionDuringQuery(Object(Doctrine\DBAL\Driver\PDOMySql\Driver), Object(Doctrine\DBAL\Driver\PDOException), 'SELECT `fileid`...', Array)
#2 /var/www/html/nextcloud/lib/private/DB/Connection.php(192): Doctrine\DBAL\Connection->executeQuery('SELECT `fileid`...', Array, Array, NULL)
#3 /var/www/html/nextcloud/lib/private/Files/Cache/Cache.php(137): OC\DB\Connection->executeQuery('SELECT `fileid`...', Array)
#4 /var/www/html/nextcloud/lib/private/Files/Storage/Wrapper/Encryption.php(929): OC\Files\Cache\Cache->get('files_encryptio...')
#5 /var/www/html/nextcloud/lib/private/Files/Storage/Wrapper/Encryption.php(949): OC\Files\Storage\Wrapper\Encryption->getHeader('files_encryptio...')
#6 /var/www/html/nextcloud/lib/private/Files/Storage/Wrapper/Encryption.php(205): OC\Files\Storage\Wrapper\Encryption->getEncryptionModule('files_encryptio...')
#7 /var/www/html/nextcloud/lib/private/Files/Storage/Wrapper/Wrapper.php(240): OC\Files\Storage\Wrapper\Encryption->file_get_contents('files_encryptio...')
#8 /var/www/html/nextcloud/lib/private/Files/View.php(1156): OC\Files\Storage\Wrapper\Wrapper->file_get_contents('files_encryptio...')
#9 /var/www/html/nextcloud/lib/private/Files/View.php(600): OC\Files\View->basicOperation('file_get_conten...', '/files_encrypti...', Array)
#10 /var/www/html/nextcloud/lib/private/Encryption/Keys/Storage.php(213): OC\Files\View->file_get_contents('/files_encrypti...')
#11 /var/www/html/nextcloud/lib/private/Encryption/Keys/Storage.php(107): OC\Encryption\Keys\Storage->getKey('/files_encrypti...')
#12 /var/www/html/nextcloud/apps/encryption/lib/KeyManager.php(569): OC\Encryption\Keys\Storage->getSystemUserKey('pubShare_7adb8a...', 'OC_DEFAULT_MODU...')
#13 /var/www/html/nextcloud/apps/encryption/lib/KeyManager.php(157): OCA\Encryption\KeyManager->getPublicShareKey()
#14 /var/www/html/nextcloud/apps/encryption/lib/Users/Setup.php(86): OCA\Encryption\KeyManager->validateShareKey()
#15 /var/www/html/nextcloud/apps/encryption/lib/AppInfo/Application.php(73): OCA\Encryption\Users\Setup->setupSystem()
#16 /var/www/html/nextcloud/apps/encryption/appinfo/app.php(30): OCA\Encryption\AppInfo\Application->__construct(Array, true)
#17 /var/www/html/nextcloud/lib/private/legacy/app.php(209): require_once('/var/www/html/n...')
#18 /var/www/html/nextcloud/lib/private/legacy/app.php(149): OC_App::requireAppFile('encryption')
#19 /var/www/html/nextcloud/lib/private/legacy/app.php(124): OC_App::loadApp('encryption')
#20 /var/www/html/nextcloud/lib/private/Console/Application.php(104): OC_App::loadApps()
#21 /var/www/html/nextcloud/console.php(99): OC\Console\Application->loadCommands(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#22 /var/www/html/nextcloud/occ(11): require_once('/var/www/html/n...')
#23 {main}

The table exists, but I get this ERROR 1932 (42S02): Table 'nextcloud516970.oc_filecache' doesn't exist in engine error.

MariaDB [nextcloud516970]> show tables;
+-----------------------------+
| Tables_in_nextcloud516970   |
+-----------------------------+
| oc_accounts                 |
| oc_activity                 |
| oc_activity_mq              |
| oc_addressbookchanges       |
| oc_addressbooks             |
| oc_admin_sections           |
| oc_admin_settings           |
| oc_appconfig                |
| oc_authtoken                |
| oc_bruteforce_attempts      |
| oc_calendarchanges          |
| oc_calendarobjects          |
| oc_calendarobjects_props    |
| oc_calendars                |
| oc_calendarsubscriptions    |
| oc_cards                    |
| oc_cards_properties         |
| oc_comments                 |
| oc_comments_read_markers    |
| oc_credentials              |
| oc_dav_shares               |
| oc_federated_reshares       |
| oc_file_locks               |
| oc_filecache                |
| oc_files_trash              |
| oc_flow_checks              |
| oc_flow_operations          |
| oc_group_admin              |
| oc_group_user               |
| oc_groups                   |
| oc_jobs                     |
| oc_mimetypes                |
| oc_mounts                   |
| oc_notifications            |
| oc_notifications_pushtokens |
| oc_oauth2_access_tokens     |
| oc_oauth2_clients           |
| oc_preferences              |
| oc_privatedata              |
| oc_properties               |
| oc_schedulingobjects        |
| oc_share                    |
| oc_share_external           |
| oc_storages                 |
| oc_systemtag                |
| oc_systemtag_group          |
| oc_systemtag_object_mapping |
| oc_trusted_servers          |
| oc_twofactor_backupcodes    |
| oc_twofactor_totp_secrets   |
| oc_users                    |
| oc_vcategory                |
| oc_vcategory_to_object      |
+-----------------------------+
53 rows in set (0.00 sec)

MariaDB [nextcloud516970]> select * from oc_filecache;
ERROR 1932 (42S02): Table 'nextcloud516970.oc_filecache' doesn't exist in engine
MariaDB [nextcloud516970]>

Any ideas? Can I just drop this table and rebuild it? How?

Strange, I had exactly the same problem three days ago. What was the last thing you did, installed or changed? For me, restarting the MySQL (MariaDB) server already fixed things.

In any case, here is an answer: It seems you can safely truncate the table and ownextcloud will recreate it. So in MySQL, run:

truncate owncloud.oc_filecache;
check table owncloud.oc_filecache;

Hi m4lvin, thanks for your answer.
I have already found this solution, but it didn’t work for me.

MariaDB [nextcloud516970]> truncate oc_filecache;
ERROR 1932 (42S02): Table 'nextcloud516970.oc_filecache' doesn't exist in engine
MariaDB [nextcloud516970]> check table oc_filecache;
+------------------------------+-------+----------+--------------------------------------------------------------+
| Table                        | Op    | Msg_type | Msg_text                                                     |
+------------------------------+-------+----------+--------------------------------------------------------------+
| nextcloud516970.oc_filecache | check | Error    | Table 'nextcloud516970.oc_filecache' doesn't exist in engine |
| nextcloud516970.oc_filecache | check | status   | Operation failed                                             |
+------------------------------+-------+----------+--------------------------------------------------------------+
2 rows in set (0.00 sec)

MariaDB [nextcloud516970]>

Some more ideas what you could try:

  • delete (drop) the whole table and create it again (I think occ maintenance:repair will do this) (edit: worked for me back then, but is a bad idea, see below.)
  • restart MariaDB
  • stop MariaDB, wait and make sure there is really no mysqld process any more, start it again, watch the logs
  • the windows solution :wink: reboot the whole server
    :boom:
    edit from mods: Please don’t just start to delete or modify tables in the database. There are already some Nextcloud commands (with occ-command) available. If you think to check things, do a full backup of your setup. Then it’s preferred you duplicate the whole setup and try changes on the copy first.

Hi,

I’m facing a similar problem with my nextcloud instance. Does the last reply solve the issue?

After uploading a large amount of files mariadb crashed.
The only way to restart the service was to use innodb_force_recovery= 5 into the my.cnf.

Saddly i can’t dump the database because 2 tables are corrupted.

I tried to run a status on my db and i can see the two tables causing issues.

Does maintenance:repair recreate missing tables?
Since i cant dump i hesitate to drop the two tables and use maintenance:repair.

I can’t truncate those tables either:

Please help.

Thank you.

I tried to do a dump without those two tables.

maintenance:repair doesn’t recreate the missing tables.

Anywhere in doc or code i can find the original schema of those two tables?

I think my last attempt would be to manually recreate those 2 tables.

Thank You.

The suggestion to drop the table is wrong!!!

If someone needs to recreate the table, here is from a dump I made 3 years ago.

CREATE TABLE oc_filecache (
fileid bigint(20) NOT NULL,
storage int(11) NOT NULL DEFAULT ‘0’,
path varchar(4000) COLLATE utf8_bin DEFAULT NULL,
path_hash varchar(32) COLLATE utf8_bin NOT NULL DEFAULT ‘’,
parent bigint(20) NOT NULL DEFAULT ‘0’,
name varchar(250) COLLATE utf8_bin DEFAULT NULL,
mimetype int(11) NOT NULL DEFAULT ‘0’,
mimepart int(11) NOT NULL DEFAULT ‘0’,
size bigint(20) NOT NULL DEFAULT ‘0’,
mtime bigint(20) NOT NULL DEFAULT ‘0’,
storage_mtime bigint(20) NOT NULL DEFAULT ‘0’,
encrypted int(11) NOT NULL DEFAULT ‘0’,
unencrypted_size bigint(20) NOT NULL DEFAULT ‘0’,
etag varchar(40) COLLATE utf8_bin DEFAULT NULL,
permissions int(11) DEFAULT ‘0’,
checksum varchar(255) COLLATE utf8_bin DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

I don’t know if it matches the current version as the command below returns error messages.

sudo -u www-data php occ maintenance:repair

This below runs fine.

sudo -u www-data php occ db:add-missing-indices

1 Like