Can't delete files on subfolders

Hi all,

facing issue as per objects, to delete files those must be moved on root.

Nextcloud version: 19.0.2
Operating system and version: Ubuntu 18.04.5
Apache or nginx version: Apache 2.4.29
PHP version: _7.4.9

The issue you are facing:

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

Steps to replicate it:

  1. Create a folder
  2. Create a subfolder of folder at point 1.
  3. Put a file in the latest subfolder
  4. Try to delete it, got below error

The output of your Nextcloud log in Admin > Logging:

Doctrine\DBAL\Exception\DriverException: An exception occurred while executing 'SELECT "fileid" FROM "oc_filecache" WHERE ("storage" = ?) AND ("path_hash" = ?)' with params [43, "3014a771cbe30761f2e9ff3272110dbf"]: SQLSTATE[25P02]: In failed sql transaction: 7 ERROR: current transaction is aborted, commands ignored until end of transaction block
{"reqId":"286rUuGFWuebAnZGRNlg","level":4,"time":"2020-09-02T18:23:31+02:00","remoteAddr":"172.31.79.253","user":"92A45C2D-3769-41CF-897F-EC17F281C7EA","app":"webdav","method":"DELETE","url":"/remote.php/dav/files/92A45C2D-3769-41CF-897F-EC17F281C7EA/Outlook/Public-Share/20200403/880487b3cc70462eaeeb3afbe571901d","message":{"Exception":"Doctrine\\DBAL\\Exception\\DriverException","Message":"An exception occurred while executing 'SELECT \"fileid\" FROM \"oc_filecache\" WHERE (\"storage\" = ?) AND (\"path_hash\" = ?)' with params [43, \"3014a771cbe30761f2e9ff3272110dbf\"]:\n\nSQLSTATE[25P02]: In failed sql transaction: 7 ERROR:  current transaction is aborted, commands ignored until end of transaction block","Code":0,"Trace":[{"file":"/var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php","line":169,"function":"convertException","class":"Doctrine\\DBAL\\Driver\\AbstractPostgreSQLDriver","type":"->"},{"file":"/var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php","line":145,"function":"wrapException","class":"Doctrine\\DBAL\\DBALException","type":"::"},{"file":"/var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php","line":911,"function":"driverExceptionDuringQuery","class":"Doctrine\\DBAL\\DBALException","type":"::"},{"file":"/var/www/nextcloud/lib/private/DB/Connection.php","line":194,"function":"executeQuery","class":"Doctrine\\DBAL\\Connection","type":"->"},{"file":"/var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Query/QueryBuilder.php","line":200,"function":"executeQuery","class":"OC\\DB\\Connection","type":"->"},{"file":"/var/www/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php","line":216,"function":"execute","class":"Doctrine\\DBAL\\Query\\QueryBuilder","type":"->"},{"file":"/var/www/nextcloud/lib/private/Files/Cache/Cache.php","line":472,"function":"execute","class":"OC\\DB\\QueryBuilder\\QueryBuilder","type":"->"},{"file":"/var/www/nextcloud/lib/private/Files/Cache/Cache.php","line":487,"function":"getId","class":"OC\\Files\\Cache\\Cache","type":"->"},{"file":"/var/www/nextcloud/lib/private/Files/Cache/Wrapper/CacheWrapper.php","line":161,"function":"getParentId","class":"OC\\Files\\Cache\\Cache","type":"->"},{"file":"/var/www/nextcloud/lib/private/Files/Cache/Updater.php","line":252,"function":"getParentId","class":"OC\\Files\\Cache\\Wrapper\\CacheWrapper","type":"->"},{"file":"/var/www/nextcloud/lib/private/Files/Cache/Updater.php","line":225,"function":"correctParentStorageMtime","class":"OC\\Files\\Cache\\Updater","type":"->"},{"file":"/var/www/nextcloud/apps/files_trashbin/lib/Trashbin.php","line":289,"function":"renameFromStorage","class":"OC\\Files\\Cache\\Updater","type":"->"},{"file":"/var/www/nextcloud/apps/files_trashbin/lib/Trash/LegacyTrashBackend.php","line":108,"function":"move2trash","class":"OCA\\Files_Trashbin\\Trashbin","type":"::"},{"file":"/var/www/nextcloud/apps/files_trashbin/lib/Trash/TrashManager.php","line":103,"function":"moveToTrash","class":"OCA\\Files_Trashbin\\Trash\\LegacyTrashBackend","type":"->"},{"file":"/var/www/nextcloud/apps/files_trashbin/lib/Storage.php","line":192,"function":"moveToTrash","class":"OCA\\Files_Trashbin\\Trash\\TrashManager","type":"->"},{"file":"/var/www/nextcloud/apps/files_trashbin/lib/Storage.php","line":118,"function":"doDelete","class":"OCA\\Files_Trashbin\\Storage","type":"->"},{"file":"/var/www/nextcloud/lib/private/Files/Storage/Wrapper/Wrapper.php","line":93,"function":"rmdir","class":"OCA\\Files_Trashbin\\Storage","type":"->"},{"file":"/var/www/nextcloud/lib/private/Files/View.php","line":1161,"function":"rmdir","class":"OC\\Files\\Storage\\Wrapper\\Wrapper","type":"->"},{"file":"/var/www/nextcloud/lib/private/Files/View.php","line":350,"function":"basicOperation","class":"OC\\Files\\View","type":"->"},{"file":"/var/www/nextcloud/apps/dav/lib/Connector/Sabre/Directory.php","line":308,"function":"rmdir","class":"OC\\Files\\View","type":"->"},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Tree.php","line":183,"function":"delete","class":"OCA\\DAV\\Connector\\Sabre\\Directory","type":"->"},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/CorePlugin.php","line":295,"function":"delete","class":"Sabre\\DAV\\Tree","type":"->"},{"file":"/var/www/nextcloud/3rdparty/sabre/event/lib/WildcardEmitterTrait.php","line":89,"function":"httpDelete","class":"Sabre\\DAV\\CorePlugin","type":"->"},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":474,"function":"emit","class":"Sabre\\DAV\\Server","type":"->"},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":251,"function":"invokeMethod","class":"Sabre\\DAV\\Server","type":"->"},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":319,"function":"start","class":"Sabre\\DAV\\Server","type":"->"},{"file":"/var/www/nextcloud/apps/dav/lib/Server.php","line":320,"function":"exec","class":"Sabre\\DAV\\Server","type":"->"},{"file":"/var/www/nextcloud/apps/dav/appinfo/v2/remote.php","line":35,"function":"exec","class":"OCA\\DAV\\Server","type":"->"},{"file":"/var/www/nextcloud/remote.php","line":167,"args":["/var/www/nextcloud/apps/dav/appinfo/v2/remote.php"],"function":"require_once"}],"File":"/var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php","Line":79,"Previous":{"Exception":"Doctrine\\DBAL\\Driver\\PDOException","Message":"SQLSTATE[25P02]: In failed sql transaction: 7 ERROR:  current transaction is aborted, commands ignored until end of transaction block","Code":"25P02","Trace":[{"file":"/var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php","line":903,"function":"execute","class":"Doctrine\\DBAL\\Driver\\PDOStatement","type":"->"},{"file":"/var/www/nextcloud/lib/private/DB/Connection.php","line":194,"function":"executeQuery","class":"Doctrine\\DBAL\\Connection","type":"->"},{"file":"/var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Query/QueryBuilder.php","line":200,"function":"executeQuery","class":"OC\\DB\\Connection","type":"->"},{"file":"/var/www/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php","line":216,"function":"execute","class":"Doctrine\\DBAL\\Query\\QueryBuilder","type":"->"},{"file":"/var/www/nextcloud/lib/private/Files/Cache/Cache.php","line":472,"function":"execute","class":"OC\\DB\\QueryBuilder\\QueryBuilder","type":"->"},{"file":"/var/www/nextcloud/lib/private/Files/Cache/Cache.php","line":487,"function":"getId","class":"OC\\Files\\Cache\\Cache","type":"->"},{"file":"/var/www/nextcloud/lib/private/Files/Cache/Wrapper/CacheWrapper.php","line":161,"function":"getParentId","class":"OC\\Files\\Cache\\Cache","type":"->"},{"file":"/var/www/nextcloud/lib/private/Files/Cache/Updater.php","line":252,"function":"getParentId","class":"OC\\Files\\Cache\\Wrapper\\CacheWrapper","type":"->"},{"file":"/var/www/nextcloud/lib/private/Files/Cache/Updater.php","line":225,"function":"correctParentStorageMtime","class":"OC\\Files\\Cache\\Updater","type":"->"},{"file":"/var/www/nextcloud/apps/files_trashbin/lib/Trashbin.php","line":289,"function":"renameFromStorage","class":"OC\\Files\\Cache\\Updater","type":"->"},{"file":"/var/www/nextcloud/apps/files_trashbin/lib/Trash/LegacyTrashBackend.php","line":108,"function":"move2trash","class":"OCA\\Files_Trashbin\\Trashbin","type":"::"},{"file":"/var/www/nextcloud/apps/files_trashbin/lib/Trash/TrashManager.php","line":103,"function":"moveToTrash","class":"OCA\\Files_Trashbin\\Trash\\LegacyTrashBackend","type":"->"},{"file":"/var/www/nextcloud/apps/files_trashbin/lib/Storage.php","line":192,"function":"moveToTrash","class":"OCA\\Files_Trashbin\\Trash\\TrashManager","type":"->"},{"file":"/var/www/nextcloud/apps/files_trashbin/lib/Storage.php","line":118,"function":"doDelete","class":"OCA\\Files_Trashbin\\Storage","type":"->"},{"file":"/var/www/nextcloud/lib/private/Files/Storage/Wrapper/Wrapper.php","line":93,"function":"rmdir","class":"OCA\\Files_Trashbin\\Storage","type":"->"},{"file":"/var/www/nextcloud/lib/private/Files/View.php","line":1161,"function":"rmdir","class":"OC\\Files\\Storage\\Wrapper\\Wrapper","type":"->"},{"file":"/var/www/nextcloud/lib/private/Files/View.php","line":350,"function":"basicOperation","class":"OC\\Files\\View","type":"->"},{"file":"/var/www/nextcloud/apps/dav/lib/Connector/Sabre/Directory.php","line":308,"function":"rmdir","class":"OC\\Files\\View","type":"->"},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Tree.php","line":183,"function":"delete","class":"OCA\\DAV\\Connector\\Sabre\\Directory","type":"->"},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/CorePlugin.php","line":295,"function":"delete","class":"Sabre\\DAV\\Tree","type":"->"},{"file":"/var/www/nextcloud/3rdparty/sabre/event/lib/WildcardEmitterTrait.php","line":89,"function":"httpDelete","class":"Sabre\\DAV\\CorePlugin","type":"->"},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":474,"function":"emit","class":"Sabre\\DAV\\Server","type":"->"},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":251,"function":"invokeMethod","class":"Sabre\\DAV\\Server","type":"->"},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":319,"function":"start","class":"Sabre\\DAV\\Server","type":"->"},{"file":"/var/www/nextcloud/apps/dav/lib/Server.php","line":320,"function":"exec","class":"Sabre\\DAV\\Server","type":"->"},{"file":"/var/www/nextcloud/apps/dav/appinfo/v2/remote.php","line":35,"function":"exec","class":"OCA\\DAV\\Server","type":"->"},{"file":"/var/www/nextcloud/remote.php","line":167,"args":["/var/www/nextcloud/apps/dav/appinfo/v2/remote.php"],"function":"require_once"}],"File":"/var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php","Line":119,"Previous":{"Exception":"PDOException","Message":"SQLSTATE[25P02]: In failed sql transaction: 7 ERROR:  current transaction is aborted, commands ignored until end of transaction block","Code":"25P02","Trace":[{"file":"/var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php","line":117,"function":"execute","class":"PDOStatement","type":"->"},{"file":"/var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php","line":903,"function":"execute","class":"Doctrine\\DBAL\\Driver\\PDOStatement","type":"->"},{"file":"/var/www/nextcloud/lib/private/DB/Connection.php","line":194,"function":"executeQuery","class":"Doctrine\\DBAL\\Connection","type":"->"},{"file":"/var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Query/QueryBuilder.php","line":200,"function":"executeQuery","class":"OC\\DB\\Connection","type":"->"},{"file":"/var/www/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php","line":216,"function":"execute","class":"Doctrine\\DBAL\\Query\\QueryBuilder","type":"->"},{"file":"/var/www/nextcloud/lib/private/Files/Cache/Cache.php","line":472,"function":"execute","class":"OC\\DB\\QueryBuilder\\QueryBuilder","type":"->"},{"file":"/var/www/nextcloud/lib/private/Files/Cache/Cache.php","line":487,"function":"getId","class":"OC\\Files\\Cache\\Cache","type":"->"},{"file":"/var/www/nextcloud/lib/private/Files/Cache/Wrapper/CacheWrapper.php","line":161,"function":"getParentId","class":"OC\\Files\\Cache\\Cache","type":"->"},{"file":"/var/www/nextcloud/lib/private/Files/Cache/Updater.php","line":252,"function":"getParentId","class":"OC\\Files\\Cache\\Wrapper\\CacheWrapper","type":"->"},{"file":"/var/www/nextcloud/lib/private/Files/Cache/Updater.php","line":225,"function":"correctParentStorageMtime","class":"OC\\Files\\Cache\\Updater","type":"->"},{"file":"/var/www/nextcloud/apps/files_trashbin/lib/Trashbin.php","line":289,"function":"renameFromStorage","class":"OC\\Files\\Cache\\Updater","type":"->"},{"file":"/var/www/nextcloud/apps/files_trashbin/lib/Trash/LegacyTrashBackend.php","line":108,"function":"move2trash","class":"OCA\\Files_Trashbin\\Trashbin","type":"::"},{"file":"/var/www/nextcloud/apps/files_trashbin/lib/Trash/TrashManager.php","line":103,"function":"moveToTrash","class":"OCA\\Files_Trashbin\\Trash\\LegacyTrashBackend","type":"->"},{"file":"/var/www/nextcloud/apps/files_trashbin/lib/Storage.php","line":192,"function":"moveToTrash","class":"OCA\\Files_Trashbin\\Trash\\TrashManager","type":"->"},{"file":"/var/www/nextcloud/apps/files_trashbin/lib/Storage.php","line":118,"function":"doDelete","class":"OCA\\Files_Trashbin\\Storage","type":"->"},{"file":"/var/www/nextcloud/lib/private/Files/Storage/Wrapper/Wrapper.php","line":93,"function":"rmdir","class":"OCA\\Files_Trashbin\\Storage","type":"->"},{"file":"/var/www/nextcloud/lib/private/Files/View.php","line":1161,"function":"rmdir","class":"OC\\Files\\Storage\\Wrapper\\Wrapper","type":"->"},{"file":"/var/www/nextcloud/lib/private/Files/View.php","line":350,"function":"basicOperation","class":"OC\\Files\\View","type":"->"},{"file":"/var/www/nextcloud/apps/dav/lib/Connector/Sabre/Directory.php","line":308,"function":"rmdir","class":"OC\\Files\\View","type":"->"},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Tree.php","line":183,"function":"delete","class":"OCA\\DAV\\Connector\\Sabre\\Directory","type":"->"},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/CorePlugin.php","line":295,"function":"delete","class":"Sabre\\DAV\\Tree","type":"->"},{"file":"/var/www/nextcloud/3rdparty/sabre/event/lib/WildcardEmitterTrait.php","line":89,"function":"httpDelete","class":"Sabre\\DAV\\CorePlugin","type":"->"},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":474,"function":"emit","class":"Sabre\\DAV\\Server","type":"->"},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":251,"function":"invokeMethod","class":"Sabre\\DAV\\Server","type":"->"},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":319,"function":"start","class":"Sabre\\DAV\\Server","type":"->"},{"file":"/var/www/nextcloud/apps/dav/lib/Server.php","line":320,"function":"exec","class":"Sabre\\DAV\\Server","type":"->"},{"file":"/var/www/nextcloud/apps/dav/appinfo/v2/remote.php","line":35,"function":"exec","class":"OCA\\DAV\\Server","type":"->"},{"file":"/var/www/nextcloud/remote.php","line":167,"args":["/var/www/nextcloud/apps/dav/appinfo/v2/remote.php"],"function":"require_once"}],"File":"/var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php","Line":117}},"CustomMessage":"--"},"userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36 Edg/85.0.564.41","version":"19.0.2.2","id":"5f4fc9102cf75"}

No one got info about this? No one got the same trouble?

I’ve got more informations:
when i run the command:
occ files:scan --all
the result got this error:

Exception during scan: An exception occurred while executing 'SELECT "fileid" FROM "oc_filecache" WHERE ("storage" = ?) AND ("path_hash" = ?)' with params [4, "d01bb67e7b71dd49fd06bad922f521c9"]:

SQLSTATE[25P02]: In failed sql transaction: 7 ERROR:  current transaction is aborted, commands ignored until end of transaction block
#0 /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php(169): Doctrine\DBAL\Driver\AbstractPostgreSQLDriver->convertException()
#1 /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php(145): Doctrine\DBAL\DBALException::wrapException()
#2 /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(911): Doctrine\DBAL\DBALException::driverExceptionDuringQuery()
#3 /var/www/nextcloud/lib/private/DB/Connection.php(194): Doctrine\DBAL\Connection->executeQuery()
#4 /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Query/QueryBuilder.php(200): OC\DB\Connection->executeQuery()
#5 /var/www/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php(216): Doctrine\DBAL\Query\QueryBuilder->execute()
#6 /var/www/nextcloud/lib/private/Files/Cache/Cache.php(472): OC\DB\QueryBuilder\QueryBuilder->execute()
#7 /var/www/nextcloud/lib/private/Files/Cache/Scanner.php(386): OC\Files\Cache\Cache->getId()
#8 /var/www/nextcloud/lib/private/Files/Cache/Scanner.php(391): OC\Files\Cache\Scanner->scanChildren()
#9 /var/www/nextcloud/lib/private/Files/Cache/Scanner.php(391): OC\Files\Cache\Scanner->scanChildren()
#10 /var/www/nextcloud/lib/private/Files/Cache/Scanner.php(340): OC\Files\Cache\Scanner->scanChildren()
#11 /var/www/nextcloud/lib/private/Files/Utils/Scanner.php(260): OC\Files\Cache\Scanner->scan()
#12 /var/www/nextcloud/apps/files/lib/Command/Scan.php(151): OC\Files\Utils\Scanner->scan()
#13 /var/www/nextcloud/apps/files/lib/Command/Scan.php(207): OCA\Files\Command\Scan->scanFiles()
#14 /var/www/nextcloud/3rdparty/symfony/console/Command/Command.php(255): OCA\Files\Command\Scan->execute()
#15 /var/www/nextcloud/core/Command/Base.php(169): Symfony\Component\Console\Command\Command->run()
#16 /var/www/nextcloud/3rdparty/symfony/console/Application.php(1012): OC\Core\Command\Base->run()
#17 /var/www/nextcloud/3rdparty/symfony/console/Application.php(272): Symfony\Component\Console\Application->doRunCommand()
#18 /var/www/nextcloud/3rdparty/symfony/console/Application.php(148): Symfony\Component\Console\Application->doRun()
#19 /var/www/nextcloud/lib/private/Console/Application.php(215): Symfony\Component\Console\Application->run()
#20 /var/www/nextcloud/console.php(100): OC\Console\Application->run()
#21 /var/www/nextcloud/occ(11): require_once('/var/www/nextcl...')
#22 {main}

another update: i’ve performed the upgrade to the 19.0.3, but the issue still persist, we can’t delete files stored in subfolders