Nextcloud oc_filecache corrupt

[details=“Currently when attempting to create a folder, upload a doc I get the following erro:
Doctrine\DBAL\Exception\UniqueConstraintViolationException: An exception occurred while executing ‘INSERT INTO “oc_filecache” (“mimepart”,“mimetype”,“mtime”,“size”,“etag”,“storage_mtime”,“permissions”,“parent”,“checksum”,“path_hash”,“path”,“name”,“storage”) SELECT ?,?,?,?,?,?,?,?,?,?,?,?,? FROM “oc_filecache” WHERE “storage” = ? AND “path_hash” = ? HAVING COUNT(*) = 0’ with params [1, 2, 1532616617, -1, “5b59dfa9c34ce”, 1532616617, 31, 83, “”, “c6b9a0935f24e0bb8c15ca7761265c91”, “files/fsfsdf”, “fsfsdf”, 6, 6, “c6b9a0935f24e0bb8c15ca7761265c91”]: SQLSTATE[23505]: Unique violation: 7 ERROR: duplicate key value violates unique constraint “oc_filecache_pkey” DETAIL: Key (fileid)=(111930) already exists.”]

[/details]

Nextcloud version (eg, 12.0.2): 13,0,1,1
Operating system and version (eg, Ubuntu 17.04): Centos 7
Apache or nginx version (eg, Apache 2.4.25): nginx 1.10
PHP version (eg, 7.1): 7.1

The issue you are facing:
Currently when attempting to create a folder, upload a doc I get the following erro:
Doctrine\DBAL\Exception\UniqueConstraintViolationException: An exception occurred while executing ‘INSERT INTO “oc_filecache” (“mimepart”,“mimetype”,“mtime”,“size”,“etag”,“storage_mtime”,“permissions”,“parent”,“checksum”,“path_hash”,“path”,“name”,“storage”) SELECT ?,?,?,?,?,?,?,?,?,?,?,?,? FROM “oc_filecache” WHERE “storage” = ? AND “path_hash” = ? HAVING COUNT(*) = 0’ with params [1, 2, 1532616617, -1, “5b59dfa9c34ce”, 1532616617, 31, 83, “”, “c6b9a0935f24e0bb8c15ca7761265c91”, “files/fsfsdf”, “fsfsdf”, 6, 6, “c6b9a0935f24e0bb8c15ca7761265c91”]: SQLSTATE[23505]: Unique violation: 7 ERROR: duplicate key value violates unique constraint “oc_filecache_pkey” DETAIL: Key (fileid)=(111930) already exists.

Is this the first time you’ve seen this error? (Y/N):
it has been in the log for a day or so
Steps to replicate it:

  1. Try to upload any document
  2. create a folder
  3. error is thrown and file or folder are not created

The output of your Nextcloud log in Admin > Logging:

Doctrine\DBAL\Exception\UniqueConstraintViolationException: An exception occurred while executing 'INSERT INTO "oc_filecache" ("mimepart","mimetype","mtime","size","etag","storage_mtime","permissions","parent","checksum","path_hash","path","name","storage") SELECT ?,?,?,?,?,?,?,?,?,?,?,?,? FROM "oc_filecache" WHERE "storage" = ? AND "path_hash" = ? HAVING COUNT(*) = 0' with params [1, 2, 1532616617, -1, "5b59dfa9c34ce", 1532616617, 31, 83, "", "c6b9a0935f24e0bb8c15ca7761265c91", "files\/fsfsdf", "fsfsdf", 6, 6, "c6b9a0935f24e0bb8c15ca7761265c91"]: SQLSTATE[23505]: Unique violation: 7 ERROR: duplicate key value violates unique constraint "oc_filecache_pkey" DETAIL: Key (fileid)=(111930) already exists.
/var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php - line 128: Doctrine\DBAL\Driver\AbstractPostgreSQLDriver->convertException('An exception oc...', Object(Doctrine\DBAL\Driver\PDOException))
/var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php - line 1015: Doctrine\DBAL\DBALException driverExceptionDuringQuery(Object(Doctrine\DBAL\Driver\PDOPgSql\Driver), Object(Doctrine\DBAL\Driver\PDOException), 'INSERT INTO "oc...', Array)
/var/www/nextcloud/lib/private/DB/Connection.php - line 216: Doctrine\DBAL\Connection->executeUpdate('INSERT INTO "oc...', Array, Array)
/var/www/nextcloud/lib/private/DB/Adapter.php - line 114: OC\DB\Connection->executeUpdate('INSERT INTO "oc...', Array)
/var/www/nextcloud/lib/private/DB/Connection.php - line 254: OC\DB\Adapter->insertIfNotExist('*PREFIX*filecac...', Array, Array)
/var/www/nextcloud/lib/private/Files/Cache/Cache.php - line 273: OC\DB\Connection->insertIfNotExist('*PREFIX*filecac...', Array, Array)
/var/www/nextcloud/lib/private/Files/Cache/Cache.php - line 230: OC\Files\Cache\Cache->insert('files/fsfsdf', Array)
/var/www/nextcloud/lib/private/Files/Cache/Scanner.php - line 292: OC\Files\Cache\Cache->put('files/fsfsdf', Array)
/var/www/nextcloud/lib/private/Files/Cache/Scanner.php - line 221: OC\Files\Cache\Scanner->addToCache('files/fsfsdf', Array, -1)
/var/www/nextcloud/lib/private/Files/Cache/Scanner.php - line 335: OC\Files\Cache\Scanner->scanFile('files/fsfsdf', 3, 83, false, false)
/var/www/nextcloud/lib/private/Files/Cache/Updater.php - line 124: OC\Files\Cache\Scanner->scan('files/fsfsdf', false, 3, false)
/var/www/nextcloud/lib/private/Files/View.php - line 319: OC\Files\Cache\Updater->update('files/fsfsdf', 1532616617)
/var/www/nextcloud/lib/private/Files/View.php - line 1163: OC\Files\View->writeUpdate(Object(OCA\Files_Trashbin\Storage), 'files/fsfsdf')
/var/www/nextcloud/lib/private/Files/View.php - line 267: OC\Files\View->basicOperation('mkdir', '/fsfsdf', Array)
/var/www/nextcloud/apps/dav/lib/Connector/Sabre/Directory.php - line 180: OC\Files\View->mkdir('//fsfsdf')
/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php - line 1210: OCA\DAV\Connector\Sabre\Directory->createDirectory('fsfsdf')
/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/CorePlugin.php - line 590: Sabre\DAV\Server->createCollection('fsfsdf', Object(Sabre\DAV\MkCol))
[internal function] Sabre\DAV\CorePlugin->httpMkcol(Object(Sabre\HTTP\Request), Object(Sabre\HTTP\Response))
/var/www/nextcloud/3rdparty/sabre/event/lib/EventEmitterTrait.php - line 105: call_user_func_array(Array, Array)
/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php - line 479: Sabre\Event\EventEmitter->emit('method MKCOL', Array)
/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php - line 254: Sabre\DAV\Server->invokeMethod(Object(Sabre\HTTP\Request), Object(Sabre\HTTP\Response))
/var/www/nextcloud/apps/dav/appinfo/v1/webdav.php - line 80: Sabre\DAV\Server->exec()
/var/www/nextcloud/remote.php - line 164: require_once('/var/www/nextcl...')
{main}

The output of your config.php file in `/path/to/nextcloud` (make sure you remove any identifiable information!):
<?php
$CONFIG = array (
  'instanceid' => 'xxxxxx',
  'passwordsalt' => 'xxxxxxx,
  'secret' => 'xxxxxx',
  'trusted_domains' => 
  array (
    0 => 'xxxxxx',
    1 => 'xxxxxxxx',
    2 => 'xxxxxx',
    3 => 'xxxxxxxx',
  ),
  'datadirectory' => 'xxxxxx',
  'overwrite.cli.url' => 'xxxxxxxxx',
  'dbtype' => 'pgsql',
  'version' => '13.0.1.1',
  'dbname' => 'xxxxx,
  'dbhost' => 'xxxxxx',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'xxxxxxx',
  'dbpassword' => 'xxxxxxxx
  'logtimezone' => 'UTC',
  'installed' => true,
  'ldapIgnoreNamingRules' => false,
  'loglevel' => 2,
  'maintenance' => false,
  'updater.release.channel' => 'stable',
  'ldapProviderFactory' => '\\OCA\\User_LDAP\\LDAPProviderFactory',
);


The output of your Apache/nginx/system log in `/var/log/____`:

PASTE HERE

Can you take a look into your database? checkout the entries for the fileid 111930, there should be two of them (even though there should be only one). If they are identical, delete one of them.