Skip to content

[Bug]: SQL Deadlock when Updating mtime and size #31993

@simonspa

Description

@simonspa

⚠️ This issue respects the following points: ⚠️

  • This is a bug, not a question or a configuration/webserver/proxy issue.
  • This issue is not already reported on Github (I've searched it).
  • Nextcloud Server is up to date. See Maintenance and Release Schedule for supported versions.
  • I agree to follow Nextcloud's Code of Conduct.

Bug description

In my error logs I have come across a deadlock situation in case a file is uploaded, the file size is updated in the file cache and the mtime also needs updating. Please find the details below.

Steps to reproduce

I'm not entirely sure which precondition generates this issue, it appears sporadically for files uploaded via the NC desktop client.

Expected behavior

No deadlock, upload as expected.

Installation method

Manual installation

Operating system

Debian/Ubuntu

PHP engine version

PHP 8.0

Web server

Nginx

Database engine version

MariaDB

Is this bug present after an update or on a fresh install?

No response

Are you using the Nextcloud Server Encryption module?

Encryption is Disabled

What user-backends are you using?

  • Default user-backend (database)
  • LDAP/ Active Directory
  • SSO - SAML
  • Other

Configuration report

No response

List of activated Apps

Not relevant here :)

Nextcloud Signing status

No response

Nextcloud Logs

{"reqId":"3bhVYlg1IhtSTmOtXvGY","level":4,"time":"2022-04-10T00:00:20+02:00","remoteAddr":"2.200.199.176","user":"user","app":"webdav","method":"PUT","url":"/remote.php/dav/files/user/some/filder/2/20220410-000001-305/backup/home/user/some/stuff/file.dat","message":"An exception occurred while executing a query: SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction","userAgent":"Mozilla/5.0 (Linux) mirall/3.4.4-20220318.152610.a3ece50dd-1.0~focal1 (Nextcloud, ubuntu-5.4.0-107-generic ClientArchitecture: x86_64 OsArchitecture: x86_64)","version":"23.0.3.2","exception":{"Exception":"Doctrine\\DBAL\\Exception\\DeadlockException","Message":"An exception occurred while executing a query: SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction","Code":1213,"Trace":[{"file":"/var/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php","line":1780,"function":"convert","class":"Doctrine\\DBAL\\Driver\\API\\MySQL\\ExceptionConverter","type":"->","args":[{"__class__":"Doctrine\\DBAL\\Driver\\PDO\\Exception"},{"__class__":"Doctrine\\DBAL\\Query"}]},{"file":"/var/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php","line":1719,"function":"handleDriverException","class":"Doctrine\\DBAL\\Connection","type":"->","args":[{"__class__":"Doctrine\\DBAL\\Driver\\PDO\\Exception"},{"__class__":"Doctrine\\DBAL\\Query"}]},{"file":"/var/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php","line":1173,"function":"convertExceptionDuringQuery","class":"Doctrine\\DBAL\\Connection","type":"->","args":[{"__class__":"Doctrine\\DBAL\\Driver\\PDO\\Exception"},"UPDATE `oc_filecache` SET `mtime` = ?, `storage_mtime` = ? WHERE (`fileid` = ?) AND (((`mtime` <> ?) OR (`mtime` IS NULL)) OR ((`storage_mtime` <> ?) OR (`storage_mtime` IS NULL)))",[1649541620,1649541620,"*** sensitive parameter replaced ***",1649541620,1649541620],[2,2,1,2,2]]},{"file":"/var/www/nextcloud/lib/private/DB/Connection.php","line":270,"function":"executeStatement","class":"Doctrine\\DBAL\\Connection","type":"->","args":["UPDATE `oc_filecache` SET `mtime` = ?, `storage_mtime` = ? WHERE (`fileid` = ?) AND (((`mtime` <> ?) OR (`mtime` IS NULL)) OR ((`storage_mtime` <> ?) OR (`storage_mtime` IS NULL)))",[1649541620,1649541620,"*** sensitive parameter replaced ***",1649541620,1649541620],[2,2,1,2,2]]},{"file":"/var/www/nextcloud/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php","line":354,"function":"executeStatement","class":"OC\\DB\\Connection","type":"->","args":["UPDATE `oc_filecache` SET `mtime` = :dcValue4, `storage_mtime` = :dcValue5 WHERE (`fileid` = :dcValue1) AND (((`mtime` <> :dcValue2) OR (`mtime` IS NULL)) OR ((`storage_mtime` <> :dcValue3) OR (`storage_mtime` IS NULL)))",{"dcValue1":"*** sensitive parameter replaced ***","dcValue2":1649541620,"dcValue3":1649541620,"dcValue4":1649541620,"dcValue5":1649541620},{"dcValue1":1,"dcValue2":2,"dcValue3":2,"dcValue4":2,"dcValue5":2}]},{"file":"/var/www/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php","line":287,"function":"execute","class":"Doctrine\\DBAL\\Query\\QueryBuilder","type":"->","args":[]},{"file":"/var/www/nextcloud/lib/private/Files/Cache/Cache.php","line":379,"function":"execute","class":"OC\\DB\\QueryBuilder\\QueryBuilder","type":"->","args":[]},{"file":"/var/www/nextcloud/lib/private/Files/Cache/Updater.php","line":256,"function":"update","class":"OC\\Files\\Cache\\Cache","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/nextcloud/lib/private/Files/Cache/Updater.php","line":138,"function":"correctParentStorageMtime","class":"OC\\Files\\Cache\\Updater","type":"->","args":["*** sensitive parameter replaced ***"]},{"file":"/var/www/nextcloud/apps/dav/lib/Connector/Sabre/File.php","line":339,"function":"update","class":"OC\\Files\\Cache\\Updater","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/nextcloud/apps/dav/lib/Connector/Sabre/Directory.php","line":155,"function":"put","class":"OCA\\DAV\\Connector\\Sabre\\File","type":"->","args":[null]},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":1098,"function":"createFile","class":"OCA\\DAV\\Connector\\Sabre\\Directory","type":"->","args":["Qgaz.dat",null]},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/CorePlugin.php","line":504,"function":"createFile","class":"Sabre\\DAV\\Server","type":"->","args":["files/user/some/filder/2/20220410-000001-305/backup/home/user/some/stuff/file.dat",null,null]},{"file":"/var/www/nextcloud/3rdparty/sabre/event/lib/WildcardEmitterTrait.php","line":89,"function":"httpPut","class":"Sabre\\DAV\\CorePlugin","type":"->","args":[{"__class__":"Sabre\\HTTP\\Request"},{"__class__":"Sabre\\HTTP\\Response"}]},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":472,"function":"emit","class":"Sabre\\DAV\\Server","type":"->","args":["method:PUT",[{"__class__":"Sabre\\HTTP\\Request"},{"__class__":"Sabre\\HTTP\\Response"}]]},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":253,"function":"invokeMethod","class":"Sabre\\DAV\\Server","type":"->","args":[{"__class__":"Sabre\\HTTP\\Request"},{"__class__":"Sabre\\HTTP\\Response"}]},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":321,"function":"start","class":"Sabre\\DAV\\Server","type":"->","args":[]},{"file":"/var/www/nextcloud/apps/dav/lib/Server.php","line":339,"function":"exec","class":"Sabre\\DAV\\Server","type":"->","args":[]},{"file":"/var/www/nextcloud/apps/dav/appinfo/v2/remote.php","line":35,"function":"exec","class":"OCA\\DAV\\Server","type":"->","args":[]},{"file":"/var/www/nextcloud/remote.php","line":166,"args":["/var/www/nextcloud/apps/dav/appinfo/v2/remote.php"],"function":"require_once"}],"File":"/var/www/nextcloud/3rdparty/doctrine/dbal/src/Driver/API/MySQL/ExceptionConverter.php","Line":37,"Previous":{"Exception":"Doctrine\\DBAL\\Driver\\PDO\\Exception","Message":"SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction","Code":1213,"Trace":[{"file":"/var/www/nextcloud/3rdparty/doctrine/dbal/src/Driver/PDO/Statement.php","line":94,"function":"new","class":"Doctrine\\DBAL\\Driver\\PDO\\Exception","type":"::","args":[{"__class__":"PDOException","errorInfo":["40001",1213,"Deadlock found when trying to get lock; try restarting transaction"]}]},{"file":"/var/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php","line":1163,"function":"execute","class":"Doctrine\\DBAL\\Driver\\PDO\\Statement","type":"->","args":[]},{"file":"/var/www/nextcloud/lib/private/DB/Connection.php","line":270,"function":"executeStatement","class":"Doctrine\\DBAL\\Connection","type":"->","args":["UPDATE `oc_filecache` SET `mtime` = ?, `storage_mtime` = ? WHERE (`fileid` = ?) AND (((`mtime` <> ?) OR (`mtime` IS NULL)) OR ((`storage_mtime` <> ?) OR (`storage_mtime` IS NULL)))",[1649541620,1649541620,"*** sensitive parameter replaced ***",1649541620,1649541620],[2,2,1,2,2]]},{"file":"/var/www/nextcloud/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php","line":354,"function":"executeStatement","class":"OC\\DB\\Connection","type":"->","args":["UPDATE `oc_filecache` SET `mtime` = :dcValue4, `storage_mtime` = :dcValue5 WHERE (`fileid` = :dcValue1) AND (((`mtime` <> :dcValue2) OR (`mtime` IS NULL)) OR ((`storage_mtime` <> :dcValue3) OR (`storage_mtime` IS NULL)))",{"dcValue1":"*** sensitive parameter replaced ***","dcValue2":1649541620,"dcValue3":1649541620,"dcValue4":1649541620,"dcValue5":1649541620},{"dcValue1":1,"dcValue2":2,"dcValue3":2,"dcValue4":2,"dcValue5":2}]},{"file":"/var/www/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php","line":287,"function":"execute","class":"Doctrine\\DBAL\\Query\\QueryBuilder","type":"->","args":[]},{"file":"/var/www/nextcloud/lib/private/Files/Cache/Cache.php","line":379,"function":"execute","class":"OC\\DB\\QueryBuilder\\QueryBuilder","type":"->","args":[]},{"file":"/var/www/nextcloud/lib/private/Files/Cache/Updater.php","line":256,"function":"update","class":"OC\\Files\\Cache\\Cache","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/nextcloud/lib/private/Files/Cache/Updater.php","line":138,"function":"correctParentStorageMtime","class":"OC\\Files\\Cache\\Updater","type":"->","args":["*** sensitive parameter replaced ***"]},{"file":"/var/www/nextcloud/apps/dav/lib/Connector/Sabre/File.php","line":339,"function":"update","class":"OC\\Files\\Cache\\Updater","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/nextcloud/apps/dav/lib/Connector/Sabre/Directory.php","line":155,"function":"put","class":"OCA\\DAV\\Connector\\Sabre\\File","type":"->","args":[null]},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":1098,"function":"createFile","class":"OCA\\DAV\\Connector\\Sabre\\Directory","type":"->","args":["Qgaz.dat",null]},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/CorePlugin.php","line":504,"function":"createFile","class":"Sabre\\DAV\\Server","type":"->","args":["files/user/some/filder/2/20220410-000001-305/backup/home/user/some/stuff/file.dat",null,null]},{"file":"/var/www/nextcloud/3rdparty/sabre/event/lib/WildcardEmitterTrait.php","line":89,"function":"httpPut","class":"Sabre\\DAV\\CorePlugin","type":"->","args":[{"__class__":"Sabre\\HTTP\\Request"},{"__class__":"Sabre\\HTTP\\Response"}]},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":472,"function":"emit","class":"Sabre\\DAV\\Server","type":"->","args":["method:PUT",[{"__class__":"Sabre\\HTTP\\Request"},{"__class__":"Sabre\\HTTP\\Response"}]]},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":253,"function":"invokeMethod","class":"Sabre\\DAV\\Server","type":"->","args":[{"__class__":"Sabre\\HTTP\\Request"},{"__class__":"Sabre\\HTTP\\Response"}]},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":321,"function":"start","class":"Sabre\\DAV\\Server","type":"->","args":[]},{"file":"/var/www/nextcloud/apps/dav/lib/Server.php","line":339,"function":"exec","class":"Sabre\\DAV\\Server","type":"->","args":[]},{"file":"/var/www/nextcloud/apps/dav/appinfo/v2/remote.php","line":35,"function":"exec","class":"OCA\\DAV\\Server","type":"->","args":[]},{"file":"/var/www/nextcloud/remote.php","line":166,"args":["/var/www/nextcloud/apps/dav/appinfo/v2/remote.php"],"function":"require_once"}],"File":"/var/www/nextcloud/3rdparty/doctrine/dbal/src/Driver/PDO/Exception.php","Line":26,"Previous":{"Exception":"PDOException","Message":"SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction","Code":"40001","Trace":[{"file":"/var/www/nextcloud/3rdparty/doctrine/dbal/src/Driver/PDO/Statement.php","line":92,"function":"execute","class":"PDOStatement","type":"->","args":[null]},{"file":"/var/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php","line":1163,"function":"execute","class":"Doctrine\\DBAL\\Driver\\PDO\\Statement","type":"->","args":[]},{"file":"/var/www/nextcloud/lib/private/DB/Connection.php","line":270,"function":"executeStatement","class":"Doctrine\\DBAL\\Connection","type":"->","args":["UPDATE `oc_filecache` SET `mtime` = ?, `storage_mtime` = ? WHERE (`fileid` = ?) AND (((`mtime` <> ?) OR (`mtime` IS NULL)) OR ((`storage_mtime` <> ?) OR (`storage_mtime` IS NULL)))",[1649541620,1649541620,"*** sensitive parameter replaced ***",1649541620,1649541620],[2,2,1,2,2]]},{"file":"/var/www/nextcloud/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php","line":354,"function":"executeStatement","class":"OC\\DB\\Connection","type":"->","args":["UPDATE `oc_filecache` SET `mtime` = :dcValue4, `storage_mtime` = :dcValue5 WHERE (`fileid` = :dcValue1) AND (((`mtime` <> :dcValue2) OR (`mtime` IS NULL)) OR ((`storage_mtime` <> :dcValue3) OR (`storage_mtime` IS NULL)))",{"dcValue1":"*** sensitive parameter replaced ***","dcValue2":1649541620,"dcValue3":1649541620,"dcValue4":1649541620,"dcValue5":1649541620},{"dcValue1":1,"dcValue2":2,"dcValue3":2,"dcValue4":2,"dcValue5":2}]},{"file":"/var/www/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php","line":287,"function":"execute","class":"Doctrine\\DBAL\\Query\\QueryBuilder","type":"->","args":[]},{"file":"/var/www/nextcloud/lib/private/Files/Cache/Cache.php","line":379,"function":"execute","class":"OC\\DB\\QueryBuilder\\QueryBuilder","type":"->","args":[]},{"file":"/var/www/nextcloud/lib/private/Files/Cache/Updater.php","line":256,"function":"update","class":"OC\\Files\\Cache\\Cache","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/nextcloud/lib/private/Files/Cache/Updater.php","line":138,"function":"correctParentStorageMtime","class":"OC\\Files\\Cache\\Updater","type":"->","args":["*** sensitive parameter replaced ***"]},{"file":"/var/www/nextcloud/apps/dav/lib/Connector/Sabre/File.php","line":339,"function":"update","class":"OC\\Files\\Cache\\Updater","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/nextcloud/apps/dav/lib/Connector/Sabre/Directory.php","line":155,"function":"put","class":"OCA\\DAV\\Connector\\Sabre\\File","type":"->","args":[null]},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":1098,"function":"createFile","class":"OCA\\DAV\\Connector\\Sabre\\Directory","type":"->","args":["Qgaz.dat",null]},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/CorePlugin.php","line":504,"function":"createFile","class":"Sabre\\DAV\\Server","type":"->","args":["files/user/some/filder/2/20220410-000001-305/backup/home/user/some/stuff/file.dat",null,null]},{"file":"/var/www/nextcloud/3rdparty/sabre/event/lib/WildcardEmitterTrait.php","line":89,"function":"httpPut","class":"Sabre\\DAV\\CorePlugin","type":"->","args":[{"__class__":"Sabre\\HTTP\\Request"},{"__class__":"Sabre\\HTTP\\Response"}]},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":472,"function":"emit","class":"Sabre\\DAV\\Server","type":"->","args":["method:PUT",[{"__class__":"Sabre\\HTTP\\Request"},{"__class__":"Sabre\\HTTP\\Response"}]]},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":253,"function":"invokeMethod","class":"Sabre\\DAV\\Server","type":"->","args":[{"__class__":"Sabre\\HTTP\\Request"},{"__class__":"Sabre\\HTTP\\Response"}]},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":321,"function":"start","class":"Sabre\\DAV\\Server","type":"->","args":[]},{"file":"/var/www/nextcloud/apps/dav/lib/Server.php","line":339,"function":"exec","class":"Sabre\\DAV\\Server","type":"->","args":[]},{"file":"/var/www/nextcloud/apps/dav/appinfo/v2/remote.php","line":35,"function":"exec","class":"OCA\\DAV\\Server","type":"->","args":[]},{"file":"/var/www/nextcloud/remote.php","line":166,"args":["/var/www/nextcloud/apps/dav/appinfo/v2/remote.php"],"function":"require_once"}],"File":"/var/www/nextcloud/3rdparty/doctrine/dbal/src/Driver/PDO/Statement.php","Line":92}},"CustomMessage":"--"},"id":"625989f16ff4d"}

Additional info

MariaDB Deadlock Summary

------------------------
LATEST DETECTED DEADLOCK
------------------------
2022-04-11 12:30:39 0x7f525c1cf700
*** (1) TRANSACTION:
TRANSACTION 835932162, ACTIVE 0 sec starting index read
mysql tables in use 1, locked 1
LOCK WAIT 3 lock struct(s), heap size 1128, 2 row lock(s)
MySQL thread id 184854, OS thread handle 140014127793920, query id 17600806 localhost nextcloud_user Updating
UPDATE `oc_filecache` SET `mtime` = '1649673039', `storage_mtime` = '1649673039' WHERE (`fileid` = 5032357) AND (((`mtime` <> '1649673039') OR (`mtime` IS NULL)) OR ((`storage_mtime` <> '1649673039') OR (`storage_mtime` IS NULL)))
*** (1) WAITING FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 572 page no 113679 n bits 120 index PRIMARY of table `nextcloud`.`oc_filecache` trx id 835932162 lock_mode X locks rec but not gap waiting
Record lock, heap no 40 PHYSICAL RECORD: n_fields 18; compact format; info bits 0
 0: len 8; hex 80000000004cc9a5; asc      L  ;;
 1: len 6; hex 000031d34fff; asc   1 O ;;
 2: len 7; hex 070000027632bf; asc     v2 ;;
 3: len 8; hex 8000000000000007; asc         ;;
 4: len 30; hex 66696c65732f536963686572756e67656e2f6261636b696e74696d652f65; asc files/Sicherungen/backintime/e; (total 100 bytes);
 5: len 30; hex 366337336162373864383533376130333939303764336437363635303533; asc 6c73ab78d8537a039907d3d7665053; (total 32 bytes);
 6: len 8; hex 80000000004cc94f; asc      L O;;
 7: len 3; hex 565341; asc VSA;;
 8: len 8; hex 8000000000000001; asc         ;;
 9: len 8; hex 8000000000000002; asc         ;;
 10: len 8; hex 80000000000112c0; asc         ;;
 11: len 8; hex 800000006254034f; asc     bT O;;
 12: len 8; hex 800000006254034f; asc     bT O;;
 13: len 4; hex 80000000; asc     ;;
 14: len 8; hex 8000000000000000; asc         ;;
 15: len 13; hex 36323534303334666562383635; asc 6254034feb865;;
 16: len 4; hex 8000001f; asc     ;;
 17: len 0; hex ; asc ;;

*** (2) TRANSACTION:
TRANSACTION 835932159, ACTIVE 0 sec updating or deleting
mysql tables in use 1, locked 1
13 lock struct(s), heap size 1128, 13 row lock(s), undo log entries 6
MySQL thread id 184855, OS thread handle 139991709447936, query id 17600797 localhost nextcloud_user Updating
UPDATE `oc_filecache` SET `size` = GREATEST(`size` + '260', -1) WHERE (`storage` = 7) AND (`path_hash` IN ('d41d8cd98f00b204e9800998ecf8427e', '45b963397aa40d4a0063e0d85e4fe7a1', '2486c5bafedcd082f9fd3126ed08c8f0', 'ce0e3198a892569cab395fecf5b3e1c9', '3000062007e200705b952d0f96cd870f', 'e8324726cb494a1ab958f64b86f4f062', '77df0a53748b00c5d3f73841fdbbef3b', 'f387dfa79ab7c23e85da67d84d39a67b', '43befc2c207a5d1075be34504d555f58', '3eb4c7e822d7022d299e18ccee00de99', 'ab0ce23b6b134e767e298b4520fd071e', '9c0282025e3c3d3891eef2dbc4f90a25', '81f0c7414ed4e64bb623a5dcd7ce4f0b', '6c73ab78d8537a039907d3d766505381')) AND (`size` > '-1')
*** (2) HOLDS THE LOCK(S):
RECORD LOCKS space id 572 page no 113679 n bits 120 index PRIMARY of table `nextcloud`.`oc_filecache` trx id 835932159 lock_mode X locks rec but not gap
Record lock, heap no 40 PHYSICAL RECORD: n_fields 18; compact format; info bits 0
 0: len 8; hex 80000000004cc9a5; asc      L  ;;
 1: len 6; hex 000031d34fff; asc   1 O ;;
 2: len 7; hex 070000027632bf; asc     v2 ;;
 3: len 8; hex 8000000000000007; asc         ;;
 4: len 30; hex 66696c65732f536963686572756e67656e2f6261636b696e74696d652f65; asc files/Sicherungen/backintime/e; (total 100 bytes);
 5: len 30; hex 366337336162373864383533376130333939303764336437363635303533; asc 6c73ab78d8537a039907d3d7665053; (total 32 bytes);
 6: len 8; hex 80000000004cc94f; asc      L O;;
 7: len 3; hex 565341; asc VSA;;
 8: len 8; hex 8000000000000001; asc         ;;
 9: len 8; hex 8000000000000002; asc         ;;
 10: len 8; hex 80000000000112c0; asc         ;;
 11: len 8; hex 800000006254034f; asc     bT O;;
 12: len 8; hex 800000006254034f; asc     bT O;;
 13: len 4; hex 80000000; asc     ;;
 14: len 8; hex 8000000000000000; asc         ;;
 15: len 13; hex 36323534303334666562383635; asc 6254034feb865;;
 16: len 4; hex 8000001f; asc     ;;
 17: len 0; hex ; asc ;;

*** (2) WAITING FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 572 page no 74162 n bits 568 index fs_id_storage_size of table `nextcloud`.`oc_filecache` trx id 835932159 lock_mode X locks rec but not gap waiting
Record lock, heap no 125 PHYSICAL RECORD: n_fields 3; compact format; info bits 0
 0: len 8; hex 80000000004cc9a5; asc      L  ;;
 1: len 8; hex 8000000000000007; asc         ;;
 2: len 8; hex 80000000000111bc; asc         ;;

*** WE ROLL BACK TRANSACTION (1)

Relevant code sections

This issue seems to be triggered by the subsequent calls of lib/private/File/Cache/Updater.php:138:

		$this->correctParentStorageMtime($path);
		$this->propagator->propagateChange($path, $time, $sizeDifference);

where the first transaction (1) is started by correctParentStorageMtime() to update oc_filecache's mtime in lib/private/File/Cache/Updater.php:250:

	private function correctParentStorageMtime($internalPath) {
		$parentId = $this->cache->getParentId($internalPath);
		$parent = dirname($internalPath);
		if ($parentId != -1) {
			$mtime = $this->storage->filemtime($parent);
			if ($mtime !== false) {
				$this->cache->update($parentId, ['storage_mtime' => $mtime]);
			}
		}
	}

and the second transaction (2) by the propagator which updates the size of the relevant storage paths in lib/private/File/Cache/Propagator.php:106:

			$builder = $this->connection->getQueryBuilder();
			$builder->update('filecache')
				->set('size', $builder->func()->greatest(
					$builder->func()->add('size', $builder->createNamedParameter($sizeDifference)),
					$builder->createNamedParameter(-1, IQueryBuilder::PARAM_INT)
				))
				->where($builder->expr()->eq('storage', $builder->createNamedParameter($storageId, IQueryBuilder::PARAM_INT)))
				->andWhere($builder->expr()->in('path_hash', $hashParams))
				->andWhere($builder->expr()->gt('size', $builder->expr()->literal(-1, IQueryBuilder::PARAM_INT)));

			$builder->execute();

Not sure how to combine them into one query though - but I'm sure you do! 🙂

Metadata

Metadata

Assignees

No one assigned

    Labels

    1. to developAccepted and waiting to be taken care ofbug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions