Synchronisation failures after adding an S3 storage bucket to my Nextcloud

Support intro

I am getting a lot of synchronisation failures after adding an S3 storage bucket to my Nextcloud instance.

Many of the errors in the log seem to relate to PHP .
I will put a couple of examples below.

PHP Errors:

[no app in context] Error: OCP\Files\NotFoundException:  at <<closure>>

 0. /var/www/nextcloud/apps/files_versions/lib/Listener/FileEventsListener.php line 182
    OC\Files\Node\NonExistingFile->getId()
 1. /var/www/nextcloud/apps/files_versions/lib/Listener/FileEventsListener.php line 90
    OCA\Files_Versions\Listener\FileEventsListener->created("*** sensitive parameters replaced ***")
 2. /var/www/nextcloud/lib/private/EventDispatcher/ServiceEventListener.php line 86
    OCA\Files_Versions\Listener\FileEventsListener->handle()
 3. /var/www/nextcloud/3rdparty/symfony/event-dispatcher/EventDispatcher.php line 251
    OC\EventDispatcher\ServiceEventListener->__invoke()
 4. /var/www/nextcloud/3rdparty/symfony/event-dispatcher/EventDispatcher.php line 73
    Symfony\Component\EventDispatcher\EventDispatcher->callListeners()
 5. /var/www/nextcloud/lib/private/EventDispatcher/EventDispatcher.php line 87
    Symfony\Component\EventDispatcher\EventDispatcher->dispatch()
 6. /var/www/nextcloud/lib/private/EventDispatcher/EventDispatcher.php line 99
    OC\EventDispatcher\EventDispatcher->dispatch()
 7. /var/www/nextcloud/lib/private/Files/Node/HookConnector.php line 139
    OC\EventDispatcher\EventDispatcher->dispatchTyped()
 8. /var/www/nextcloud/lib/private/legacy/OC_Hook.php line 105
    OC\Files\Node\HookConnector->postCreate()
 9. /var/www/nextcloud/apps/dav/lib/Connector/Sabre/File.php line 465
    OC_Hook::emit()
10. /var/www/nextcloud/apps/dav/lib/Connector/Sabre/File.php line 398
    OCA\DAV\Connector\Sabre\File->emitPostHooks()
11. /var/www/nextcloud/apps/dav/lib/Connector/Sabre/Directory.php line 149
    OCA\DAV\Connector\Sabre\File->put()
12. /var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php line 1098
    OCA\DAV\Connector\Sabre\Directory->createFile("*** sensitive parameters replaced ***")
13. /var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/CorePlugin.php line 504
    Sabre\DAV\Server->createFile("*** sensitive parameters replaced ***")
14. /var/www/nextcloud/3rdparty/sabre/event/lib/WildcardEmitterTrait.php line 89
    Sabre\DAV\CorePlugin->httpPut()
15. /var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php line 472
    Sabre\DAV\Server->emit()
16. /var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php line 253
    Sabre\DAV\Server->invokeMethod()
17. /var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php line 321
    Sabre\DAV\Server->start()
18. /var/www/nextcloud/apps/dav/lib/Server.php line 366
    Sabre\DAV\Server->exec()
19. /var/www/nextcloud/apps/dav/appinfo/v2/remote.php line 35
    OCA\DAV\Server->exec()
20. /var/www/nextcloud/remote.php line 172
    require_once("/var/www/nextcl ... p")

PUT /remote.php/dav/files/****/********.docx
from XXX.XXX.XXX.XXX by *** at 2023-10-18T08:07:46+00:00

Nextcloud version : 26.0.2 - 26.0.2.1
Operating system and version: Linux 5.15.0-86-generic #96-Ubuntu SMP Wed Sep 20 08:23:49 UTC 2023 x86_64
Apache or nginx version: Apache/2.4.52 (Ubuntu) (apache2handler)
PHP version (eg, 7.4): 8.1.2-1ubuntu2.14

The issue you are facing: Hundred of my files will not sync

Is this the first time you’ve seen this error? (Y/N): Yes

The output of your Nextcloud log in Admin > Logging:

Error	PHP	Allowed memory size of 134217728 bytes exhausted (tried to allocate 98566176 bytes) at /var/www/nextcloud/3rdparty/guzzlehttp/psr7/src/Stream.php#254		2023-10-18T09:59:17+0100
Error	webdav	Sabre\DAV\Exception: Failed to get fileinfo for /Bucket/Couture Digital/21 Eaton Mews South.zip		2023-10-18T09:58:11+0100
Error	no app in context	OCP\Files\NotFoundException: 		2023-10-18T09:58:11+0100
Error	no app in context	OCP\Files\NotFoundException: 		2023-10-18T09:58:11+0100
Error	PHP	Undefined array key "mimetype" at /var/www/nextcloud/lib/private/Files/Cache/Watcher.php#116		2023-10-18T09:58:11+0100
Error	PHP	Undefined array key "storage_mtime" at /var/www/nextcloud/lib/private/Files/Cache/Watcher.php#134		2023-10-18T09:58:11+0100
Error	files_external	Aws\S3\Exception\S3Exception: Error executing "PutObject" on "https://storage.nl-ams-1.linodeobjects.com/Couture%20Digital/21%20Eaton%20Mews%20South.zip"; AWS HTTP error: Client error: `PUT https://storage.nl-ams-1.linodeobjects.com/Couture%20Digital/21%20Eaton%20Mews%20South.zip` resulted in a `400 Bad Request` response: <?xml version="1.0" encoding="UTF-8"?><Error><Code>InvalidArgument</Code><BucketName>storage</BucketName><RequestId>tx00 (truncated...) InvalidArgument (client): - <?xml version="1.0" encoding="UTF-8"?><Error><Code>InvalidArgument</Code><BucketName>storage</BucketName><RequestId>tx00000b488f9a7475ba74a-00652f9e23-35b251-default</RequestId><HostId>35b251-default-default</HostId></Error>		2023-10-18T09:58:11+0100
Error	PHP	Allowed memory size of 134217728 bytes exhausted (tried to allocate 81788960 bytes) at /var/www/nextcloud/3rdparty/guzzlehttp/psr7/src/Stream.php#254		2023-10-18T09:58:11+0100
Error	webdav	Sabre\DAV\Exception: Failed to get fileinfo for /Bucket/Couture Digital/Lethbridge Audit.tar.xz		2023-10-18T09:56:22+0100
Error	no app in context	OCP\Files\NotFoundException: 		2023-10-18T09:56:22+0100
Error	no app in context	OCP\Files\NotFoundException: 		2023-10-18T09:56:22+0100
Error	PHP	Undefined array key "mimetype" at /var/www/nextcloud/lib/private/Files/Cache/Watcher.php#116		2023-10-18T09:56:22+0100
Error	PHP	Undefined array key "storage_mtime" at /var/www/nextcloud/lib/private/Files/Cache/Watcher.php#134		2023-10-18T09:56:22+0100
Error	files_external	Aws\S3\Exception\S3Exception: Error executing "PutObject" on "https://storage.nl-ams-1.linodeobjects.com/Couture%20Digital/Lethbridge%20Audit.tar.xz"; AWS HTTP error: Client error: `PUT https://storage.nl-ams-1.linodeobjects.com/Couture%20Digital/Lethbridge%20Audit.tar.xz` resulted in a `400 Bad Request` response: <?xml version="1.0" encoding="UTF-8"?><Error><Code>InvalidArgument</Code><BucketName>storage</BucketName><RequestId>tx00 (truncated...) InvalidArgument (client): - <?xml version="1.0" encoding="UTF-8"?><Error><Code>InvalidArgument</Code><BucketName>storage</BucketName><RequestId>tx000000ca59f6de875ae6b-00652f9db6-35b21a-default</RequestId><HostId>35b21a-default-default</HostId></Error>		2023-10-18T09:56:22+0100
Error	webdav	Sabre\DAV\Exception: Failed to get fileinfo for /Bucket/Couture Digital/21 Eaton Mews South.zip		2023-10-18T09:56:10+0100
Error	no app in context	OCP\Files\NotFoundException: 		2023-10-18T09:56:10+0100
Error	no app in context	OCP\Files\NotFoundException: 		2023-10-18T09:56:10+0100
Error	PHP	Undefined array key "mimetype" at /var/www/nextcloud/lib/private/Files/Cache/Watcher.php#116		2023-10-18T09:56:10+0100
Error	PHP	Undefined array key "storage_mtime" at /var/www/nextcloud/lib/private/Files/Cache/Watcher.php#134		2023-10-18T09:56:10+0100
Error	files_external	Aws\S3\Exception\S3Exception: Error executing "PutObject" on "https://storage.nl-ams-1.linodeobjects.com/Couture%20Digital/21%20Eaton%20Mews%20South.zip"; AWS HTTP error: Client error: `PUT https://storage.nl-ams-1.linodeobjects.com/Couture%20Digital/21%20Eaton%20Mews%20South.zip` resulted in a `400 Bad Request` response: <?xml version="1.0" encoding="UTF-8"?><Error><Code>InvalidArgument</Code><BucketName>storage</BucketName><RequestId>tx00 (truncated...) InvalidArgument (client): - <?xml version="1.0" encoding="UTF-8"?><Error><Code>InvalidArgument</Code><BucketName>storage</BucketName><RequestId>tx000003dbbf76507eef4d0-00652f9daa-3523cd-default</RequestId><HostId>3523cd-default-default</HostId></Error>		2023-10-18T09:56:10+0100
Error	PHP	Allowed memory size of 134217728 bytes exhausted (tried to allocate 65011744 bytes) at /var/www/nextcloud/3rdparty/guzzlehttp/psr7/src/Stream.php#254		2023-10-18T09:54:53+0100
Error	webdav	OC\DB\Exceptions\DbalException: An exception occurred while executing a query: SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction		2023-10-18T09:52:52+0100
Error	webdav	Sabre\DAV\Exception: Failed to get fileinfo for /Bucket/Couture Digital/21 Eaton Mews South.zip		2023-10-18T09:52:51+0100
Error	no app in context	OCP\Files\NotFoundException: 		2023-10-18T09:52:51+0100
Error	no app in context	OCP\Files\NotFoundException: 		2023-10-18T09:52:51+0100
Error	PHP	Undefined array key "mimetype" at /var/www/nextcloud/lib/private/Files/Cache/Watcher.php#116		2023-10-18T09:52:51+0100
Error	PHP	Undefined array key "storage_mtime" at /var/www/nextcloud/lib/private/Files/Cache/Watcher.php#134		2023-10-18T09:52:51+0100
Error	files_external	Aws\S3\Exception\S3Exception: Error executing "PutObject" on "https://storage.nl-ams-1.linodeobjects.com/Couture%20Digital/21%20Eaton%20Mews%20South.zip"; AWS HTTP error: Client error: `PUT https://storage.nl-ams-1.linodeobjects.com/Couture%20Digital/21%20Eaton%20Mews%20South.zip` resulted in a `400 Bad Request` response: <?xml version="1.0" encoding="UTF-8"?><Error><Code>InvalidArgument</Code><BucketName>storage</BucketName><RequestId>tx00 (truncated...) InvalidArgument (client): - <?xml version="1.0" encoding="UTF-8"?><Error><Code>InvalidArgument</Code><BucketName>storage</BucketName><RequestId>tx00000c64529c734624462-00652f9ce3-35b16b-default</RequestId><HostId>35b16b-default-default</HostId></Error>		2023-10-18T09:52:51+0100
Error	PHP	Allowed memory size of 134217728 bytes exhausted (tried to allocate 65011744 bytes) at /var/www/nextcloud/3rdparty/guzzlehttp/psr7/src/Stream.php#254		2023-10-18T09:52:51+0100
Error	PHP	Allowed memory size of 134217728 bytes exhausted (tried to allocate 98566176 bytes) at /var/www/nextcloud/3rdparty/guzzlehttp/psr7/src/Stream.php#254		2023-10-18T09:51:44+0100
Error	webdav	Sabre\DAV\Exception: Failed to get fileinfo for /Bucket/Couture Digital/Lethbridge Audit.tar.xz		2023-10-18T09:51:07+0100
Error	no app in context	OCP\Files\NotFoundException: 		2023-10-18T09:51:07+0100
Error	no app in context	OCP\Files\NotFoundException: 		2023-10-18T09:51:07+0100
Error	PHP	Undefined array key "mimetype" at /var/www/nextcloud/lib/private/Files/Cache/Watcher.php#116		2023-10-18T09:51:07+0100
Error	PHP	Undefined array key "storage_mtime" at /var/www/nextcloud/lib/private/Files/Cache/Watcher.php#134		2023-10-18T09:51:07+0100
Error	files_external	Aws\S3\Exception\S3Exception: Error executing "PutObject" on "https://storage.nl-ams-1.linodeobjects.com/Couture%20Digital/Lethbridge%20Audit.tar.xz"; AWS HTTP error: Client error: `PUT https://storage.nl-ams-1.linodeobjects.com/Couture%20Digital/Lethbridge%20Audit.tar.xz` resulted in a `400 Bad Request` response: <?xml version="1.0" encoding="UTF-8"?><Error><Code>InvalidArgument</Code><BucketName>storage</BucketName><RequestId>tx00 (truncated...) InvalidArgument (client): - <?xml version="1.0" encoding="UTF-8"?><Error><Code>InvalidArgument</Code><BucketName>storage</BucketName><RequestId>tx0000072280af0fd2e3a00-00652f9c7b-3523eb-default</RequestId><HostId>3523eb-default-default</HostId></Error>		2023-10-18T09:51:07+0100
Error	webdav	Sabre\DAV\Exception: Failed to get fileinfo for /Bucket/Couture Digital/21 Eaton Mews South.zip		2023-10-18T09:50:59+0100
Error	no app in context	OCP\Files\NotFoundException: 		2023-10-18T09:50:59+0100
Error	no app in context	OCP\Files\NotFoundException: 		2023-10-18T09:50:59+0100
Error	PHP	Undefined array key "mimetype" at /var/www/nextcloud/lib/private/Files/Cache/Watcher.php#116		2023-10-18T09:50:59+0100
Error	PHP	Undefined array key "storage_mtime" at /var/www/nextcloud/lib/private/Files/Cache/Watcher.php#134		2023-10-18T09:50:59+0100
Error	files_external	Aws\S3\Exception\S3Exception: Error executing "PutObject" on "https://storage.nl-ams-1.linodeobjects.com/Couture%20Digital/21%20Eaton%20Mews%20South.zip"; AWS HTTP error: Client error: `PUT https://storage.nl-ams-1.linodeobjects.com/Couture%20Digital/21%20Eaton%20Mews%20South.zip` resulted in a `400 Bad Request` response: <?xml version="1.0" encoding="UTF-8"?><Error><Code>InvalidArgument</Code><BucketName>storage</BucketName><RequestId>tx00 (truncated...) InvalidArgument (client): - <?xml version="1.0" encoding="UTF-8"?><Error><Code>InvalidArgument</Code><BucketName>storage</BucketName><RequestId>tx00000f54b8e061187ed7a-00652f9c73-3523eb-default</RequestId><HostId>3523eb-default-default</HostId></Error>

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

I need some help locating this :)

I have a huge file called nextcloud.error in my /var/log/apache2 folder. Here is an example of an error from that file:

[Fri Jul 14 10:01:51.436727 2023] [php:error] [pid 481697] [client 216.131.116.45:40687] PHP Fatal error:  Uncaught Doctrine\\DBAL\\Exception: Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [2002] Connection refused in /var/www/nextcloud/lib/private/DB/Connection.php:140\nStack trace:\n#0 /var/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php(1531): OC\\DB\\Connection->connect()\n#1 /var/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php(813): Doctrine\\DBAL\\Connection->getWrappedConnection()\n#2 /var/www/nextcloud/3rdparty/doctrine/dbal/src/Query/Expression/ExpressionBuilder.php(323): Doctrine\\DBAL\\Connection->quote()\n#3 /var/www/nextcloud/lib/private/DB/QueryBuilder/ExpressionBuilder/ExpressionBuilder.php(422): Doctrine\\DBAL\\Query\\Expression\\ExpressionBuilder->literal()\n#4 /var/www/nextcloud/lib/private/Lock/DBLockingProvider.php(258): OC\\DB\\QueryBuilder\\ExpressionBuilder\\ExpressionBuilder->literal()\n#5 [internal function]: OC\\Lock\\DBLockingProvider->releaseAll()\n#6 {main}\n  thrown in /var/www/nextcloud/lib/private/DB/Connection.php on line 140

Try searching for generic sections of errors you are seeing in your log. Things like:

https://help.nextcloud.com/search?q=PHP%09Allowed%20memory%20size%20of%20134217728%20bytes%20exhausted

https://help.nextcloud.com/search?q=thrown%20in%20%2Fvar%2Fwww%2Fnextcloud%2Flib%2Fprivate%2FDB%2FConnection.php