server icon indicating copy to clipboard operation
server copied to clipboard

Bulk Upload - Deadlock found when trying to get lock

Open apg1980 opened this issue 3 years ago • 29 comments

  • Mariadb 10.5.13
  • Php 8.0.13
  • Apache
  • ubuntu 20.04 lts
{
  "reqId": "57SS2UgAK0IhKBiUN97i",
  "level": 3,
  "time": "2021-11-30T14:44:25+01:00",
  "remoteAddr": "------",
  "user": "---",
  "app": "no app in context",
  "method": "POST",
  "url": "/remote.php/dav/bulk",
  "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 (Windows) mirall/3.4.0stable-Win64 (build 20211129) (Nextcloud, windows-10.0.22000 ClientArchitecture: x86_64 OsArchitecture: x86_64)",
  "version": "23.0.0.10",
  "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": "->"
      },
      {
        "file": "/var/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php",
        "line": 1719,
        "function": "handleDriverException",
        "class": "Doctrine\\DBAL\\Connection",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php",
        "line": 1173,
        "function": "convertExceptionDuringQuery",
        "class": "Doctrine\\DBAL\\Connection",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/lib/private/DB/Connection.php",
        "line": 267,
        "function": "executeStatement",
        "class": "Doctrine\\DBAL\\Connection",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php",
        "line": 354,
        "function": "executeStatement",
        "class": "OC\\DB\\Connection",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php",
        "line": 287,
        "function": "execute",
        "class": "Doctrine\\DBAL\\Query\\QueryBuilder",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/lib/private/Files/Cache/Cache.php",
        "line": 379,
        "function": "execute",
        "class": "OC\\DB\\QueryBuilder\\QueryBuilder",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/lib/private/Files/Cache/Wrapper/CacheWrapper.php",
        "line": 145,
        "function": "update",
        "class": "OC\\Files\\Cache\\Cache",
        "type": "->",
        "args": [
          "*** sensitive parameters replaced ***"
        ]
      },
      {
        "file": "/var/www/nextcloud/lib/private/Files/Cache/Wrapper/CacheWrapper.php",
        "line": 145,
        "function": "update",
        "class": "OC\\Files\\Cache\\Wrapper\\CacheWrapper",
        "type": "->",
        "args": [
          "*** sensitive parameters replaced ***"
        ]
      },
      {
        "file": "/var/www/nextcloud/lib/private/Files/Cache/Updater.php",
        "line": 256,
        "function": "update",
        "class": "OC\\Files\\Cache\\Wrapper\\CacheWrapper",
        "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": "->"
      },
      {
        "file": "/var/www/nextcloud/lib/private/Files/View.php",
        "line": 323,
        "function": "update",
        "class": "OC\\Files\\Cache\\Updater",
        "type": "->",
        "args": [
          "*** sensitive parameters replaced ***"
        ]
      },
      {
        "file": "/var/www/nextcloud/lib/private/Files/View.php",
        "line": 943,
        "function": "writeUpdate",
        "class": "OC\\Files\\View",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/apps/files_versions/lib/Versions/LegacyVersionsBackend.php",
        "line": 93,
        "function": "copy",
        "class": "OC\\Files\\View",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/apps/files_versions/lib/Versions/VersionManager.php",
        "line": 92,
        "function": "createVersion",
        "class": "OCA\\Files_Versions\\Versions\\LegacyVersionsBackend",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/apps/files_versions/lib/Storage.php",
        "line": 217,
        "function": "createVersion",
        "class": "OCA\\Files_Versions\\Versions\\VersionManager",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/apps/files_versions/lib/Hooks.php",
        "line": 56,
        "function": "store",
        "class": "OCA\\Files_Versions\\Storage",
        "type": "::"
      },
      {
        "file": "/var/www/nextcloud/lib/private/legacy/OC_Hook.php",
        "line": 106,
        "function": "write_hook",
        "class": "OCA\\Files_Versions\\Hooks",
        "type": "::"
      },
      {
        "file": "/var/www/nextcloud/lib/private/Files/View.php",
        "line": 1284,
        "function": "emit",
        "class": "OC_Hook",
        "type": "::"
      },
      {
        "file": "/var/www/nextcloud/lib/private/Files/View.php",
        "line": 1154,
        "function": "runHooks",
        "class": "OC\\Files\\View",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/lib/private/Files/View.php",
        "line": 706,
        "function": "basicOperation",
        "class": "OC\\Files\\View",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/lib/private/Files/Node/Folder.php",
        "line": 198,
        "function": "file_put_contents",
        "class": "OC\\Files\\View",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/apps/dav/lib/BulkUpload/BulkUploadPlugin.php",
        "line": 81,
        "function": "newFile",
        "class": "OC\\Files\\Node\\Folder",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/3rdparty/sabre/event/lib/WildcardEmitterTrait.php",
        "line": 89,
        "function": "httpPost",
        "class": "OCA\\DAV\\BulkUpload\\BulkUploadPlugin",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php",
        "line": 472,
        "function": "emit",
        "class": "Sabre\\DAV\\Server",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php",
        "line": 253,
        "function": "invokeMethod",
        "class": "Sabre\\DAV\\Server",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php",
        "line": 321,
        "function": "start",
        "class": "Sabre\\DAV\\Server",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/apps/dav/lib/Server.php",
        "line": 339,
        "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": 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": "::"
        },
        {
          "file": "/var/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php",
          "line": 1163,
          "function": "execute",
          "class": "Doctrine\\DBAL\\Driver\\PDO\\Statement",
          "type": "->"
        },
        {
          "file": "/var/www/nextcloud/lib/private/DB/Connection.php",
          "line": 267,
          "function": "executeStatement",
          "class": "Doctrine\\DBAL\\Connection",
          "type": "->"
        },
        {
          "file": "/var/www/nextcloud/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php",
          "line": 354,
          "function": "executeStatement",
          "class": "OC\\DB\\Connection",
          "type": "->"
        },
        {
          "file": "/var/www/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php",
          "line": 287,
          "function": "execute",
          "class": "Doctrine\\DBAL\\Query\\QueryBuilder",
          "type": "->"
        },
        {
          "file": "/var/www/nextcloud/lib/private/Files/Cache/Cache.php",
          "line": 379,
          "function": "execute",
          "class": "OC\\DB\\QueryBuilder\\QueryBuilder",
          "type": "->"
        },
        {
          "file": "/var/www/nextcloud/lib/private/Files/Cache/Wrapper/CacheWrapper.php",
          "line": 145,
          "function": "update",
          "class": "OC\\Files\\Cache\\Cache",
          "type": "->",
          "args": [
            "*** sensitive parameters replaced ***"
          ]
        },
        {
          "file": "/var/www/nextcloud/lib/private/Files/Cache/Wrapper/CacheWrapper.php",
          "line": 145,
          "function": "update",
          "class": "OC\\Files\\Cache\\Wrapper\\CacheWrapper",
          "type": "->",
          "args": [
            "*** sensitive parameters replaced ***"
          ]
        },
        {
          "file": "/var/www/nextcloud/lib/private/Files/Cache/Updater.php",
          "line": 256,
          "function": "update",
          "class": "OC\\Files\\Cache\\Wrapper\\CacheWrapper",
          "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": "->"
        },
        {
          "file": "/var/www/nextcloud/lib/private/Files/View.php",
          "line": 323,
          "function": "update",
          "class": "OC\\Files\\Cache\\Updater",
          "type": "->",
          "args": [
            "*** sensitive parameters replaced ***"
          ]
        },
        {
          "file": "/var/www/nextcloud/lib/private/Files/View.php",
          "line": 943,
          "function": "writeUpdate",
          "class": "OC\\Files\\View",
          "type": "->"
        },
        {
          "file": "/var/www/nextcloud/apps/files_versions/lib/Versions/LegacyVersionsBackend.php",
          "line": 93,
          "function": "copy",
          "class": "OC\\Files\\View",
          "type": "->"
        },
        {
          "file": "/var/www/nextcloud/apps/files_versions/lib/Versions/VersionManager.php",
          "line": 92,
          "function": "createVersion",
          "class": "OCA\\Files_Versions\\Versions\\LegacyVersionsBackend",
          "type": "->"
        },
        {
          "file": "/var/www/nextcloud/apps/files_versions/lib/Storage.php",
          "line": 217,
          "function": "createVersion",
          "class": "OCA\\Files_Versions\\Versions\\VersionManager",
          "type": "->"
        },
        {
          "file": "/var/www/nextcloud/apps/files_versions/lib/Hooks.php",
          "line": 56,
          "function": "store",
          "class": "OCA\\Files_Versions\\Storage",
          "type": "::"
        },
        {
          "file": "/var/www/nextcloud/lib/private/legacy/OC_Hook.php",
          "line": 106,
          "function": "write_hook",
          "class": "OCA\\Files_Versions\\Hooks",
          "type": "::"
        },
        {
          "file": "/var/www/nextcloud/lib/private/Files/View.php",
          "line": 1284,
          "function": "emit",
          "class": "OC_Hook",
          "type": "::"
        },
        {
          "file": "/var/www/nextcloud/lib/private/Files/View.php",
          "line": 1154,
          "function": "runHooks",
          "class": "OC\\Files\\View",
          "type": "->"
        },
        {
          "file": "/var/www/nextcloud/lib/private/Files/View.php",
          "line": 706,
          "function": "basicOperation",
          "class": "OC\\Files\\View",
          "type": "->"
        },
        {
          "file": "/var/www/nextcloud/lib/private/Files/Node/Folder.php",
          "line": 198,
          "function": "file_put_contents",
          "class": "OC\\Files\\View",
          "type": "->"
        },
        {
          "file": "/var/www/nextcloud/apps/dav/lib/BulkUpload/BulkUploadPlugin.php",
          "line": 81,
          "function": "newFile",
          "class": "OC\\Files\\Node\\Folder",
          "type": "->"
        },
        {
          "file": "/var/www/nextcloud/3rdparty/sabre/event/lib/WildcardEmitterTrait.php",
          "line": 89,
          "function": "httpPost",
          "class": "OCA\\DAV\\BulkUpload\\BulkUploadPlugin",
          "type": "->"
        },
        {
          "file": "/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php",
          "line": 472,
          "function": "emit",
          "class": "Sabre\\DAV\\Server",
          "type": "->"
        },
        {
          "file": "/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php",
          "line": 253,
          "function": "invokeMethod",
          "class": "Sabre\\DAV\\Server",
          "type": "->"
        },
        {
          "file": "/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php",
          "line": 321,
          "function": "start",
          "class": "Sabre\\DAV\\Server",
          "type": "->"
        },
        {
          "file": "/var/www/nextcloud/apps/dav/lib/Server.php",
          "line": 339,
          "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": 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": "->"
          },
          {
            "file": "/var/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php",
            "line": 1163,
            "function": "execute",
            "class": "Doctrine\\DBAL\\Driver\\PDO\\Statement",
            "type": "->"
          },
          {
            "file": "/var/www/nextcloud/lib/private/DB/Connection.php",
            "line": 267,
            "function": "executeStatement",
            "class": "Doctrine\\DBAL\\Connection",
            "type": "->"
          },
          {
            "file": "/var/www/nextcloud/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php",
            "line": 354,
            "function": "executeStatement",
            "class": "OC\\DB\\Connection",
            "type": "->"
          },
          {
            "file": "/var/www/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php",
            "line": 287,
            "function": "execute",
            "class": "Doctrine\\DBAL\\Query\\QueryBuilder",
            "type": "->"
          },
          {
            "file": "/var/www/nextcloud/lib/private/Files/Cache/Cache.php",
            "line": 379,
            "function": "execute",
            "class": "OC\\DB\\QueryBuilder\\QueryBuilder",
            "type": "->"
          },
          {
            "file": "/var/www/nextcloud/lib/private/Files/Cache/Wrapper/CacheWrapper.php",
            "line": 145,
            "function": "update",
            "class": "OC\\Files\\Cache\\Cache",
            "type": "->",
            "args": [
              "*** sensitive parameters replaced ***"
            ]
          },
          {
            "file": "/var/www/nextcloud/lib/private/Files/Cache/Wrapper/CacheWrapper.php",
            "line": 145,
            "function": "update",
            "class": "OC\\Files\\Cache\\Wrapper\\CacheWrapper",
            "type": "->",
            "args": [
              "*** sensitive parameters replaced ***"
            ]
          },
          {
            "file": "/var/www/nextcloud/lib/private/Files/Cache/Updater.php",
            "line": 256,
            "function": "update",
            "class": "OC\\Files\\Cache\\Wrapper\\CacheWrapper",
            "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": "->"
          },
          {
            "file": "/var/www/nextcloud/lib/private/Files/View.php",
            "line": 323,
            "function": "update",
            "class": "OC\\Files\\Cache\\Updater",
            "type": "->",
            "args": [
              "*** sensitive parameters replaced ***"
            ]
          },
          {
            "file": "/var/www/nextcloud/lib/private/Files/View.php",
            "line": 943,
            "function": "writeUpdate",
            "class": "OC\\Files\\View",
            "type": "->"
          },
          {
            "file": "/var/www/nextcloud/apps/files_versions/lib/Versions/LegacyVersionsBackend.php",
            "line": 93,
            "function": "copy",
            "class": "OC\\Files\\View",
            "type": "->"
          },
          {
            "file": "/var/www/nextcloud/apps/files_versions/lib/Versions/VersionManager.php",
            "line": 92,
            "function": "createVersion",
            "class": "OCA\\Files_Versions\\Versions\\LegacyVersionsBackend",
            "type": "->"
          },
          {
            "file": "/var/www/nextcloud/apps/files_versions/lib/Storage.php",
            "line": 217,
            "function": "createVersion",
            "class": "OCA\\Files_Versions\\Versions\\VersionManager",
            "type": "->"
          },
          {
            "file": "/var/www/nextcloud/apps/files_versions/lib/Hooks.php",
            "line": 56,
            "function": "store",
            "class": "OCA\\Files_Versions\\Storage",
            "type": "::"
          },
          {
            "file": "/var/www/nextcloud/lib/private/legacy/OC_Hook.php",
            "line": 106,
            "function": "write_hook",
            "class": "OCA\\Files_Versions\\Hooks",
            "type": "::"
          },
          {
            "file": "/var/www/nextcloud/lib/private/Files/View.php",
            "line": 1284,
            "function": "emit",
            "class": "OC_Hook",
            "type": "::"
          },
          {
            "file": "/var/www/nextcloud/lib/private/Files/View.php",
            "line": 1154,
            "function": "runHooks",
            "class": "OC\\Files\\View",
            "type": "->"
          },
          {
            "file": "/var/www/nextcloud/lib/private/Files/View.php",
            "line": 706,
            "function": "basicOperation",
            "class": "OC\\Files\\View",
            "type": "->"
          },
          {
            "file": "/var/www/nextcloud/lib/private/Files/Node/Folder.php",
            "line": 198,
            "function": "file_put_contents",
            "class": "OC\\Files\\View",
            "type": "->"
          },
          {
            "file": "/var/www/nextcloud/apps/dav/lib/BulkUpload/BulkUploadPlugin.php",
            "line": 81,
            "function": "newFile",
            "class": "OC\\Files\\Node\\Folder",
            "type": "->"
          },
          {
            "file": "/var/www/nextcloud/3rdparty/sabre/event/lib/WildcardEmitterTrait.php",
            "line": 89,
            "function": "httpPost",
            "class": "OCA\\DAV\\BulkUpload\\BulkUploadPlugin",
            "type": "->"
          },
          {
            "file": "/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php",
            "line": 472,
            "function": "emit",
            "class": "Sabre\\DAV\\Server",
            "type": "->"
          },
          {
            "file": "/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php",
            "line": 253,
            "function": "invokeMethod",
            "class": "Sabre\\DAV\\Server",
            "type": "->"
          },
          {
            "file": "/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php",
            "line": 321,
            "function": "start",
            "class": "Sabre\\DAV\\Server",
            "type": "->"
          },
          {
            "file": "/var/www/nextcloud/apps/dav/lib/Server.php",
            "line": 339,
            "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": 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": "61a636a484de3"
}

apg1980 avatar Nov 30 '21 14:11 apg1980

seems like also a bulkupload issue...

szaimen avatar Nov 30 '21 14:11 szaimen

cc @artonge @nextcloud/desktop

szaimen avatar Nov 30 '21 14:11 szaimen

This Problem is neither limited to NC23 nor to bulkupload. I had the same issue about 20 times in the last 6 month. Sometimes it was a Single File Upload, sometimes a File or Directory Move, sometimes a Deletion.

My Setup: Ubuntu 20.04 LTS HWE PHP 7.4.3 + OPcache Apache 2.4.51 MariaDB 10.4.22

The Error seems related to https://github.com/nextcloud/server/issues/6899

Greetings

KaeTuuN avatar Dec 01 '21 11:12 KaeTuuN

I confirm the issue:

"An exception occurred while executing a query: SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction"

Nextcloud 23, fresh install, dedicated server, PHP 8.0, MariaDB 10.5.12, under Debian 11.

ArvyRogerio avatar Dec 13 '21 13:12 ArvyRogerio

Why was this closed, the issue being referred #29987 is referring to this issue. I am still having this issue

KRSogaard avatar Jan 23 '22 19:01 KRSogaard

I also had this exact same issue and decided to make some re-installations and tests. Since I have a NAS at home I decided to keep all files on the NAS but running NextCloud on a separate server (Proxmox). Mounting the NFS share on the Nextcloud server works fine.

The problems started to occur for me when also hosting the database (both postgres and mariadb) on the NAS, and accessing it over the network by IP in Nextcloud. When I changed to a locally installed database on the nextcloud server itself and accessing it over the socket everything works flawlessly. Could it be network speeds or just that the DB is externally accessed? LAN speed it 1000/1000 in my tests.

I also tried with and without Redis as cache but that didn't change anything. I've been running nextcloud with a local database for several weeks now without any problems.

samuelsson avatar Jan 23 '22 20:01 samuelsson

Yes, had deadlocks here too. They were corresponding to the query: UPDATE oc_filecache SET mtime = ?, storage_mtime = ? WHERE (fileid = ?) AND (((mtime <> ?) OR (mtime IS NULL)) OR ((storage_mtime <> ?) OR (storage_mtime IS NULL)))

This does not look like a very complex statement, so its up to mariadb to get this going. I also have not found bad behaviour of NC or php with that (deadlocks before made it impossible to sync, as it always restarted to sync and always ran into that deadlock).

I changed mariadb- config to use fsync instead of direct writes (https://mariadb.com/docs/reference/mdb/system-variables/innodb_flush_method/), than upped the Version of mariadb to 10.6.5 now there had been no deadlock any more since some days, but my system is currently not on heavy load.

Maybe check your config and temporary tables by using mysqltuner.pl and your slow.log to eleminate bottlenecks for your db, it may help to reduce deadlocks when the db performs good in general

obel1x avatar Mar 02 '22 19:03 obel1x

Still an issue on NC 23.0.2

AndyXheli avatar Mar 22 '22 13:03 AndyXheli

Still an issue on NC 23.0.3

danieltuzes avatar Apr 06 '22 21:04 danieltuzes

ok, still a problem here too. Can you check in the logs, if this is related to the "update oc_filecache" as it is for me? This time it was: "args":["UPDATE oc_filecache SET size = :dcValue3 WHERE (fileid = :dcValue1) AND ((size <> :dcValue2) OR (size IS NULL))",{"dcValue1":"*** sensitive parameter replaced ***","dcValue2":282256502,"dcValue3":282256502},{"dcValue1":1,"dcValue2":2,"dcValue3":2}]}

It was caused when deleting multiple files in a directory and when recalculationg the directory size, which seems to do it recursivly (scanning all upper folders) by function move2trash of "class":"OCA\Files_Trashbin\Trashbin".

The way this is done looks like the calculation of directory sizes is not synchronised by nexcloud, so it would not suprise me if the next deletion would cause deadlocks in that table for the entry - which may not be bad as such, but may lead to wrong data.

Maybe some approach to nextcloud for this: synchronise filecache- operations...

obel1x avatar Apr 15 '22 08:04 obel1x

My log from the web interface is:

{
   "reqId":"0P4cP8wjXhtwyT1Ktb0n",
   "level":4,
   "time":"2022-04-14T22:16:55+00:00",
   "remoteAddr":"172.19.0.1",
   "user":"tuzes",
   "app":"webdav",
   "method":"PUT",
   "url":"/remote.php/dav/files/tuzes/kamera/r%C3%A9gi%20k%C3%A9pt%C3%A1r/%C3%9Cnnepi/temet%C3%A9s/nagypapa/K%C3%A9p%20045.jpg",
   "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 (Windows) mirall/3.4.4stable-Win64 (build 20220318) (Nextcloud, windows-10.0.19044 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/html/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/html/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/html/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)))",
               [
                  1649974615,
                  1649974615,
                  "*** sensitive parameter replaced ***",
                  1649974615,
                  1649974615
               ],
               [
                  2,
                  2,
                  1,
                  2,
                  2
               ]
            ]
         },
         {
            "file":"/var/www/html/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)))",
               [
                  1649974615,
                  1649974615,
                  "*** sensitive parameter replaced ***",
                  1649974615,
                  1649974615
               ],
               [
                  2,
                  2,
                  1,
                  2,
                  2
               ]
            ]
         },
         {
            "file":"/var/www/html/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":1649974615,
                  "dcValue3":1649974615,
                  "dcValue4":1649974615,
                  "dcValue5":1649974615
               },
               {
                  "dcValue1":1,
                  "dcValue2":2,
                  "dcValue3":2,
                  "dcValue4":2,
                  "dcValue5":2
               }
            ]
         },
         {
            "file":"/var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php",
            "line":287,
            "function":"execute",
            "class":"Doctrine\\DBAL\\Query\\QueryBuilder",
            "type":"->",
            "args":[
               
            ]
         },
         {
            "file":"/var/www/html/lib/private/Files/Cache/Cache.php",
            "line":379,
            "function":"execute",
            "class":"OC\\DB\\QueryBuilder\\QueryBuilder",
            "type":"->",
            "args":[
               
            ]
         },
         {
            "file":"/var/www/html/lib/private/Files/Cache/Updater.php",
            "line":256,
            "function":"update",
            "class":"OC\\Files\\Cache\\Cache",
            "type":"->",
            "args":[
               "*** sensitive parameters replaced ***"
            ]
         },
         {
            "file":"/var/www/html/lib/private/Files/Cache/Updater.php",
            "line":138,
            "function":"correctParentStorageMtime",
            "class":"OC\\Files\\Cache\\Updater",
            "type":"->",
            "args":[
               "*** sensitive parameter replaced ***"
            ]
         },
         {
            "file":"/var/www/html/apps/dav/lib/Connector/Sabre/File.php",
            "line":339,
            "function":"update",
            "class":"OC\\Files\\Cache\\Updater",
            "type":"->",
            "args":[
               "*** sensitive parameters replaced ***"
            ]
         },
         {
            "file":"/var/www/html/apps/dav/lib/Connector/Sabre/Directory.php",
            "line":155,
            "function":"put",
            "class":"OCA\\DAV\\Connector\\Sabre\\File",
            "type":"->",
            "args":[
               null
            ]
         },
         {
            "file":"/var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php",
            "line":1098,
            "function":"createFile",
            "class":"OCA\\DAV\\Connector\\Sabre\\Directory",
            "type":"->",
            "args":[
               "Kép 045.jpg",
               null
            ]
         },
         {
            "file":"/var/www/html/3rdparty/sabre/dav/lib/DAV/CorePlugin.php",
            "line":504,
            "function":"createFile",
            "class":"Sabre\\DAV\\Server",
            "type":"->",
            "args":[
               "files/tuzes/kamera/régi képtár/Ünnepi/temetés/nagypapa/Kép 045.jpg",
               null,
               null
            ]
         },
         {
            "file":"/var/www/html/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/html/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/html/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/html/3rdparty/sabre/dav/lib/DAV/Server.php",
            "line":321,
            "function":"start",
            "class":"Sabre\\DAV\\Server",
            "type":"->",
            "args":[
               
            ]
         },
         {
            "file":"/var/www/html/apps/dav/lib/Server.php",
            "line":339,
            "function":"exec",
            "class":"Sabre\\DAV\\Server",
            "type":"->",
            "args":[
               
            ]
         },
         {
            "file":"/var/www/html/apps/dav/appinfo/v2/remote.php",
            "line":35,
            "function":"exec",
            "class":"OCA\\DAV\\Server",
            "type":"->",
            "args":[
               
            ]
         },
         {
            "file":"/var/www/html/remote.php",
            "line":166,
            "args":[
               "/var/www/html/apps/dav/appinfo/v2/remote.php"
            ],
            "function":"require_once"
         }
      ],
      "File":"/var/www/html/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/html/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/html/3rdparty/doctrine/dbal/src/Connection.php",
               "line":1163,
               "function":"execute",
               "class":"Doctrine\\DBAL\\Driver\\PDO\\Statement",
               "type":"->",
               "args":[
                  
               ]
            },
            {
               "file":"/var/www/html/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)))",
                  [
                     1649974615,
                     1649974615,
                     "*** sensitive parameter replaced ***",
                     1649974615,
                     1649974615
                  ],
                  [
                     2,
                     2,
                     1,
                     2,
                     2
                  ]
               ]
            },
            {
               "file":"/var/www/html/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":1649974615,
                     "dcValue3":1649974615,
                     "dcValue4":1649974615,
                     "dcValue5":1649974615
                  },
                  {
                     "dcValue1":1,
                     "dcValue2":2,
                     "dcValue3":2,
                     "dcValue4":2,
                     "dcValue5":2
                  }
               ]
            },
            {
               "file":"/var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php",
               "line":287,
               "function":"execute",
               "class":"Doctrine\\DBAL\\Query\\QueryBuilder",
               "type":"->",
               "args":[
                  
               ]
            },
            {
               "file":"/var/www/html/lib/private/Files/Cache/Cache.php",
               "line":379,
               "function":"execute",
               "class":"OC\\DB\\QueryBuilder\\QueryBuilder",
               "type":"->",
               "args":[
                  
               ]
            },
            {
               "file":"/var/www/html/lib/private/Files/Cache/Updater.php",
               "line":256,
               "function":"update",
               "class":"OC\\Files\\Cache\\Cache",
               "type":"->",
               "args":[
                  "*** sensitive parameters replaced ***"
               ]
            },
            {
               "file":"/var/www/html/lib/private/Files/Cache/Updater.php",
               "line":138,
               "function":"correctParentStorageMtime",
               "class":"OC\\Files\\Cache\\Updater",
               "type":"->",
               "args":[
                  "*** sensitive parameter replaced ***"
               ]
            },
            {
               "file":"/var/www/html/apps/dav/lib/Connector/Sabre/File.php",
               "line":339,
               "function":"update",
               "class":"OC\\Files\\Cache\\Updater",
               "type":"->",
               "args":[
                  "*** sensitive parameters replaced ***"
               ]
            },
            {
               "file":"/var/www/html/apps/dav/lib/Connector/Sabre/Directory.php",
               "line":155,
               "function":"put",
               "class":"OCA\\DAV\\Connector\\Sabre\\File",
               "type":"->",
               "args":[
                  null
               ]
            },
            {
               "file":"/var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php",
               "line":1098,
               "function":"createFile",
               "class":"OCA\\DAV\\Connector\\Sabre\\Directory",
               "type":"->",
               "args":[
                  "Kép 045.jpg",
                  null
               ]
            },
            {
               "file":"/var/www/html/3rdparty/sabre/dav/lib/DAV/CorePlugin.php",
               "line":504,
               "function":"createFile",
               "class":"Sabre\\DAV\\Server",
               "type":"->",
               "args":[
                  "files/tuzes/kamera/régi képtár/Ünnepi/temetés/nagypapa/Kép 045.jpg",
                  null,
                  null
               ]
            },
            {
               "file":"/var/www/html/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/html/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/html/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/html/3rdparty/sabre/dav/lib/DAV/Server.php",
               "line":321,
               "function":"start",
               "class":"Sabre\\DAV\\Server",
               "type":"->",
               "args":[
                  
               ]
            },
            {
               "file":"/var/www/html/apps/dav/lib/Server.php",
               "line":339,
               "function":"exec",
               "class":"Sabre\\DAV\\Server",
               "type":"->",
               "args":[
                  
               ]
            },
            {
               "file":"/var/www/html/apps/dav/appinfo/v2/remote.php",
               "line":35,
               "function":"exec",
               "class":"OCA\\DAV\\Server",
               "type":"->",
               "args":[
                  
               ]
            },
            {
               "file":"/var/www/html/remote.php",
               "line":166,
               "args":[
                  "/var/www/html/apps/dav/appinfo/v2/remote.php"
               ],
               "function":"require_once"
            }
         ],
         "File":"/var/www/html/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/html/3rdparty/doctrine/dbal/src/Driver/PDO/Statement.php",
                  "line":92,
                  "function":"execute",
                  "class":"PDOStatement",
                  "type":"->",
                  "args":[
                     null
                  ]
               },
               {
                  "file":"/var/www/html/3rdparty/doctrine/dbal/src/Connection.php",
                  "line":1163,
                  "function":"execute",
                  "class":"Doctrine\\DBAL\\Driver\\PDO\\Statement",
                  "type":"->",
                  "args":[
                     
                  ]
               },
               {
                  "file":"/var/www/html/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)))",
                     [
                        1649974615,
                        1649974615,
                        "*** sensitive parameter replaced ***",
                        1649974615,
                        1649974615
                     ],
                     [
                        2,
                        2,
                        1,
                        2,
                        2
                     ]
                  ]
               },
               {
                  "file":"/var/www/html/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":1649974615,
                        "dcValue3":1649974615,
                        "dcValue4":1649974615,
                        "dcValue5":1649974615
                     },
                     {
                        "dcValue1":1,
                        "dcValue2":2,
                        "dcValue3":2,
                        "dcValue4":2,
                        "dcValue5":2
                     }
                  ]
               },
               {
                  "file":"/var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php",
                  "line":287,
                  "function":"execute",
                  "class":"Doctrine\\DBAL\\Query\\QueryBuilder",
                  "type":"->",
                  "args":[
                     
                  ]
               },
               {
                  "file":"/var/www/html/lib/private/Files/Cache/Cache.php",
                  "line":379,
                  "function":"execute",
                  "class":"OC\\DB\\QueryBuilder\\QueryBuilder",
                  "type":"->",
                  "args":[
                     
                  ]
               },
               {
                  "file":"/var/www/html/lib/private/Files/Cache/Updater.php",
                  "line":256,
                  "function":"update",
                  "class":"OC\\Files\\Cache\\Cache",
                  "type":"->",
                  "args":[
                     "*** sensitive parameters replaced ***"
                  ]
               },
               {
                  "file":"/var/www/html/lib/private/Files/Cache/Updater.php",
                  "line":138,
                  "function":"correctParentStorageMtime",
                  "class":"OC\\Files\\Cache\\Updater",
                  "type":"->",
                  "args":[
                     "*** sensitive parameter replaced ***"
                  ]
               },
               {
                  "file":"/var/www/html/apps/dav/lib/Connector/Sabre/File.php",
                  "line":339,
                  "function":"update",
                  "class":"OC\\Files\\Cache\\Updater",
                  "type":"->",
                  "args":[
                     "*** sensitive parameters replaced ***"
                  ]
               },
               {
                  "file":"/var/www/html/apps/dav/lib/Connector/Sabre/Directory.php",
                  "line":155,
                  "function":"put",
                  "class":"OCA\\DAV\\Connector\\Sabre\\File",
                  "type":"->",
                  "args":[
                     null
                  ]
               },
               {
                  "file":"/var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php",
                  "line":1098,
                  "function":"createFile",
                  "class":"OCA\\DAV\\Connector\\Sabre\\Directory",
                  "type":"->",
                  "args":[
                     "Kép 045.jpg",
                     null
                  ]
               },
               {
                  "file":"/var/www/html/3rdparty/sabre/dav/lib/DAV/CorePlugin.php",
                  "line":504,
                  "function":"createFile",
                  "class":"Sabre\\DAV\\Server",
                  "type":"->",
                  "args":[
                     "files/tuzes/kamera/régi képtár/Ünnepi/temetés/nagypapa/Kép 045.jpg",
                     null,
                     null
                  ]
               },
               {
                  "file":"/var/www/html/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/html/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/html/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/html/3rdparty/sabre/dav/lib/DAV/Server.php",
                  "line":321,
                  "function":"start",
                  "class":"Sabre\\DAV\\Server",
                  "type":"->",
                  "args":[
                     
                  ]
               },
               {
                  "file":"/var/www/html/apps/dav/lib/Server.php",
                  "line":339,
                  "function":"exec",
                  "class":"Sabre\\DAV\\Server",
                  "type":"->",
                  "args":[
                     
                  ]
               },
               {
                  "file":"/var/www/html/apps/dav/appinfo/v2/remote.php",
                  "line":35,
                  "function":"exec",
                  "class":"OCA\\DAV\\Server",
                  "type":"->",
                  "args":[
                     
                  ]
               },
               {
                  "file":"/var/www/html/remote.php",
                  "line":166,
                  "args":[
                     "/var/www/html/apps/dav/appinfo/v2/remote.php"
                  ],
                  "function":"require_once"
               }
            ],
            "File":"/var/www/html/3rdparty/doctrine/dbal/src/Driver/PDO/Statement.php",
            "Line":92
         }
      },
      "CustomMessage":"--"
   },
   "id":"62592c7b5bbaa"
}

danieltuzes avatar Apr 15 '22 08:04 danieltuzes

yes, this is all due to filecache updates. In your case putting a file to nextcloud, in my case deleting it, the top case too (maybe in the versions-manager, which irritated me, but its basically the same). This also explains, why it happens more often if the database is large or slow.

Nextcloud should really think about serialisation of the class "OC\Files\Cache\Updater" function "update" to not interfere with itself when doing many changes, but i would rate it minor, as it will not impact basic functionality of the server.

obel1x avatar Apr 15 '22 09:04 obel1x

still an issue with Nextcloud 24

meldarionqeusse avatar May 07 '22 17:05 meldarionqeusse

Still a blocking issue, users can not upload bulk directories, making Nextcloud useless for them…

nderambure avatar May 17 '22 11:05 nderambure

Is there any realiable workaround for this? Huge issue when users are migrating data from old DMS to nextcloud, because it breaks somewhere in the middle.

slavoren avatar Jun 15 '22 09:06 slavoren

Same as #22482 which is locked and all of these get duped to.

bdrewery avatar Oct 19 '22 20:10 bdrewery

This has become much more prominent with the v25 release, simply uploading something with loads of small files through the webui always results in this issue. Uploading the same files through the client results in "Network Error:99".

Resulting in simply unworkable situations.

GieltjE avatar Nov 17 '22 21:11 GieltjE

I got same issue over and over on a new installation despite following many advices from different forums & docs. I tried the snap install on another VM I and was able to upload smoothly the full directory without issue.

garphil avatar Nov 26 '22 13:11 garphil

Same problem when upload folder with lots of small files. Compress file uploaded without a hitch

meldarionqeusse avatar Jan 04 '23 14:01 meldarionqeusse

I've applied the recommended configuration of MySQL (MariaDB for me) seen here : https://docs.nextcloud.com/server/stable/admin_manual/configuration_database/linux_database_configuration.html

Adding this to my conf file :

transaction_isolation   = READ-COMMITTED
binlog_format           = ROW
innodb_large_prefix     = on
innodb_file_format      = barracuda

makes the error disappear. I'm still on NC 24, can you confirm too on 25 ?

nderambure avatar Jan 04 '23 15:01 nderambure

thanks @nderambure it seems your suggestion fixed the issue and I am running NC 25.

For others not so familiar with sql and this sort of things like I am. I added the following to /etc/mysql/my.cnf as per https://docs.nextcloud.com/server/stable/admin_manual/configuration_database/linux_database_configuration.html :

[mysqld]
character_set_server = utf8mb4
collation_server = utf8mb4_general_ci
transaction_isolation = READ-COMMITTED
binlog_format = ROW
innodb_large_prefix=on
innodb_file_format=barracuda
innodb_file_per_table=1

meldarionqeusse avatar Jan 05 '23 08:01 meldarionqeusse

Wow. I don't know for sure if that was the trouble, but I just had my first working bulk POST.

tail -f /var/log/apache2/other_vhosts_access.log |grep 'bulk\|PUT'

XXXXXXX - - [05/Jan/2023:09:09:02 +0000] "POST /remote.php/dav/bulk HTTP/1.1" 200 4475 "-" "Mozilla/5.0 (Macintosh) mirall/3.6.4git (build 12826) (Nextcloud, osx-22.1.0 ClientArchitecture: x86_64 OsArchitecture: x86_64)"

Tested with 200x random 10kb files in 1 directory. NC25.

This goes in an awesome direction. Approaching happiness.

btw I adjusted the following in postgresql.conf default_transaction_isolation = 'read committed'

labor4 avatar Jan 05 '23 09:01 labor4

Thank you for figuring this out!

According to MySQL manual:

Transaction Isolation Levels READ COMMITTED For UPDATE or DELETE statements, InnoDB holds locks only for rows that it updates or deletes. Record locks for nonmatching rows are released after MySQL has evaluated the WHERE condition. This greatly reduces the probability of deadlocks, but they can still happen.

This might explain the lack of deadlocks with this configuration.

Nextcloud could also set this isolation level during connection time (so we wouldn't need to set this globally, affecting every database):

A user can change the isolation level for a single session or for all subsequent connections with the SET TRANSACTION statement.

Similar situation with binlog_format:

The logging format in a running MySQL server is controlled by setting the binlog_format server system variable. This variable can be set with session or global scope.

szotsaki avatar Jan 05 '23 10:01 szotsaki

About the "discover" of this configuration recommandation in NC doc, I think that when I first Install my NC (the 15th !), this doc was not existing, and since I'm not a Database specialist, I missed it.

Thank you @szotsaki for the precision, I'm wondering why NC does not set this for himself instead of configuring it globally, which force to use a custom instance of MySQL specifically for NC.

Any NC dev that could enlighten us ?

nderambure avatar Jan 05 '23 15:01 nderambure

Changed the aformentioned values in MariaDB, re-enabled bulk upload in the config, deleted and uploaded 3k files and still encountered the same issues.

GieltjE avatar Jan 05 '23 15:01 GieltjE

Closing as this seems to be a configuration issue based on https://github.com/nextcloud/server/issues/29985#issuecomment-1371925886

szaimen avatar Jan 09 '23 10:01 szaimen

Same here changing the db config to READ_COMMITTED did not solve the problem. Still an issue together with md5 hash is incorrect.

c-schulz-rd13 avatar Apr 27 '23 08:04 c-schulz-rd13

I'm running postgres (where default_transaction_isolation = 'read committed' is actually the default) and the problem exists with nc 26.0.1

robbytobby avatar May 02 '23 08:05 robbytobby

@robbytobby @szaimen @szotsaki Read committed won't fix the Problem, as it is a problem of coding and handling parrallelisation. I analysed this before: Nextcloud is doing all recalculations of top Directory sizes for each affected file in one parrallel execution by adding/substracting Values. This is very bad, as it performes many updates and will cause deadlocks, cause when changing more than one File in one (DB-) Commit, this tells the Database to synchroniously add or substract two values depending of the result of the other operation. This MUST lead to a Deadlock and can only be solved by refacturing the code of Size- Calculation.

Unfortunatelly currently i am low on ressources - but please Nextclouders, have a look at this!

Best approach imo would either be to cache the sizecalculation (best to memcached/redis) and only write Results once after te Bunch of commits to the DB (when using Bulkuploads) - or to synchronise Access to the DB, which would be much slower and maybe complicated to do so, but would solve the Deadlocks.

obel1x avatar May 02 '23 14:05 obel1x

@robbytobby @szaimen @szotsaki Read committed won't fix the Problem, as it is a problem of coding and handling parrallelisation. I analysed this before: Nextcloud is doing all recalculations of top Directory sizes for each affected file in one parrallel execution by adding/substracting Values. This is very bad, as it performes many updates and will cause deadlocks, cause when changing more than one File in one (DB-) Commit, this tells the Database to synchroniously add or substract two values depending of the result of the other operation. This MUST lead to a Deadlock and can only be solved by refacturing the code of Size- Calculation.

Unfortunatelly currently i am low on ressources - but please Nextclouders, have a look at this!

Best approach imo would either be to cache the sizecalculation (best to memcached/redis) and only write Results once after te Bunch of commits to the DB (when using Bulkuploads) - or to synchronise Access to the DB, which would be much slower and maybe complicated to do so, but would solve the Deadlocks.

@obel1x Hi, just wondering if there is any temporary solution? Like manually delete something? My nextcloud is totally stopped for days.

yylzcom avatar Oct 26 '23 01:10 yylzcom