NextCloud v13 - oc_share table issue

Support intro

Sorry to hear you’re facing problems :slightly_frowning_face:

help.nextcloud.com is for home/non-enterprise users. If you’re running a business, paid support can be accessed via portal.nextcloud.com where we can ensure your business keeps running smoothly.

In order to help you as quickly as possible, before clicking Create Topic please provide as much of the below as you can. Feel free to use a pastebin service for logs, otherwise either indent short log examples with four spaces:

example

Or for longer, use three backticks above and below the code snippet:

longer
example
here

Some or all of the below information will be requested if it isn’t supplied; for fastest response please provide as much as you can :heart:

Nextcloud version 13.0.0.0:
Operating system and version RedHat 7:
Apache or nginx version nginx 1.10:
PHP version 7.3:

The issue you are facing:

Yesterday morning tried to share a file but had a spinning icon forever. Checking the logs showed the following errors:

Doctrine\DBAL\Exception\DriverException: An exception occurred while executing 'INSERT INTO `oc_file_locks` (`key`,`lock`,`ttl`) SELECT ?,?,? FROM `oc_file_locks` WHERE `key` = ? HAVING COUNT(*) = 0' with params ["files\/82a3ad67f40a206e7f0158453e70f5c6", 1, 1609976861, "files\/82a3ad67f40a206e7f0158453e70f5c6"]: SQLSTATE[HY000]: General error: 1206 The total number of locks exceeds the lock table size

/opt/nextcloud/www/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php - line 128: Doctrine\DBAL\Driver\AbstractMySQLDriver->convertException('An exception oc...', Object(Doctrine\DBAL\Driver\PDOException))
/opt/nextcloud/www/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)
/opt/nextcloud/www/lib/private/DB/Connection.php - line 216: Doctrine\DBAL\Connection->executeUpdate('INSERT INTO `oc...', Array, Array)
/opt/nextcloud/www/lib/private/DB/Adapter.php - line 114: OC\DB\Connection->executeUpdate('INSERT INTO `oc...', Array)
/opt/nextcloud/www/lib/private/DB/Connection.php - line 254: OC\DB\Adapter->insertIfNotExist('*PREFIX*file_lo...', Array, Array)
/opt/nextcloud/www/lib/private/Lock/DBLockingProvider.php - line 119: OC\DB\Connection->insertIfNotExist('*PREFIX*file_lo...', Array, Array)
/opt/nextcloud/www/lib/private/Lock/DBLockingProvider.php - line 164: OC\Lock\DBLockingProvider->initLockField('files/82a3ad67f...', 1)
/opt/nextcloud/www/lib/private/Files/Storage/Common.php - line 709: OC\Lock\DBLockingProvider->acquireLock('files/82a3ad67f...', 1)
/opt/nextcloud/www/lib/private/Files/Storage/Wrapper/Wrapper.php - line 592: OC\Files\Storage\Common->acquireLock('files/arcive/Pr...', 1, Object(OC\Lock\DBLockingProvider))
/opt/nextcloud/www/lib/private/Files/Storage/Wrapper/Wrapper.php - line 592: OC\Files\Storage\Wrapper\Wrapper->acquireLock('files/arcive/Pr...', 1, Object(OC\Lock\DBLockingProvider))
/opt/nextcloud/www/lib/private/Files/Storage/Wrapper/Wrapper.php - line 592: OC\Files\Storage\Wrapper\Wrapper->acquireLock('files/arcive/Pr...', 1, Object(OC\Lock\DBLockingProvider))
/opt/nextcloud/www/apps/files_sharing/lib/SharedStorage.php - line 405: OC\Files\Storage\Wrapper\Wrapper->acquireLock('files/arcive/Pr...', 1, Object(OC\Lock\DBLockingProvider))
/opt/nextcloud/www/lib/private/Files/Storage/Wrapper/Wrapper.php - line 592: OCA\Files_Sharing\SharedStorage->acquireLock('Projects/PG1039...', 1, Object(OC\Lock\DBLockingProvider))
/opt/nextcloud/www/lib/private/Files/View.php - line 1926: OC\Files\Storage\Wrapper\Wrapper->acquireLock('Projects/PG1039...', 1, Object(OC\Lock\DBLockingProvider))
/opt/nextcloud/www/lib/private/Files/View.php - line 2036: OC\Files\View->lockPath('/amanda.johnsto...', 1, false)
/opt/nextcloud/www/lib/private/Files/Node/Node.php - line 360: OC\Files\View->lockFile('/amanda.johnsto...', 1)
/opt/nextcloud/www/apps/files_sharing/lib/Controller/ShareAPIController.php - line 936: OC\Files\Node\Node->lock(1)
/opt/nextcloud/www/apps/files_sharing/lib/Controller/ShareAPIController.php - line 596: OCA\Files_Sharing\Controller\ShareAPIController->lock(Object(OC\Files\Node\Folder))
[internal function] OCA\Files_Sharing\Controller\ShareAPIController->getShares('true', 'false', 'false', Object(OC\Files\Node\Folder), 'false')
/opt/nextcloud/www/lib/private/AppFramework/Http/Dispatcher.php - line 161: call_user_func_array(Array, Array)
/opt/nextcloud/www/lib/private/AppFramework/Http/Dispatcher.php - line 91: OC\AppFramework\Http\Dispatcher->executeController(Object(OCA\Files_Sharing\Controller\ShareAPIController), 'getShares')
/opt/nextcloud/www/lib/private/AppFramework/App.php - line 115: OC\AppFramework\Http\Dispatcher->dispatch(Object(OCA\Files_Sharing\Controller\ShareAPIController), 'getShares')
/opt/nextcloud/www/lib/private/AppFramework/Routing/RouteActionHandler.php - line 47: OC\AppFramework\App main('OCA\\Files_Shari...', 'getShares', Object(OC\AppFramework\DependencyInjection\DIContainer), Array)
[internal function] OC\AppFramework\Routing\RouteActionHandler->__invoke(Array)
/opt/nextcloud/www/lib/private/Route/Router.php - line 297: call_user_func(Object(OC\AppFramework\Routing\RouteActionHandler), Array)
/opt/nextcloud/www/ocs/v1.php - line 78: OC\Route\Router->match('/ocsapp/apps/fi...')
/opt/nextcloud/www/ocs/v2.php - line 24: require_once('/opt/nextcloud/...')
{main}
Doctrine\DBAL\Exception\DriverException: An exception occurred while executing 'UPDATE `oc_filecache` SET `size` = `size` + ? WHERE (`storage` = ?) AND (`path_hash` IN ('d41d8cd98f00b204e9800998ecf8427e', '45b963397aa40d4a0063e0d85e4fe7a1', 'fb26a8a3e656c11acd30b93680278314', '53c57ec54f72f860ea8dfb662829f79a', 'ae31e2f01a01e3c9c73ab1847870cb81', '3ea20b0fe91486b4028e2d57bbf1d063', '7a7e1458c77daeb02624b4b680261280', 'c5e41139d88e2185bca8decb94859301')) AND (`size` > '-1')' with params [104239, 677]: SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction
/opt/nextcloud/www/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php - line 128: Doctrine\DBAL\Driver\AbstractMySQLDriver->convertException('An exception oc...', Object(Doctrine\DBAL\Driver\PDOException))
/opt/nextcloud/www/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), 'UPDATE `oc_file...', Array)
/opt/nextcloud/www/lib/private/DB/Connection.php - line 216: Doctrine\DBAL\Connection->executeUpdate('UPDATE `oc_file...', Array, Array)
/opt/nextcloud/www/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Query/QueryBuilder.php - line 208: OC\DB\Connection->executeUpdate('UPDATE `oc_file...', Array, Array)
/opt/nextcloud/www/lib/private/DB/QueryBuilder/QueryBuilder.php - line 214: Doctrine\DBAL\Query\QueryBuilder->execute()
/opt/nextcloud/www/lib/private/Files/Cache/Propagator.php - line 102: OC\DB\QueryBuilder\QueryBuilder->execute()
/opt/nextcloud/www/lib/private/Files/Cache/HomePropagator.php - line 49: OC\Files\Cache\Propagator->propagateChange('files/ETL/04 La...', 1609975223, 104239)
/opt/nextcloud/www/lib/private/Files/Cache/Updater.php - line 138: OC\Files\Cache\HomePropagator->propagateChange('files/ETL/04 La...', 1609975223, 104239)
/opt/nextcloud/www/apps/dav/lib/Connector/Sabre/File.php - line 226: OC\Files\Cache\Updater->update('files/ETL/04 La...')
/opt/nextcloud/www/apps/dav/lib/Connector/Sabre/Directory.php - line 151: OCA\DAV\Connector\Sabre\File->put(Resource id #8)
/opt/nextcloud/www/3rdparty/sabre/dav/lib/DAV/Server.php - line 1096: OCA\DAV\Connector\Sabre\Directory->createFile('P M Howley CV 1...', Resource id #8)
/opt/nextcloud/www/3rdparty/sabre/dav/lib/DAV/CorePlugin.php - line 525: Sabre\DAV\Server->createFile('files/gary.hein...', Resource id #8, NULL)
[internal function] Sabre\DAV\CorePlugin->httpPut(Object(Sabre\HTTP\Request), Object(Sabre\HTTP\Response))
/opt/nextcloud/www/3rdparty/sabre/event/lib/EventEmitterTrait.php - line 105: call_user_func_array(Array, Array)
/opt/nextcloud/www/3rdparty/sabre/dav/lib/DAV/Server.php - line 479: Sabre\Event\EventEmitter->emit('method PUT', Array)
/opt/nextcloud/www/3rdparty/sabre/dav/lib/DAV/Server.php - line 254: Sabre\DAV\Server->invokeMethod(Object(Sabre\HTTP\Request), Object(Sabre\HTTP\Response))
/opt/nextcloud/www/apps/dav/lib/Server.php - line 283: Sabre\DAV\Server->exec()
/opt/nextcloud/www/apps/dav/appinfo/v2/remote.php - line 35: OCA\DAV\Server->exec()
/opt/nextcloud/www/remote.php - line 164: require_once('/opt/nextcloud/...')
{main}

Looked at the size of the oc_filecache table and it was 4TB+. Decided to attempt a full file scan via occ to rebuild this table but prior to that ran the following commands:

maintenance:repair
files:cleanup

The repair found no issues and files:cleanup found 0 orphaned files.

While the file scan was running I found any files shared with me via direct sharing or groups were not visible.

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

Steps to replicate it:

  1. Unknown. Suspect we’ve hit a limit on the oc_file_locks table that has caused a cascade of other issues.

The output of your Nextcloud log in Admin > Logging:

PASTE HERE

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

<?php
$CONFIG = array (
  'instanceid' => 'ocrrtnimt5jc',
  'passwordsalt' => '<removed>',
  'secret' => '<removed>',
  'trusted_domains' =>
  array (
    0 => '<removed>',
  ),
  'datadirectory' => '/opt/nextcloud/data',
  'overwrite.cli.url' => '<removed>',
  'skeletondirectory' => '/opt/nextcloud/skeleton',
  'dbtype' => 'mysql',
  'version' => '13.0.0.14',
  'dbname' => 'NEXTCLOUD',
  'dbhost' => <removed>,
  'dbport' => '3306',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'nextcloud_user',
  'dbpassword' => <removed>,
  'installed' => true,
  'has_internet_connection' => false,
  'appstoreenabled' => false,
  'mail_from_address' => 'Nextcloud',
  'mail_smtpmode' => 'php',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_domain' => '<removed>',
  'loglevel' => 2,
  'memcache.local' => '\\OC\\Memcache\\APCu',

);

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

2021/01/08 01:01:01 [error] 14363#0: *26349023 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 127.0.0.1, server: rds.unisa.edu.au, request: "GET /cron.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9001", host: "localhost"
2021/01/08 08:01:30 [error] 14364#0: *26439182 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 130.220.1.250, server: rds.unisa.edu.au, request: "PUT /remote.php/dav/files/ahsan.waqas@mymail.unisa.edu.au/WAQAS,%20Ahsan/PhD/1_Documents/2_My_Documents/5_Factor_Graph/figures/Rx_Constant_freq_FFG.PNG HTTP/1.1", upstream: "fastcgi://127.0.0.1:9001", host: "rds.unisa.edu.au"
2021/01/08 08:31:01 [error] 14364#0: *26445289 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 127.0.0.1, server: rds.unisa.edu.au, request: "GET /cron.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9001", host: "localhost"
2021/01/08 09:07:26 [error] 14364#0: *26453368 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 130.220.1.250, server: rds.unisa.edu.au, request: "PUT /remote.php/dav/files/natalie.prow@unisa.edu.au/ETL/01%20Ordering/Copy%20of%20CRI%202018%20Chemical%20Store%20Requisition%20(008).xlsx HTTP/1.1", upstream: "fastcgi://127.0.0.1:9001", host: "rds.unisa.edu.au"
2021/01/08 09:10:06 [error] 14363#0: *26455053 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 130.220.1.250, server: rds.unisa.edu.au, request: "PUT /remote.php/dav/files/natalie.prow@unisa.edu.au/ETL/01%20Ordering/purchase%20order%20requests/CLOSED%20COST%20CODES/PG100926%20ACTIVE%201/200311%20Intergrated%20Sciences%20NP-JZ.xlsx HTTP/1.1", upstream: "fastcgi://127.0.0.1:9001", host: "rds.unisa.edu.au"
2021/01/08 09:12:44 [error] 14363#0: *26456983 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 130.220.1.250, server: rds.unisa.edu.au, request: "PUT /remote.php/dav/files/natalie.prow@unisa.edu.au/ETL/04%20Lab%20information/ETL%20Records/New%20student%20and%20staff%20paperwork/ETL%20Staff%20and%20Student%20records/Students%20records/Students/Active%20pHD%20students/Jorel%20COLET/2020%20Jorel%20COLET%20ETL%20induction%20checklist.pdf HTTP/1.1", upstream: "fastcgi://127.0.0.1:9001", host: "rds.unisa.edu.au"
2021/01/08 09:15:23 [error] 14363#0: *26458752 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 130.220.1.250, server: rds.unisa.edu.au, request: "PUT /remote.php/dav/files/natalie.prow@unisa.edu.au/SEMENTIS/Janssen/Project%201%20SCV8001/Mouse%20dose%20finding%20exp/Preclin%20data_exp%20I_20aug19.pptx HTTP/1.1", upstream: "fastcgi://127.0.0.1:9001", host: "rds.unisa.edu.au"
2021/01/08 09:37:06 [error] 14364#0: *26463402 connect() failed (111: Connection refused) while connecting to upstream, client: 130.220.1.250, server: rds.unisa.edu.au, request: "PROPFIND /remote.php/dav/files/liang.liu@unisa.edu.au/ HTTP/1.1", upstream: "fastcgi://127.0.0.1:9001", host: "rds.unisa.edu.au"
2021/01/08 10:11:50 [error] 5234#0: *417 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 130.220.1.250, server: rds.unisa.edu.au, request: "GET /apps/files/ HTTP/1.1", upstream: "fastcgi://127.0.0.1:9001", host: "rds.unisa.edu.au"
2021/01/08 10:13:47 [error] 5234#0: *795 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 130.220.1.250, server: rds.unisa.edu.au, request: "PUT /remote.php/dav/files/dario.arrua@unisa.edu.au/separationsciencegroup/ARC_Linkage_Project_LP180101285/Amin%20Khodabandeh/15-EndNote%202020/Postdoc2020.Data/PDF/1148605122/acsami.8b06560.pdf HTTP/1.1", upstream: "fastcgi://127.0.0.1:9001", host: "rds.unisa.edu.au"
2021/01/08 10:15:22 [error] 5234#0: *646 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 130.220.1.250, server: rds.unisa.edu.au, request: "PUT /remote.php/dav/files/dario.arrua@unisa.edu.au/separationsciencegroup/ARC_Linkage_Project_LP180101285/Amin%20Khodabandeh/15-EndNote%202020/Postdoc2020.Data/PDF/1188461145/2012%20-%20Chem%20Comm%20-%20Encapsulation%20of%20proteins%20i.pdf HTTP/1.1", upstream: "fastcgi://127.0.0.1:9001", host: "rds.unisa.edu.au"
2021/01/08 10:33:39 [error] 5235#0: *6750 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 130.220.1.250, server: rds.unisa.edu.au, request: "GET /core/preview.png?file=%2Ffolders.txt&c=b75e4a355734496baf729b148d1da003&x=32&y=32&forceIcon=0 HTTP/1.1", upstream: "fastcgi://127.0.0.1:9001", host: "rds.unisa.edu.au"
2021/01/08 10:45:59 [error] 5234#0: *9026 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 130.220.1.250, server: rds.unisa.edu.au, request: "GET /core/preview.png?file=%2Ffolders.txt&c=b75e4a355734496baf729b148d1da003&x=32&y=32&forceIcon=0 HTTP/1.1", upstream: "fastcgi://127.0.0.1:9001", host: "rds.unisa.edu.au"
2021/01/08 10:51:33 [error] 5235#0: *11560 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 130.220.1.250, server: rds.unisa.edu.au, request: "GET /cron.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9001", host: "rds.unisa.edu.au"

Should also mention that while groups and group shares are present in oc_groups, oc_group_user, no group shares are visible on the home screen and adding/removing groups updates the databases but has no affect.

Nextcloud 13 has already been declard “End of life” in *February 2019, so that you won’t get any support on it anymore. The latest supported Nextcloud major version is v20. So you’re at least 7 major versions behind with your installation.

Please update your system asap!!

2 Likes