server icon indicating copy to clipboard operation
server copied to clipboard

Doctrine\DBAL\Exception\UniqueConstraintViolationException: An exception occurred while executing 'INSERT INTO "oc_filecache"

Open enoch85 opened this issue 9 years ago • 38 comments

Steps to reproduce

Don't know

Expected behaviour

No error

Actual behaviour

See Nextcloud log

General server configuration

Operating system: Linux cloud.techandme.se 4.4.0-91-generic #114-Ubuntu SMP Tue Aug 8 11:56:56 UTC 2017 x86_64

Web server: Apache/2.4.18 (Ubuntu) (apache2handler)

Database: pgsql PostgreSQL 9.6.4 on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609, 64-bit

PHP version: 7.0.22-0ubuntu0.16.04.1

PHP-modules loaded
 - Core
 - date
 - libxml
 - openssl
 - pcre
 - zlib
 - filter
 - hash
 - Reflection
 - SPL
 - session
 - standard
 - apache2handler
 - PDO
 - xml
 - calendar
 - ctype
 - curl
 - dom
 - mbstring
 - fileinfo
 - ftp
 - gd
 - gettext
 - iconv
 - imap
 - intl
 - json
 - ldap
 - exif
 - mcrypt
 - pdo_pgsql
 - pdo_sqlite
 - pgsql
 - Phar
 - posix
 - readline
 - redis
 - shmop
 - SimpleXML
 - smbclient
 - sockets
 - sqlite3
 - sysvmsg
 - sysvsem
 - sysvshm
 - tokenizer
 - wddx
 - xmlreader
 - xmlwriter
 - xsl
 - zip
 - libsmbclient
 - Zend OPcache

Nextcloud configuration

Nextcloud version: 12.0.2 - 12.0.2.0

Updated from an older Nextcloud/ownCloud or fresh install: YOUR ANSWER HERE

Where did you install Nextcloud from: YOUR ANSWER HERE

Are you using external storage, if yes which one: Array ( [0] => \OC\Files\Storage\Local [1] => \OCA\Files_External\Lib\Storage\FTP [2] => \OC\Files\Storage\DAV [3] => \OCA\Files_External\Lib\Storage\OwnCloud [4] => \OCA\Files_External\Lib\Storage\SFTP [5] => \OCA\Files_External\Lib\Storage\AmazonS3 [6] => \OCA\Files_External\Lib\Storage\Dropbox [7] => \OCA\Files_External\Lib\Storage\Google [8] => \OCA\Files_External\Lib\Storage\Swift [9] => \OCA\Files_External\Lib\Storage\SFTP [10] => \OCA\Files_External\Lib\Storage\SMB [11] => \OCA\Files_External\Lib\Storage\SMB )

Are you using encryption: no

Are you using an external user-backend, if yes which one: NO (LDAP/ActiveDirectory/Webdav/...)

Signing status
[]
Enabled apps
 - activity: 2.5.2
 - admin_notifications: 1.0.0
 - bruteforcesettings: 1.0.2
 - calendar: 1.5.3
 - checksum: 0.3.5
 - comments: 1.2.0
 - contacts: 1.5.3
 - dav: 1.3.0
 - federatedfilesharing: 1.2.0
 - federation: 1.2.0
 - files: 1.7.2
 - files_downloadactivity: 1.1.1
 - files_external: 1.3.0
 - files_pdfviewer: 1.1.1
 - files_sharing: 1.4.0
 - files_texteditor: 2.4.1
 - files_trashbin: 1.2.0
 - files_versions: 1.5.0
 - files_videoplayer: 1.1.0
 - firstrunwizard: 2.1
 - gallery: 17.0.0
 - impersonate: 1.0.1
 - issuetemplate: 0.2.2
 - logreader: 2.0.0
 - lookup_server_connector: 1.0.0
 - mail: 0.6.4
 - nextcloud_announcements: 1.1
 - notes: 2.3.1
 - notifications: 2.0.0
 - oauth2: 1.0.5
 - ocsms: 1.12.0
 - password_policy: 1.2.2
 - previewgenerator: 1.0.6
 - provisioning_api: 1.2.0
 - qownnotesapi: 17.5.0
 - richdocuments: 1.12.34
 - serverinfo: 1.2.0
 - sharebymail: 1.2.0
 - socialsharing_diaspora: 1.0.1
 - socialsharing_email: 1.0.1
 - socialsharing_facebook: 1.0.1
 - socialsharing_googleplus: 1.0.1
 - socialsharing_twitter: 1.0.1
 - spreed: 2.0.1
 - survey_client: 1.0.0
 - systemtags: 1.2.0
 - theming: 1.3.0
 - twofactor_backupcodes: 1.1.1
 - twofactor_totp: 1.3.1
 - updatenotification: 1.2.0
 - workflowengine: 1.2.0
Disabled apps
 - admin_audit
 - encryption
 - user_external
 - user_ldap
Content of config/config.php
{
    "updatechecker": false,
    "passwordsalt": "***REMOVED SENSITIVE VALUE***",
    "secret": "***REMOVED SENSITIVE VALUE***",
    "trusted_domains": [
        "localhost",
        "192.168.4.111",
        "cloud.techandme.se",
    ],
    "datadirectory": "\/var\/ncdata",
    "overwrite.cli.url": "https:\/\/cloud.techandme.se\/",
    "dbtype": "pgsql",
    "version": "12.0.2.0",
    "dbname": "nextcloud_db",
    "dbhost": "127.0.0.1",
    "dbtableprefix": "oc_",
    "dbuser": "***REMOVED SENSITIVE VALUE***",
    "dbpassword": "***REMOVED SENSITIVE VALUE***",
    "logtimezone": "Europe\/Stockholm",
    "installed": true,
    "instanceid": "oc7aii0tkiol",
    "mail_smtpmode": "smtp",
    "mail_smtpauth": 1,
    "mail_smtpport": "587",
    "mail_smtphost": "mail.citynetwork.se",
    "mail_smtpauthtype": "LOGIN",
    "mail_from_address": "no-reply",
    "mail_domain": "techandme.se",
    "mail_smtpname": "***REMOVED SENSITIVE VALUE***",
    "mail_smtppassword": "***REMOVED SENSITIVE VALUE***",
    "allowZipDownload": true,
    "session_lifetime": 1800,
    "forcessl": true,
    "logfile": "\/var\/log\/nfs-share\/nextcloud.log",
    "loglevel": 2,
    "memcache.local": "\\OC\\Memcache\\Redis",
    "filelocking.enabled": true,
    "memcache.distributed": "\\OC\\Memcache\\Redis",
    "memcache.locking": "\\OC\\Memcache\\Redis",
    "redis": {
        "host": "\/var\/run\/redis\/redis.sock",
        "port": 0,
        "timeout": 0,
        "dbindex": 0
    },
    "trusted_proxies": [
        [
            "192.168.10.201"
        ]
    ],
    "forwarded_for_headers": [
        "HTTP_X_FORWARDED",
        "HTTP_FORWARDED_FOR"
    ],
    "maintenance": false,
    "mail_smtpsecure": "tls",
    "htaccess.RewriteBase": "\/",
    "theme": "",
    "updater.release.channel": "stable",
    "trashbin_retention_obligation": "auto, 30",
    "activity_expire_days": 60
}

Client configuration

Browser: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.111 Safari/537.36

Operating system: Ubuntu 16.04 Server

Logs

Web server error log
Insert your webserver log here
Nextcloud log (data/nextcloud.log)
Doctrine\DBAL\Exception\UniqueConstraintViolationException: An exception occurred while executing 'INSERT INTO "oc_filecache" ("mimepart","mimetype","mtime","size","etag","storage_mtime","permissions","checksum","path_hash","path","parent","name","storage") SELECT ?,?,?,?,?,?,?,?,?,?,?,?,? FROM "oc_filecache" WHERE "storage" = ? AND "path_hash" = ? HAVING COUNT(*) = 0' with params [1, 2, 1502911047, -1, "59949a47cabae", 1502911047, 31, "", "fb66dca5f27af6f15c1d1d81e6f8d28b", "files_trashbin", 1742774, "files_trashbin", 136, 136, "fb66dca5f27af6f15c1d1d81e6f8d28b"]: SQLSTATE[23505]: Unique violation: 7 ERROR: duplicate key value violates unique constraint "fs_storage_path_hash" DETAIL: Key (storage, path_hash)=(136, fb66dca5f27af6f15c1d1d81e6f8d28b) 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 213: 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 251: 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_trashbin', Array)
/var/www/nextcloud/lib/private/Files/Cache/Scanner.php - line 279: OC\Files\Cache\Cache->put('files_trashbin', Array)
/var/www/nextcloud/lib/private/Files/Cache/Scanner.php - line 216: OC\Files\Cache\Scanner->addToCache('files_trashbin', Array, -1)
/var/www/nextcloud/lib/private/Files/Cache/Scanner.php - line 175: OC\Files\Cache\Scanner->scanFile('files_trashbin')
/var/www/nextcloud/lib/private/Files/Cache/Scanner.php - line 322: OC\Files\Cache\Scanner->scanFile('files_trashbin/...', 3, -1, NULL, false)
/var/www/nextcloud/lib/private/Files/Cache/Updater.php - line 124: OC\Files\Cache\Scanner->scan('files_trashbin/...', false, 3, false)
/var/www/nextcloud/lib/private/Files/View.php - line 321: OC\Files\Cache\Updater->update('files_trashbin/...', 1502911047)
/var/www/nextcloud/lib/private/Files/View.php - line 1151: OC\Files\View->writeUpdate(Object(OCA\Files_Trashbin\Storage), 'files_trashbin/...')
/var/www/nextcloud/lib/private/Files/View.php - line 269: OC\Files\View->basicOperation('mkdir', '/files_trashbin...', Array)
/var/www/nextcloud/apps/files_trashbin/lib/Trashbin.php - line 154: OC\Files\View->mkdir('files_trashbin/...')
/var/www/nextcloud/apps/files_trashbin/lib/Trashbin.php - line 225: OCA\Files_Trashbin\Trashbin setUpTrash('klas')
/var/www/nextcloud/apps/files_trashbin/lib/Storage.php - line 247: OCA\Files_Trashbin\Trashbin move2trash('Photos', false)
/var/www/nextcloud/apps/files_trashbin/lib/Storage.php - line 189: OCA\Files_Trashbin\Storage->doDelete('files/Photos', 'rmdir')
/var/www/nextcloud/lib/private/Files/View.php - line 1136: OCA\Files_Trashbin\Storage->rmdir('files/Photos')
/var/www/nextcloud/lib/private/Files/View.php - line 348: OC\Files\View->basicOperation('rmdir', '/Photos', Array)
/var/www/nextcloud/apps/dav/lib/Connector/Sabre/Directory.php - line 303: OC\Files\View->rmdir('/Photos')
/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Tree.php - line 179: OCA\DAV\Connector\Sabre\Directory->delete()
/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/CorePlugin.php - line 287: Sabre\DAV\Tree->delete('Photos')
[internal function] Sabre\DAV\CorePlugin->httpDelete(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 DELETE', 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 71: Sabre\DAV\Server->exec()
/var/www/nextcloud/remote.php - line 162: require_once('/var/www/nextcl...')
{main}
Browser log
Insert your browser log here, this could for example include:

a) The javascript console log
b) The network log
c) ...

enoch85 avatar Aug 17 '17 07:08 enoch85

@icewind1991

enoch85 avatar Aug 17 '17 07:08 enoch85

Related: https://github.com/nextcloud/server/issues/6104

enoch85 avatar Aug 19 '17 12:08 enoch85

Well either it's due to missing file locking or due to invalid database configuration

nickvergessen avatar Sep 06 '17 08:09 nickvergessen

@nickvergessen Well, it's PostgreSQL default from the Ubuntu repo. So if the DB configuration is wrong, the default configuration in Ubuntu is wrong.

That leaves us with missing file locking. How do I check if it's missing or not?

enoch85 avatar Sep 06 '17 08:09 enoch85

https://github.com/nextcloud/server/blob/d26ec44617e5bcda11f5f03a90a35790fc8f6f45/config/config.sample.php#L1458-L1501

nickvergessen avatar Sep 06 '17 09:09 nickvergessen

@nickvergessen Yeah, forgot about that. Obvious.

And yes, it's activated. I use Redis and later + OPcache as it's recommended since NC12.

enoch85 avatar Sep 06 '17 10:09 enoch85

Hi, On my machine occurs to my knowledge the same error. The configuration is the same as written in this issue #6899.

Stacktrace
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 ["3", "14", 1508661498, 0, "e529af4920a84580d90233f21903bd3d", 1508661498, 27, 36, "", "68df112244cdd1a21c0d23e3dd41fabd", "appdata_ocqw4m1v6kk0\/js\/activity\/activity-sidebar.js.deps", "activity-sidebar.js.deps", 1, 1, "68df112244cdd1a21c0d23e3dd41fabd"]: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '1-68df112244cdd1a21c0d23e3dd41fabd' for key 'fs_storage_path_hash'
/var/www/cloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php - line 128: Doctrine\DBAL\Driver\AbstractMySQLDriver->convertException('An exception oc...', Object(Doctrine\DBAL\Driver\PDOException))
/var/www/cloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php - line 1015: Doctrine\DBAL\DBALException driverExceptionDuringQuery(Object(Doctrine\DBAL\Driver\PDOMySql\Driver), Object(Doctrine\DBAL\Driver\PDOException), 'INSERT INTO `oc...', Array)
/var/www/cloud/lib/private/DB/Connection.php - line 213: Doctrine\DBAL\Connection->executeUpdate('INSERT INTO `oc...', Array, Array)
/var/www/cloud/lib/private/DB/Adapter.php - line 114: OC\DB\Connection->executeUpdate('INSERT INTO `oc...', Array)
/var/www/cloud/lib/private/DB/Connection.php - line 251: OC\DB\Adapter->insertIfNotExist('*PREFIX*filecac...', Array, Array)
/var/www/cloud/lib/private/Files/Cache/Cache.php - line 273: OC\DB\Connection->insertIfNotExist('*PREFIX*filecac...', Array, Array)
/var/www/cloud/lib/private/Files/Cache/Cache.php - line 230: OC\Files\Cache\Cache->insert('appdata_ocqw4m1...', Array)
/var/www/cloud/lib/private/Files/Cache/Scanner.php - line 279: OC\Files\Cache\Cache->put('appdata_ocqw4m1...', Array)
/var/www/cloud/lib/private/Files/Cache/Scanner.php - line 216: OC\Files\Cache\Scanner->addToCache('appdata_ocqw4m1...', Array, -1)
/var/www/cloud/lib/private/Files/Cache/Scanner.php - line 322: OC\Files\Cache\Scanner->scanFile('appdata_ocqw4m1...', 3, 36, false, true)
/var/www/cloud/lib/private/Files/View.php - line 1315: OC\Files\Cache\Scanner->scan('appdata_ocqw4m1...', false)
/var/www/cloud/lib/private/Files/View.php - line 1356: OC\Files\View->getCacheEntry(Object(OCA\Files_Trashbin\Storage), 'appdata_ocqw4m1...', '/appdata_ocqw4m...')
/var/www/cloud/lib/private/Files/Node/Root.php - line 196: OC\Files\View->getFileInfo('/appdata_ocqw4m...')
/var/www/cloud/lib/private/Files/Node/Folder.php - line 133: OC\Files\Node\Root->get('/appdata_ocqw4m...')
/var/www/cloud/lib/private/Files/SimpleFS/SimpleFolder.php - line 73: OC\Files\Node\Folder->get('activity-sideba...')
/var/www/cloud/lib/private/Template/JSCombiner.php - line 102: OC\Files\SimpleFS\SimpleFolder->getFile('activity-sideba...')
/var/www/cloud/lib/private/Template/JSCombiner.php - line 86: OC\Template\JSCombiner->isCached('activity-sideba...', Object(OC\Files\SimpleFS\SimpleFolder))
/var/www/cloud/lib/private/Template/JSResourceLocator.php - line 105: OC\Template\JSCombiner->process('/var/www/cloud....', 'js/activity-sid...', 'activity')
/var/www/cloud/lib/private/Template/JSResourceLocator.php - line 92: OC\Template\JSResourceLocator->cacheAndAppendCombineJsonIfExist('/var/www/cloud....', 'js/activity-sid...', 'activity')
/var/www/cloud/lib/private/Template/ResourceLocator.php - line 75: OC\Template\JSResourceLocator->doFind('js/activity-sid...')
/var/www/cloud/lib/private/TemplateLayout.php - line 249: OC\Template\ResourceLocator->find(Array)
/var/www/cloud/lib/private/TemplateLayout.php - line 132: OC\TemplateLayout findJavascriptFiles(Array)
/var/www/cloud/lib/private/legacy/template.php - line 205: OC\TemplateLayout->__construct('user', 'files')
/var/www/cloud/lib/public/AppFramework/Http/TemplateResponse.php - line 157: OC_Template->fetchPage()
/var/www/cloud/lib/private/AppFramework/Http/Dispatcher.php - line 113: OCP\AppFramework\Http\TemplateResponse->render()
/var/www/cloud/lib/private/AppFramework/App.php - line 114: OC\AppFramework\Http\Dispatcher->dispatch(Object(OCA\Files\Controller\ViewController), 'index')
/var/www/cloud/lib/private/AppFramework/Routing/RouteActionHandler.php - line 47: OC\AppFramework\App main('ViewController', 'index', Object(OC\AppFramework\DependencyInjection\DIContainer), Array)
[internal function] OC\AppFramework\Routing\RouteActionHandler->__invoke(Array)
/var/www/cloud/lib/private/Route/Router.php - line 299: call_user_func(Object(OC\AppFramework\Routing\RouteActionHandler), Array)
/var/www/cloud/lib/base.php - line 1004: OC\Route\Router->match('/apps/files/')
/var/www/cloud/index.php - line 48: OC handleRequest()
{main}
data/nextcloud.log
{
    "reqId": "cDtwiSOoiGoO7uZB1l0v",
    "level": 3,
    "time": "2017-10-22T08:38:18+00:00",
    "remoteAddr": "162.158.202.30",
    "user": "maxibanki",
    "app": "index",
    "method": "GET",
    "url": "\/apps\/files\/",
    "message": "Exception: {\"Exception\":\"Doctrine\\\\DBAL\\\\Exception\\\\UniqueConstraintViolationException\",\"Message\":\"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 [\\\"3\\\", \\\"14\\\", 1508661498, 0, \\\"e529af4920a84580d90233f21903bd3d\\\", 1508661498, 27, 36, \\\"\\\", \\\"68df112244cdd1a21c0d23e3dd41fabd\\\", \\\"appdata_ocqw4m1v6kk0\\\\\\\/js\\\\\\\/activity\\\\\\\/activity-sidebar.js.deps\\\", \\\"activity-sidebar.js.deps\\\", 1, 1, \\\"68df112244cdd1a21c0d23e3dd41fabd\\\"]:\\n\\nSQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '1-68df112244cdd1a21c0d23e3dd41fabd' for key 'fs_storage_path_hash'\",\"Code\":0,\"Trace\":\"#0 \\\/var\\\/www\\\/cloud\\\/3rdparty\\\/doctrine\\\/dbal\\\/lib\\\/Doctrine\\\/DBAL\\\/DBALException.php(128): Doctrine\\\\DBAL\\\\Driver\\\\AbstractMySQLDriver->convertException('An exception oc...', Object(Doctrine\\\\DBAL\\\\Driver\\\\PDOException))\\n#1 \\\/var\\\/www\\\/cloud\\\/3rdparty\\\/doctrine\\\/dbal\\\/lib\\\/Doctrine\\\/DBAL\\\/Connection.php(1015): Doctrine\\\\DBAL\\\\DBALException::driverExceptionDuringQuery(Object(Doctrine\\\\DBAL\\\\Driver\\\\PDOMySql\\\\Driver), Object(Doctrine\\\\DBAL\\\\Driver\\\\PDOException), 'INSERT INTO `oc...', Array)\\n#2 \\\/var\\\/www\\\/cloud\\\/lib\\\/private\\\/DB\\\/Connection.php(213): Doctrine\\\\DBAL\\\\Connection->executeUpdate('INSERT INTO `oc...', Array, Array)\\n#3 \\\/var\\\/www\\\/cloud\\\/lib\\\/private\\\/DB\\\/Adapter.php(114): OC\\\\DB\\\\Connection->executeUpdate('INSERT INTO `oc...', Array)\\n#4 \\\/var\\\/www\\\/cloud\\\/lib\\\/private\\\/DB\\\/Connection.php(251): OC\\\\DB\\\\Adapter->insertIfNotExist('*PREFIX*filecac...', Array, Array)\\n#5 \\\/var\\\/www\\\/cloud\\\/lib\\\/private\\\/Files\\\/Cache\\\/Cache.php(273): OC\\\\DB\\\\Connection->insertIfNotExist('*PREFIX*filecac...', Array, Array)\\n#6 \\\/var\\\/www\\\/cloud\\\/lib\\\/private\\\/Files\\\/Cache\\\/Cache.php(230): OC\\\\Files\\\\Cache\\\\Cache->insert('appdata_ocqw4m1...', Array)\\n#7 \\\/var\\\/www\\\/cloud\\\/lib\\\/private\\\/Files\\\/Cache\\\/Scanner.php(279): OC\\\\Files\\\\Cache\\\\Cache->put('appdata_ocqw4m1...', Array)\\n#8 \\\/var\\\/www\\\/cloud\\\/lib\\\/private\\\/Files\\\/Cache\\\/Scanner.php(216): OC\\\\Files\\\\Cache\\\\Scanner->addToCache('appdata_ocqw4m1...', Array, -1)\\n#9 \\\/var\\\/www\\\/cloud\\\/lib\\\/private\\\/Files\\\/Cache\\\/Scanner.php(322): OC\\\\Files\\\\Cache\\\\Scanner->scanFile('appdata_ocqw4m1...', 3, 36, false, true)\\n#10 \\\/var\\\/www\\\/cloud\\\/lib\\\/private\\\/Files\\\/View.php(1315): OC\\\\Files\\\\Cache\\\\Scanner->scan('appdata_ocqw4m1...', false)\\n#11 \\\/var\\\/www\\\/cloud\\\/lib\\\/private\\\/Files\\\/View.php(1356): OC\\\\Files\\\\View->getCacheEntry(Object(OCA\\\\Files_Trashbin\\\\Storage), 'appdata_ocqw4m1...', '\\\/appdata_ocqw4m...')\\n#12 \\\/var\\\/www\\\/cloud\\\/lib\\\/private\\\/Files\\\/Node\\\/Root.php(196): OC\\\\Files\\\\View->getFileInfo('\\\/appdata_ocqw4m...')\\n#13 \\\/var\\\/www\\\/cloud\\\/lib\\\/private\\\/Files\\\/Node\\\/Folder.php(133): OC\\\\Files\\\\Node\\\\Root->get('\\\/appdata_ocqw4m...')\\n#14 \\\/var\\\/www\\\/cloud\\\/lib\\\/private\\\/Files\\\/SimpleFS\\\/SimpleFolder.php(73): OC\\\\Files\\\\Node\\\\Folder->get('activity-sideba...')\\n#15 \\\/var\\\/www\\\/cloud\\\/lib\\\/private\\\/Template\\\/JSCombiner.php(102): OC\\\\Files\\\\SimpleFS\\\\SimpleFolder->getFile('activity-sideba...')\\n#16 \\\/var\\\/www\\\/cloud\\\/lib\\\/private\\\/Template\\\/JSCombiner.php(86): OC\\\\Template\\\\JSCombiner->isCached('activity-sideba...', Object(OC\\\\Files\\\\SimpleFS\\\\SimpleFolder))\\n#17 \\\/var\\\/www\\\/cloud\\\/lib\\\/private\\\/Template\\\/JSResourceLocator.php(105): OC\\\\Template\\\\JSCombiner->process('\\\/var\\\/www\\\/cloud....', 'js\\\/activity-sid...', 'activity')\\n#18 \\\/var\\\/www\\\/cloud\\\/lib\\\/private\\\/Template\\\/JSResourceLocator.php(92): OC\\\\Template\\\\JSResourceLocator->cacheAndAppendCombineJsonIfExist('\\\/var\\\/www\\\/cloud....', 'js\\\/activity-sid...', 'activity')\\n#19 \\\/var\\\/www\\\/cloud\\\/lib\\\/private\\\/Template\\\/ResourceLocator.php(75): OC\\\\Template\\\\JSResourceLocator->doFind('js\\\/activity-sid...')\\n#20 \\\/var\\\/www\\\/cloud\\\/lib\\\/private\\\/TemplateLayout.php(249): OC\\\\Template\\\\ResourceLocator->find(Array)\\n#21 \\\/var\\\/www\\\/cloud\\\/lib\\\/private\\\/TemplateLayout.php(132): OC\\\\TemplateLayout::findJavascriptFiles(Array)\\n#22 \\\/var\\\/www\\\/cloud\\\/lib\\\/private\\\/legacy\\\/template.php(205): OC\\\\TemplateLayout->__construct('user', 'files')\\n#23 \\\/var\\\/www\\\/cloud\\\/lib\\\/public\\\/AppFramework\\\/Http\\\/TemplateResponse.php(157): OC_Template->fetchPage()\\n#24 \\\/var\\\/www\\\/cloud\\\/lib\\\/private\\\/AppFramework\\\/Http\\\/Dispatcher.php(113): OCP\\\\AppFramework\\\\Http\\\\TemplateResponse->render()\\n#25 \\\/var\\\/www\\\/cloud\\\/lib\\\/private\\\/AppFramework\\\/App.php(114): OC\\\\AppFramework\\\\Http\\\\Dispatcher->dispatch(Object(OCA\\\\Files\\\\Controller\\\\ViewController), 'index')\\n#26 \\\/var\\\/www\\\/cloud\\\/lib\\\/private\\\/AppFramework\\\/Routing\\\/RouteActionHandler.php(47): OC\\\\AppFramework\\\\App::main('ViewController', 'index', Object(OC\\\\AppFramework\\\\DependencyInjection\\\\DIContainer), Array)\\n#27 [internal function]: OC\\\\AppFramework\\\\Routing\\\\RouteActionHandler->__invoke(Array)\\n#28 \\\/var\\\/www\\\/cloud\\\/lib\\\/private\\\/Route\\\/Router.php(299): call_user_func(Object(OC\\\\AppFramework\\\\Routing\\\\RouteActionHandler), Array)\\n#29 \\\/var\\\/www\\\/cloud\\\/lib\\\/base.php(1004): OC\\\\Route\\\\Router->match('\\\/apps\\\/files\\\/')\\n#30 \\\/var\\\/www\\\/cloud\\\/index.php(48): OC::handleRequest()\\n#31 {main}\",\"File\":\"\\\/var\\\/www\\\/cloud\\\/3rdparty\\\/doctrine\\\/dbal\\\/lib\\\/Doctrine\\\/DBAL\\\/Driver\\\/AbstractMySQLDriver.php\",\"Line\":66}",
    "userAgent": "Mozilla\/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/61.0.3163.100 Safari\/537.36",
    "version": "12.0.3.3"
}

mxschmitt avatar Oct 22 '17 10:10 mxschmitt

I have same error on v12.0.4. OS: Debian 8; Nginx; PHP-5

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_filecacheWHEREstorage= ? ANDpath_hash = ? HAVING COUNT(*) = 0' with params ["13", "19", 1512770508, 0, "db14564d3b3939b0c495a228f13895de", 1512770508, 27, 16635, "", "619aa6621db88cefca5fe60b402d212c", "appdata_ocboc03zyp7e\/css\/core\/25c6ce980724e37af3fe774551b7943c-server.css", "25c6ce980724e37af3fe774551b7943c-server.css", 27, 27, "619aa6621db88cefca5fe60b402d212c"]: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '27-619aa6621db88cefca5fe60b402d212c' for key 'fs_storage_path_hash'

techc0de avatar Dec 09 '17 01:12 techc0de

I realized the same error on v12.0.4. Linux v,3.16.50, Apache2 2.4.29, PHP 5.6.29, MariaDB 10.0.32:

Doctrine\DBAL\Exception\UniqueConstraintViolationException: An exception occurred while executing
'INSERT INTO `nc_filecache`  (`mimepart`,`mimetype`,`mtime`,`size`,`etag`,`storage_mtime`,
`permissions`,`parent`,`checksum`,`path_hash`,`path`,`name`,`storage`) SELECT ?,?,?,?,?,?,?,?,?,?,?,?,?
FROM `nc_filecache` WHERE `storage` = ? AND `path_hash` = ? HAVING COUNT(*) = 0' with params
["5", "9", 1512925591, 876, "31f801d5edcb5be1ffeeee34fea9356c", 1512925591, 27, 98, "",
"24deee6a704e6e31156a1faa70a9a970", "appdata_oc3rij6gro8a\/css\/core\/3e49acc621a9e6ce81524892062bbf7f-server.css.deps", "3e49acc621a9e6ce81524
892062bbf7f-server.css.deps", 2, 2, "24deee6a704e6e31156a1faa70a9a970"]: SQLSTATE[23000]:
Integrity constraint violation: 1062 Doppelter Eintrag '2-24deee6a704e6e31156a1faa70a9a970'
für Schlüssel 'fs_storage_path_hash'

j-ed avatar Dec 10 '17 18:12 j-ed

Hi,

I have the very same issue on Nextcloud v12.0.4. For me it happens after DELETE statements in heavy-load situations (e.g. multiple clients accessing/deleting the same file). Apache log of the relevant file:

10.1.2.3 - user0815 [11/Dec/2017:10:52:59 +0100] "PUT /remote.php/dav/files/user0815/data/filename.o HTTP/1.1" 201 - "-" "Mozilla/5.0 (Macintosh) mirall/2.3.2 (build 1) (Nextcloud)" 1
10.1.2.3 - user0815 [11/Dec/2017:10:53:20 +0100] "DELETE /remote.php/dav/files/user0815/data/filename.o HTTP/1.1" 500 756 "-" "Mozilla/5.0 (Macintosh) mirall/2.3.2 (build 1) (Nextcloud)" 0

And this is the anonymized output of the relevant Nextcloud log:

[INFO] -- 2017-12-11 10:53:20+01:00 --
[INFO] DELETE /remote.php/dav/files/user0815/data/filename.o
[INFO] User: 'user0815'@'10.1.2.3'
[INFO] File deleted: "/data/filename.o"

[some more DELETE requests on other files]

[FATAL] -- 2017-12-11 10:53:20+01:00 --
[FATAL] DELETE /remote.php/dav/files/user0815/data/filename.o
[FATAL] User: 'user0815'@'10.1.2.3'
[FATAL] Exception: An exception occurred while executing 'UPDATE "oc_filecache" SET "storage" = ?, "path" = ?, "path_hash" = ?, "name" = ?, "parent" = ? WHERE "fileid" = ?' with params [88, "files_trashbin\/files\/filename.o.d1512986000", "0bb76c0cb1188da59208c21c6096652f", "filename.o.d1512986000", 236307, 2040671]:

SQLSTATE[23505]: Unique violation: 7 FEHLER:  doppelter Schlüsselwert verletzt Unique-Constraint »fs_storage_path_hash«
DETAIL:  Schlüssel »(storage, path_hash)=(88, 0bb76c0cb1188da59208c21c6096652f)« existiert bereits.
[FATAL] Trace:
 #0 /var/www/html/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php(128): Doctrine\DBAL\Driver\AbstractPostgreSQLDriver->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\PDOPgSql\Driver), Object(Doctrine\DBAL\Driver\PDOException), 'UPDATE "oc_file...', Array)
#2 /var/www/html/nextcloud/lib/private/DB/Connection.php(192): Doctrine\DBAL\Connection->executeQuery('UPDATE "oc_file...', Array, Array, NULL)
#3 /var/www/html/nextcloud/lib/private/Files/Cache/Cache.php(553): OC\DB\Connection->executeQuery('UPDATE "oc_file...', Array)
#4 /var/www/html/nextcloud/lib/private/Files/Cache/Cache.php(484): OC\Files\Cache\Cache->moveFromCache(Object(OC\Files\Cache\HomeCache), 'files/data...', 'files_trashbin/...')
#5 /var/www/html/nextcloud/lib/private/Files/Cache/Updater.php(196): OC\Files\Cache\Cache->move('files/data...', 'files_trashbin/...')
#6 /var/www/html/nextcloud/apps/files_trashbin/lib/Trashbin.php(269): OC\Files\Cache\Updater->renameFromStorage(Object(OCA\Files_Trashbin\Storage), 'files/data...', 'files_trashbin/...')
#7 /var/www/html/nextcloud/apps/files_trashbin/lib/Storage.php(247): OCA\Files_Trashbin\Trashbin::move2trash('data...', false)
#8 /var/www/html/nextcloud/apps/files_trashbin/lib/Storage.php(163): OCA\Files_Trashbin\Storage->doDelete('data...', 'unlink')
#9 /var/www/html/nextcloud/lib/private/Files/View.php(1136): OCA\Files_Trashbin\Storage->unlink('data...')
#10 /var/www/html/nextcloud/lib/private/Files/View.php(701): OC\Files\View->basicOperation('unlink', 'data...', Array)
#11 /var/www/html/nextcloud/apps/dav/lib/Connector/Sabre/File.php(344): OC\Files\View->unlink('data...')
#12 /var/www/html/nextcloud/3rdparty/sabre/dav/lib/DAV/Tree.php(179): OCA\DAV\Connector\Sabre\File->delete()
#13 /var/www/html/nextcloud/3rdparty/sabre/dav/lib/DAV/CorePlugin.php(287): Sabre\DAV\Tree->delete('files/user0815...')
#14 [internal function]: Sabre\DAV\CorePlugin->httpDelete(Object(Sabre\HTTP\Request), Object(Sabre\HTTP\Response))
#15 /var/www/html/nextcloud/3rdparty/sabre/event/lib/EventEmitterTrait.php(105): call_user_func_array(Array, Array)
#16 /var/www/html/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php(479): Sabre\Event\EventEmitter->emit('method:DELETE', Array)
#17 /var/www/html/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php(254): Sabre\DAV\Server->invokeMethod(Object(Sabre\HTTP\Request), Object(Sabre\HTTP\Response))
#18 /var/www/html/nextcloud/apps/dav/lib/Server.php(258): Sabre\DAV\Server->exec()
#19 /var/www/html/nextcloud/apps/dav/appinfo/v2/remote.php(33): OCA\DAV\Server->exec()
#20 /var/www/html/nextcloud/remote.php(162): require_once('/var/www/html/n...')
#21 {main}

It looks like the file filename.o had been deleted correctly and on the second DELETE the exception is thrown.

  • NC 12.0.4
  • Postgres 9.2.23
  • RHEL 7.4
  • 'memcache.locking' => '\OC\Memcache\Redis'
  • 'filelocking.enabled' => true,

klada avatar Dec 11 '17 11:12 klada

@nickvergessen Any update here? Been seeing this a lot lately on a system with around 100 users.

enoch85 avatar Feb 07 '18 16:02 enoch85

Not from me, I never managed to create such conflicts. especially since file locking was added.

nickvergessen avatar Feb 09 '18 08:02 nickvergessen

Same issue here on ubuntu 16.04, php 7.0.25, mysql 5.7.21, filelocking enabled with redis-server 3.0.6-1

tsueri avatar Feb 12 '18 11:02 tsueri

Same issue after upgrade to 13.0 using docker installation like this: https://github.com/nextcloud/docker/tree/master/.examples/docker-compose/with-nginx-proxy/mariadb-cron-redis/apache

Steps to reproduce:

  • Log in after having uploaded many images
  • switch to Activity tab
  • many previews will be generated
  • switch to gallery tab while preview generation isn't finished
  • Wait until nextcloud crashes because of an "internal server error"
  • see log for mentioned error message

protree avatar Feb 12 '18 14:02 protree

@protree Do note though, that the Original Poster has a postgres Database, where as you have a MariaDB.

Also note that the default configuration of the docker installation you have referenced has MariaDB with a 'READ-REPEATABLE' Transaction Isolation Level, but Nextcloud requires 'READ-COMMITTED'. According to many issues around here, this can be the cause of Deadlocks. I have pushed a PR that sets this by default, but until that is merged, you have to set the TIL manually.

Greek64 avatar Feb 12 '18 17:02 Greek64

@Greek64 @protree Since this also effects Postgres where "read committed" is the default transaction isolation level I don't think that this bug can be solved by changing the MySQL transaction level. It is correct though that people should always be using "READ-COMMITTED" with Nextcloud on MySQL.

klada avatar Feb 12 '18 20:02 klada

@Greek64 Thank you, I will change my configuration and have a look at my logs.

protree avatar Feb 13 '18 11:02 protree

It seams like those two configuration edits fix the issue also for me.

[mysqld]
transaction-isolation = READ-COMMITTED
'memcache.locking' => '\\OC\\Memcache\\Redis'

MartinBrugnara avatar Mar 15 '18 14:03 MartinBrugnara

Still having this issue. Webdav fatal changed to no app in context error after transaction-isolation = READ-COMMITTED setting.

Memcache locking is the same like above.

Newest (highest versions) Nextcloud, Mariadb and PHP. Nginx is few weeks old.

Errors came while uploading whole camera roll from iphone. Over 2000 pics/vids.

MeiRos avatar Apr 21 '18 21:04 MeiRos

I can confirm this error with Ubuntu 18.04, Nextcloud 14.0.0, redis 4.0.9 and opcache enabled like in the documentation described... It is appearing when syncing a large number of files. Big files or a small number of files are not a problem...

SchoolGuy avatar Sep 12 '18 12:09 SchoolGuy