nextcloud / nextcloud/server

[Bug]: Serialization failure: 1213 Deadlock error lead to a "conflict" the next time sync runs

Open
#34,697 11 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

0. Needs triage 27-feedback bug feature: database feature: dav feature: filesystem performance 🚀 technical debt
Dominant language
PHP
Stars
36.9k
Forks
5.2k
Avg merge
2d 3h
Merged PRs (30d)
713

Description

⚠️ 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.
  • Nextcloud Server is running on 64bit capable CPU, PHP and OS.
  • I agree to follow Nextcloud's Code of Conduct.
Bug description

Since all serialization-deadlock issues (like #22482 or #27904) are closed or blocked, preventing new comments, I need to open a new issue to add some information.

I've set up a new Nextcloud-instance and during the process of initial upload I run into lots of serialization-errors as described in the issues. The next time the sync runs I occasionally run into conflicts which should be impossible because - as mentioned - this is an initial upload of files from one client, so it's impossible that a second client uploaded a different version of a file at the same time. I don't have many measure points but it looks like the files on the server are always smaller than the local ones, giving me the impression that they are incomplete uploads not recognizes as such on the server side. The deadlock-messages are the only messages that happened during upload so I think these two issues might be related.

If that's the case, the view "nothing serious, the process just repeats the next time" isn't 100% correct because there seem to be cases where corrupt data resides on the server after such an error that might be downloaded by other clients before the fixing reupload starts.

Steps to reproduce

See reproducing steps in the other issues about this issue.

Expected behavior

An incomplete upload should be recognized by the server (if that's what's happening leading to the effect)

Installation method

Community Manual installation with Archive

Operating system

Debian/Ubuntu

PHP engine version

PHP 8.0

Web server

Apache (supported)

Database engine version

MariaDB

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

Fresh Nextcloud Server install

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
{
    "system": {
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "xxx.xxx.xxx.xxx"
        ],
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "mysql",
        "version": "24.0.6.1",
        "overwrite.cli.url": "http:\/\/xxx.xxx.xxx.xxx\/nextcloud",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "",
        "dbtableprefix": "oc_",
        "mysql.utf8mb4": true,
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true
    }
}
List of activated Apps
Enabled:
  - accessibility: 1.10.0
  - activity: 2.16.0
  - bruteforcesettings: 2.4.0
  - calendar: 3.5.0
  - circles: 24.0.1
  - cloud_federation_api: 1.7.0
  - comments: 1.14.0
  - contacts: 4.2.2
  - contactsinteraction: 1.5.0
  - dashboard: 7.4.0
  - dav: 1.22.0
  - federatedfilesharing: 1.14.0
  - federation: 1.14.0
  - files: 1.19.0
  - files_pdfviewer: 2.5.0
  - files_rightclick: 1.3.0
  - files_sharing: 1.16.2
  - files_trashbin: 1.14.0
  - files_versions: 1.17.0
  - files_videoplayer: 1.13.0
  - firstrunwizard: 2.13.0
  - logreader: 2.9.0
  - lookup_server_connector: 1.12.0
  - mail: 1.13.9
  - nextcloud_announcements: 1.13.0
  - notifications: 2.12.1
  - oauth2: 1.12.0
  - password_policy: 1.14.0
  - photos: 1.6.0
  - privacy: 1.8.0
  - provisioning_api: 1.14.0
  - recommendations: 1.3.0
  - richdocuments: 6.2.0
  - serverinfo: 1.14.0
  - settings: 1.6.0
  - sharebymail: 1.14.0
  - spreed: 14.0.5
  - support: 1.7.0
  - survey_client: 1.12.0
  - systemtags: 1.14.0
  - text: 3.5.1
  - theming: 1.15.0
  - twofactor_backupcodes: 1.13.0
  - updatenotification: 1.14.0
  - user_status: 1.4.0
  - viewer: 1.8.0
  - weather_status: 1.4.0
  - workflowengine: 2.6.0
Disabled:
  - admin_audit
  - encryption
  - files_external
  - user_ldap
Nextcloud Signing status
No errors have been found.
Nextcloud Logs
[webdav] Fatal: Doctrine\DBAL\Exception\DeadlockException: An exception occurred while executing a query: SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction at <<closure>>

 0. /var/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php line 1780
    Doctrine\DBAL\Driver\API\MySQL\ExceptionConverter->convert()
 1. /var/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php line 1719
    Doctrine\DBAL\Connection->handleDriverException()
 2. /var/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php line 1173
    Doctrine\DBAL\Connection->convertExceptionDuringQuery()
 3. /var/www/nextcloud/lib/private/DB/Connection.php line 294
    Doctrine\DBAL\Connection->executeStatement()
 4. /var/www/nextcloud/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php line 354
    OC\DB\Connection->executeStatement()
 5. /var/www/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php line 281
    Doctrine\DBAL\Query\QueryBuilder->execute()
 6. /var/www/nextcloud/lib/private/Files/Cache/Cache.php line 382
    OC\DB\QueryBuilder\QueryBuilder->execute()
 7. /var/www/nextcloud/lib/private/Files/Cache/Updater.php line 256
    OC\Files\Cache\Cache->update("*** sensitive parameters replaced ***")
 8. /var/www/nextcloud/lib/private/Files/Cache/Updater.php line 161
    OC\Files\Cache\Updater->correctParentStorageMtime()
 9. /var/www/nextcloud/lib/private/Files/View.php line 334
    OC\Files\Cache\Updater->remove()
10. /var/www/nextcloud/lib/private/Files/View.php line 1189
    OC\Files\View->removeUpdate()
11. /var/www/nextcloud/lib/private/Files/View.php line 355
    OC\Files\View->basicOperation()
12. /var/www/nextcloud/apps/dav/lib/Connector/Sabre/Directory.php line 318
    OC\Files\View->rmdir()
13. /var/www/nextcloud/apps/dav/lib/Upload/FutureFile.php line 100
    OCA\DAV\Connector\Sabre\Directory->delete()
14. /var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Tree.php line 164
    OCA\DAV\Upload\FutureFile->delete()
15. /var/www/nextcloud/apps/dav/lib/Upload/ChunkingPlugin.php line 94
    Sabre\DAV\Tree->move()
16. /var/www/nextcloud/apps/dav/lib/Upload/ChunkingPlugin.php line 76
    OCA\DAV\Upload\ChunkingPlugin->performMove()
17. /var/www/nextcloud/3rdparty/sabre/event/lib/WildcardEmitterTrait.php line 89
    OCA\DAV\Upload\ChunkingPlugin->beforeMove()
18. /var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/CorePlugin.php line 603
    Sabre\DAV\Server->emit()
19. /var/www/nextcloud/3rdparty/sabre/event/lib/WildcardEmitterTrait.php line 89
    Sabre\DAV\CorePlugin->httpMove()
20. /var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php line 472
    Sabre\DAV\Server->emit()
21. /var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php line 253
    Sabre\DAV\Server->invokeMethod()
22. /var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php line 321
    Sabre\DAV\Server->start()
23. /var/www/nextcloud/apps/dav/lib/Server.php line 358
    Sabre\DAV\Server->exec()
24. /var/www/nextcloud/apps/dav/appinfo/v2/remote.php line 35
    OCA\DAV\Server->exec()
25. /var/www/nextcloud/remote.php line 166
    require_once("/var/www/nextcl ... p")

MOVE /nextcloud/remote.php/dav/uploads/user/3066096469/.file
from 192.168.1.40 by user at 2022-10-20T09:38:06+00:00
Additional info

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with apps/dav/lib/Upload/ChunkingPlugin.php, apps/dav/lib/Upload/FutureFile.php, and lib/private/Files/Cache/Updater.php from the stack trace, then review issues #22482 and #27904. Reproduce the MariaDB deadlock during an upload and determine whether incomplete data remains server-side; done requires defined handling and regression coverage.

Written by the indexing model from the issue text.

Assessment

Tech stack
apache, mariadb, php
Domain
api, backend, databases
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.