Server: DeadlockException executing UPDATE `oc_filecache`

Created on 29 Aug 2020  路  93Comments  路  Source: nextcloud/server

How to use GitHub

  • Please use the 馃憤 reaction to show that you are affected by the same issue.
  • Please don't comment if you have no relevant information to add. It's just extra noise for everyone subscribed to this issue.
  • Subscribe to receive notifications on status change and new comments.

Report

Getting the following error when deleting files. I even setup a new Nextcloud 19.0.2 server and still same issue. Seems to be related with photo files more then docs.

Doctrine\DBAL\Exception\DeadlockException: An exception occurred while executing
'UPDATE `oc_filecache` SET `size` = ? WHERE (`fileid` = ?) AND ((`size` <> ?) OR (`size` IS NULL))'
with params [237591435, 213130, 237591435]:
SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction

I've already ran

sudo -u www-data php occ files:scan-app-data
sudo -u www-data php occ files:scan --all
sudo -u www-data php occ files:cleanup

Already checked the oc_filecache table; and no issues there based on the output of mysql.

image

image

image

1. to develop 19-feedback bug needs info

Most helpful comment

This issue should deserve more attention, a single user can render a whole Nextcloud instance unusable just by uploading a bunch of files at once through the web interface.
Maybe a quick and dirty fix could be a brute-force solution doing a before update statement trigger on oc_filecache that takes a share row exclusive lock?

This!

We dont need a "useful" dashboard or users' online status indicators. What is important is that core-functionality is working reliably.

All 93 comments

There are several issues like this like https://github.com/nextcloud/server/issues/15047, but it clears seems a new problem introduced in 19.0.2 as it affects all our instances with different setups after upgrading from 19.0.1.

We can reproduce it but uploading many files (30) to a folder then select them all and delete. Some of them will produce a Deadlock.

Filelocking is enabled on Redis. I'm using MariaBD 10.4.


Detailed output

{
  "reqId": "1IyGszyr4rk3uCA4FIoF",
  "level": 4,
  "time": "2020-08-27T16:06:11+02:00",
  "remoteAddr": "176.177.105.226",
  "user": "nextcloud",
  "app": "webdav",
  "method": "DELETE",
  "url": "/remote.php/dav/files/nextcloud/Photos/hvkjbhvbkljmknbm.png",
  "message": {
    "Exception": "Doctrine\\DBAL\\Exception\\DeadlockException",
    "Message": "An exception occurred while executing 'UPDATE `oc_filecache` SET `mtime` = GREATEST(`mtime`, ?), `etag` = ? WHERE (`storage` = ?) AND (`path_hash` IN ('d41d8cd98f00b204e9800998ecf8427e', '45b963397aa40d4a0063e0d85e4fe7a1', 'd01bb67e7b71dd49fd06bad922f521c9'))' with params [1598537171, \"5f47bdd345199\", 1]:\n\nSQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction",
    "Code": 0,
    "Trace": [
      {
        "file": "/var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php",
        "line": 169,
        "function": "convertException",
        "class": "Doctrine\\DBAL\\Driver\\AbstractMySQLDriver",
        "type": "->",
        "args": [
          "An exception occurred while executing 'UPDATE `oc_filecache` SET `mtime` = GREATEST(`mtime`, ?), `etag` = ? WHERE (`storage` = ?) AND (`path_hash` IN ('d41d8cd98f00b204e9800998ecf8427e', '45b963397aa40d4a0063e0d85e4fe7a1', 'd01bb67e7b71dd49fd06bad922f521c9'))' with params [1598537171, \"5f47bdd345199\", 1]:\n\nSQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction",
          {
            "errorInfo": [
              "40001",
              1213,
              "Deadlock found when trying to get lock; try restarting transaction"
            ],
            "__class__": "Doctrine\\DBAL\\Driver\\PDOException"
          }
        ]
      },
      {
        "file": "/var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php",
        "line": 145,
        "function": "wrapException",
        "class": "Doctrine\\DBAL\\DBALException",
        "type": "::",
        "args": [
          {
            "__class__": "Doctrine\\DBAL\\Driver\\PDOMySql\\Driver"
          },
          {
            "errorInfo": [
              "40001",
              1213,
              "Deadlock found when trying to get lock; try restarting transaction"
            ],
            "__class__": "Doctrine\\DBAL\\Driver\\PDOException"
          },
          "An exception occurred while executing 'UPDATE `oc_filecache` SET `mtime` = GREATEST(`mtime`, ?), `etag` = ? WHERE (`storage` = ?) AND (`path_hash` IN ('d41d8cd98f00b204e9800998ecf8427e', '45b963397aa40d4a0063e0d85e4fe7a1', 'd01bb67e7b71dd49fd06bad922f521c9'))' with params [1598537171, \"5f47bdd345199\", 1]:\n\nSQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction"
        ]
      },
      {
        "file": "/var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php",
        "line": 1063,
        "function": "driverExceptionDuringQuery",
        "class": "Doctrine\\DBAL\\DBALException",
        "type": "::",
        "args": [
          {
            "__class__": "Doctrine\\DBAL\\Driver\\PDOMySql\\Driver"
          },
          {
            "errorInfo": [
              "40001",
              1213,
              "Deadlock found when trying to get lock; try restarting transaction"
            ],
            "__class__": "Doctrine\\DBAL\\Driver\\PDOException"
          },
          "UPDATE `oc_filecache` SET `mtime` = GREATEST(`mtime`, ?), `etag` = ? WHERE (`storage` = ?) AND (`path_hash` IN ('d41d8cd98f00b204e9800998ecf8427e', '45b963397aa40d4a0063e0d85e4fe7a1', 'd01bb67e7b71dd49fd06bad922f521c9'))",
          {
            "1": 1598537171,
            "2": "5f47bdd345199",
            "3": 1
          }
        ]
      },
      {
        "file": "/var/www/nextcloud/lib/private/DB/Connection.php",
        "line": 214,
        "function": "executeUpdate",
        "class": "Doctrine\\DBAL\\Connection",
        "type": "->",
        "args": [
          "UPDATE `oc_filecache` SET `mtime` = GREATEST(`mtime`, ?), `etag` = ? WHERE (`storage` = ?) AND (`path_hash` IN ('d41d8cd98f00b204e9800998ecf8427e', '45b963397aa40d4a0063e0d85e4fe7a1', 'd01bb67e7b71dd49fd06bad922f521c9'))",
          [
            1598537171,
            "5f47bdd345199",
            1
          ],
          [
            1,
            2,
            1
          ]
        ]
      },
      {
        "file": "/var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Query/QueryBuilder.php",
        "line": 203,
        "function": "executeUpdate",
        "class": "OC\\DB\\Connection",
        "type": "->",
        "args": [
          "UPDATE `oc_filecache` SET `mtime` = GREATEST(`mtime`, :dcValue1), `etag` = :dcValue2 WHERE (`storage` = :dcValue3) AND (`path_hash` IN ('d41d8cd98f00b204e9800998ecf8427e', '45b963397aa40d4a0063e0d85e4fe7a1', 'd01bb67e7b71dd49fd06bad922f521c9'))",
          {
            "dcValue1": 1598537171,
            "dcValue2": "5f47bdd345199",
            "dcValue3": 1
          },
          {
            "dcValue1": 1,
            "dcValue2": 2,
            "dcValue3": 1
          }
        ]
      },
      {
        "file": "/var/www/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php",
        "line": 216,
        "function": "execute",
        "class": "Doctrine\\DBAL\\Query\\QueryBuilder",
        "type": "->",
        "args": []
      },
      {
        "file": "/var/www/nextcloud/lib/private/Files/Cache/Propagator.php",
        "line": 101,
        "function": "execute",
        "class": "OC\\DB\\QueryBuilder\\QueryBuilder",
        "type": "->",
        "args": []
      },
      {
        "file": "/var/www/nextcloud/lib/private/Files/Cache/Updater.php",
        "line": 166,
        "function": "propagateChange",
        "class": "OC\\Files\\Cache\\Propagator",
        "type": "->",
        "args": [
          "files/Photos/hvkjbhvbkljmknbm.png",
          1598537171
        ]
      },
      {
        "file": "/var/www/nextcloud/lib/private/Files/View.php",
        "line": 329,
        "function": "remove",
        "class": "OC\\Files\\Cache\\Updater",
        "type": "->",
        "args": [
          "files/Photos/hvkjbhvbkljmknbm.png"
        ]
      },
      {
        "file": "/var/www/nextcloud/lib/private/Files/View.php",
        "line": 1173,
        "function": "removeUpdate",
        "class": "OC\\Files\\View",
        "type": "->",
        "args": [
          {
            "cache": {
              "__class__": "OC\\Files\\Cache\\Cache"
            },
            "scanner": null,
            "watcher": null,
            "propagator": {
              "__class__": "OC\\Files\\Cache\\Propagator"
            },
            "updater": {
              "__class__": "OC\\Files\\Cache\\Updater"
            },
            "__class__": "OCA\\Files_Trashbin\\Storage"
          },
          "files/Photos/hvkjbhvbkljmknbm.png"
        ]
      },
      {
        "file": "/var/www/nextcloud/lib/private/Files/View.php",
        "line": 718,
        "function": "basicOperation",
        "class": "OC\\Files\\View",
        "type": "->",
        "args": [
          "unlink",
          "/Photos/hvkjbhvbkljmknbm.png",
          [
            "delete"
          ]
        ]
      },
      {
        "file": "/var/www/nextcloud/apps/dav/lib/Connector/Sabre/File.php",
        "line": 455,
        "function": "unlink",
        "class": "OC\\Files\\View",
        "type": "->",
        "args": [
          "/Photos/hvkjbhvbkljmknbm.png"
        ]
      },
      {
        "file": "/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Tree.php",
        "line": 183,
        "function": "delete",
        "class": "OCA\\DAV\\Connector\\Sabre\\File",
        "type": "->",
        "args": []
      },
      {
        "file": "/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/CorePlugin.php",
        "line": 295,
        "function": "delete",
        "class": "Sabre\\DAV\\Tree",
        "type": "->",
        "args": [
          "files/nextcloud/Photos/hvkjbhvbkljmknbm.png"
        ]
      },
      {
        "file": "/var/www/nextcloud/3rdparty/sabre/event/lib/WildcardEmitterTrait.php",
        "line": 89,
        "function": "httpDelete",
        "class": "Sabre\\DAV\\CorePlugin",
        "type": "->",
        "args": [
          {
            "__class__": "Sabre\\HTTP\\Request"
          },
          {
            "__class__": "Sabre\\HTTP\\Response"
          }
        ]
      },
      {
        "file": "/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php",
        "line": 474,
        "function": "emit",
        "class": "Sabre\\DAV\\Server",
        "type": "->",
        "args": [
          "method:DELETE",
          [
            {
              "__class__": "Sabre\\HTTP\\Request"
            },
            {
              "__class__": "Sabre\\HTTP\\Response"
            }
          ]
        ]
      },
      {
        "file": "/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php",
        "line": 251,
        "function": "invokeMethod",
        "class": "Sabre\\DAV\\Server",
        "type": "->",
        "args": [
          {
            "__class__": "Sabre\\HTTP\\Request"
          },
          {
            "__class__": "Sabre\\HTTP\\Response"
          }
        ]
      },
      {
        "file": "/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php",
        "line": 319,
        "function": "start",
        "class": "Sabre\\DAV\\Server",
        "type": "->",
        "args": []
      },
      {
        "file": "/var/www/nextcloud/apps/dav/lib/Server.php",
        "line": 320,
        "function": "exec",
        "class": "Sabre\\DAV\\Server",
        "type": "->",
        "args": []
      },
      {
        "file": "/var/www/nextcloud/apps/dav/appinfo/v2/remote.php",
        "line": 35,
        "function": "exec",
        "class": "OCA\\DAV\\Server",
        "type": "->",
        "args": []
      },
      {
        "file": "/var/www/nextcloud/remote.php",
        "line": 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/AbstractMySQLDriver.php",
    "Line": 34,
    "Previous": {
      "Exception": "Doctrine\\DBAL\\Driver\\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/lib/Doctrine/DBAL/Connection.php",
          "line": 1054,
          "function": "execute",
          "class": "Doctrine\\DBAL\\Driver\\PDOStatement",
          "type": "->",
          "args": []
        },
        {
          "file": "/var/www/nextcloud/lib/private/DB/Connection.php",
          "line": 214,
          "function": "executeUpdate",
          "class": "Doctrine\\DBAL\\Connection",
          "type": "->",
          "args": [
            "UPDATE `oc_filecache` SET `mtime` = GREATEST(`mtime`, ?), `etag` = ? WHERE (`storage` = ?) AND (`path_hash` IN ('d41d8cd98f00b204e9800998ecf8427e', '45b963397aa40d4a0063e0d85e4fe7a1', 'd01bb67e7b71dd49fd06bad922f521c9'))",
            [
              1598537171,
              "5f47bdd345199",
              1
            ],
            [
              1,
              2,
              1
            ]
          ]
        },
        {
          "file": "/var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Query/QueryBuilder.php",
          "line": 203,
          "function": "executeUpdate",
          "class": "OC\\DB\\Connection",
          "type": "->",
          "args": [
            "UPDATE `oc_filecache` SET `mtime` = GREATEST(`mtime`, :dcValue1), `etag` = :dcValue2 WHERE (`storage` = :dcValue3) AND (`path_hash` IN ('d41d8cd98f00b204e9800998ecf8427e', '45b963397aa40d4a0063e0d85e4fe7a1', 'd01bb67e7b71dd49fd06bad922f521c9'))",
            {
              "dcValue1": 1598537171,
              "dcValue2": "5f47bdd345199",
              "dcValue3": 1
            },
            {
              "dcValue1": 1,
              "dcValue2": 2,
              "dcValue3": 1
            }
          ]
        },
        {
          "file": "/var/www/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php",
          "line": 216,
          "function": "execute",
          "class": "Doctrine\\DBAL\\Query\\QueryBuilder",
          "type": "->",
          "args": []
        },
        {
          "file": "/var/www/nextcloud/lib/private/Files/Cache/Propagator.php",
          "line": 101,
          "function": "execute",
          "class": "OC\\DB\\QueryBuilder\\QueryBuilder",
          "type": "->",
          "args": []
        },
        {
          "file": "/var/www/nextcloud/lib/private/Files/Cache/Updater.php",
          "line": 166,
          "function": "propagateChange",
          "class": "OC\\Files\\Cache\\Propagator",
          "type": "->",
          "args": [
            "files/Photos/hvkjbhvbkljmknbm.png",
            1598537171
          ]
        },
        {
          "file": "/var/www/nextcloud/lib/private/Files/View.php",
          "line": 329,
          "function": "remove",
          "class": "OC\\Files\\Cache\\Updater",
          "type": "->",
          "args": [
            "files/Photos/hvkjbhvbkljmknbm.png"
          ]
        },
        {
          "file": "/var/www/nextcloud/lib/private/Files/View.php",
          "line": 1173,
          "function": "removeUpdate",
          "class": "OC\\Files\\View",
          "type": "->",
          "args": [
            {
              "cache": {
                "__class__": "OC\\Files\\Cache\\Cache"
              },
              "scanner": null,
              "watcher": null,
              "propagator": {
                "__class__": "OC\\Files\\Cache\\Propagator"
              },
              "updater": {
                "__class__": "OC\\Files\\Cache\\Updater"
              },
              "__class__": "OCA\\Files_Trashbin\\Storage"
            },
            "files/Photos/hvkjbhvbkljmknbm.png"
          ]
        },
        {
          "file": "/var/www/nextcloud/lib/private/Files/View.php",
          "line": 718,
          "function": "basicOperation",
          "class": "OC\\Files\\View",
          "type": "->",
          "args": [
            "unlink",
            "/Photos/hvkjbhvbkljmknbm.png",
            [
              "delete"
            ]
          ]
        },
        {
          "file": "/var/www/nextcloud/apps/dav/lib/Connector/Sabre/File.php",
          "line": 455,
          "function": "unlink",
          "class": "OC\\Files\\View",
          "type": "->",
          "args": [
            "/Photos/hvkjbhvbkljmknbm.png"
          ]
        },
        {
          "file": "/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Tree.php",
          "line": 183,
          "function": "delete",
          "class": "OCA\\DAV\\Connector\\Sabre\\File",
          "type": "->",
          "args": []
        },
        {
          "file": "/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/CorePlugin.php",
          "line": 295,
          "function": "delete",
          "class": "Sabre\\DAV\\Tree",
          "type": "->",
          "args": [
            "files/nextcloud/Photos/hvkjbhvbkljmknbm.png"
          ]
        },
        {
          "file": "/var/www/nextcloud/3rdparty/sabre/event/lib/WildcardEmitterTrait.php",
          "line": 89,
          "function": "httpDelete",
          "class": "Sabre\\DAV\\CorePlugin",
          "type": "->",
          "args": [
            {
              "__class__": "Sabre\\HTTP\\Request"
            },
            {
              "__class__": "Sabre\\HTTP\\Response"
            }
          ]
        },
        {
          "file": "/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php",
          "line": 474,
          "function": "emit",
          "class": "Sabre\\DAV\\Server",
          "type": "->",
          "args": [
            "method:DELETE",
            [
              {
                "__class__": "Sabre\\HTTP\\Request"
              },
              {
                "__class__": "Sabre\\HTTP\\Response"
              }
            ]
          ]
        },
        {
          "file": "/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php",
          "line": 251,
          "function": "invokeMethod",
          "class": "Sabre\\DAV\\Server",
          "type": "->",
          "args": [
            {
              "__class__": "Sabre\\HTTP\\Request"
            },
            {
              "__class__": "Sabre\\HTTP\\Response"
            }
          ]
        },
        {
          "file": "/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php",
          "line": 319,
          "function": "start",
          "class": "Sabre\\DAV\\Server",
          "type": "->",
          "args": []
        },
        {
          "file": "/var/www/nextcloud/apps/dav/lib/Server.php",
          "line": 320,
          "function": "exec",
          "class": "Sabre\\DAV\\Server",
          "type": "->",
          "args": []
        },
        {
          "file": "/var/www/nextcloud/apps/dav/appinfo/v2/remote.php",
          "line": 35,
          "function": "exec",
          "class": "OCA\\DAV\\Server",
          "type": "->",
          "args": []
        },
        {
          "file": "/var/www/nextcloud/remote.php",
          "line": 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[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction",
        "Code": "40001",
        "Trace": [
          {
            "file": "/var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php",
            "line": 117,
            "function": "execute",
            "class": "PDOStatement",
            "type": "->",
            "args": [
              null
            ]
          },
          {
            "file": "/var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php",
            "line": 1054,
            "function": "execute",
            "class": "Doctrine\\DBAL\\Driver\\PDOStatement",
            "type": "->",
            "args": []
          },
          {
            "file": "/var/www/nextcloud/lib/private/DB/Connection.php",
            "line": 214,
            "function": "executeUpdate",
            "class": "Doctrine\\DBAL\\Connection",
            "type": "->",
            "args": [
              "UPDATE `oc_filecache` SET `mtime` = GREATEST(`mtime`, ?), `etag` = ? WHERE (`storage` = ?) AND (`path_hash` IN ('d41d8cd98f00b204e9800998ecf8427e', '45b963397aa40d4a0063e0d85e4fe7a1', 'd01bb67e7b71dd49fd06bad922f521c9'))",
              [
                1598537171,
                "5f47bdd345199",
                1
              ],
              [
                1,
                2,
                1
              ]
            ]
          },
          {
            "file": "/var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Query/QueryBuilder.php",
            "line": 203,
            "function": "executeUpdate",
            "class": "OC\\DB\\Connection",
            "type": "->",
            "args": [
              "UPDATE `oc_filecache` SET `mtime` = GREATEST(`mtime`, :dcValue1), `etag` = :dcValue2 WHERE (`storage` = :dcValue3) AND (`path_hash` IN ('d41d8cd98f00b204e9800998ecf8427e', '45b963397aa40d4a0063e0d85e4fe7a1', 'd01bb67e7b71dd49fd06bad922f521c9'))",
              {
                "dcValue1": 1598537171,
                "dcValue2": "5f47bdd345199",
                "dcValue3": 1
              },
              {
                "dcValue1": 1,
                "dcValue2": 2,
                "dcValue3": 1
              }
            ]
          },
          {
            "file": "/var/www/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php",
            "line": 216,
            "function": "execute",
            "class": "Doctrine\\DBAL\\Query\\QueryBuilder",
            "type": "->",
            "args": []
          },
          {
            "file": "/var/www/nextcloud/lib/private/Files/Cache/Propagator.php",
            "line": 101,
            "function": "execute",
            "class": "OC\\DB\\QueryBuilder\\QueryBuilder",
            "type": "->",
            "args": []
          },
          {
            "file": "/var/www/nextcloud/lib/private/Files/Cache/Updater.php",
            "line": 166,
            "function": "propagateChange",
            "class": "OC\\Files\\Cache\\Propagator",
            "type": "->",
            "args": [
              "files/Photos/hvkjbhvbkljmknbm.png",
              1598537171
            ]
          },
          {
            "file": "/var/www/nextcloud/lib/private/Files/View.php",
            "line": 329,
            "function": "remove",
            "class": "OC\\Files\\Cache\\Updater",
            "type": "->",
            "args": [
              "files/Photos/hvkjbhvbkljmknbm.png"
            ]
          },
          {
            "file": "/var/www/nextcloud/lib/private/Files/View.php",
            "line": 1173,
            "function": "removeUpdate",
            "class": "OC\\Files\\View",
            "type": "->",
            "args": [
              {
                "cache": {
                  "__class__": "OC\\Files\\Cache\\Cache"
                },
                "scanner": null,
                "watcher": null,
                "propagator": {
                  "__class__": "OC\\Files\\Cache\\Propagator"
                },
                "updater": {
                  "__class__": "OC\\Files\\Cache\\Updater"
                },
                "__class__": "OCA\\Files_Trashbin\\Storage"
              },
              "files/Photos/hvkjbhvbkljmknbm.png"
            ]
          },
          {
            "file": "/var/www/nextcloud/lib/private/Files/View.php",
            "line": 718,
            "function": "basicOperation",
            "class": "OC\\Files\\View",
            "type": "->",
            "args": [
              "unlink",
              "/Photos/hvkjbhvbkljmknbm.png",
              [
                "delete"
              ]
            ]
          },
          {
            "file": "/var/www/nextcloud/apps/dav/lib/Connector/Sabre/File.php",
            "line": 455,
            "function": "unlink",
            "class": "OC\\Files\\View",
            "type": "->",
            "args": [
              "/Photos/hvkjbhvbkljmknbm.png"
            ]
          },
          {
            "file": "/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Tree.php",
            "line": 183,
            "function": "delete",
            "class": "OCA\\DAV\\Connector\\Sabre\\File",
            "type": "->",
            "args": []
          },
          {
            "file": "/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/CorePlugin.php",
            "line": 295,
            "function": "delete",
            "class": "Sabre\\DAV\\Tree",
            "type": "->",
            "args": [
              "files/nextcloud/Photos/hvkjbhvbkljmknbm.png"
            ]
          },
          {
            "file": "/var/www/nextcloud/3rdparty/sabre/event/lib/WildcardEmitterTrait.php",
            "line": 89,
            "function": "httpDelete",
            "class": "Sabre\\DAV\\CorePlugin",
            "type": "->",
            "args": [
              {
                "__class__": "Sabre\\HTTP\\Request"
              },
              {
                "__class__": "Sabre\\HTTP\\Response"
              }
            ]
          },
          {
            "file": "/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php",
            "line": 474,
            "function": "emit",
            "class": "Sabre\\DAV\\Server",
            "type": "->",
            "args": [
              "method:DELETE",
              [
                {
                  "__class__": "Sabre\\HTTP\\Request"
                },
                {
                  "__class__": "Sabre\\HTTP\\Response"
                }
              ]
            ]
          },
          {
            "file": "/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php",
            "line": 251,
            "function": "invokeMethod",
            "class": "Sabre\\DAV\\Server",
            "type": "->",
            "args": [
              {
                "__class__": "Sabre\\HTTP\\Request"
              },
              {
                "__class__": "Sabre\\HTTP\\Response"
              }
            ]
          },
          {
            "file": "/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php",
            "line": 319,
            "function": "start",
            "class": "Sabre\\DAV\\Server",
            "type": "->",
            "args": []
          },
          {
            "file": "/var/www/nextcloud/apps/dav/lib/Server.php",
            "line": 320,
            "function": "exec",
            "class": "Sabre\\DAV\\Server",
            "type": "->",
            "args": []
          },
          {
            "file": "/var/www/nextcloud/apps/dav/appinfo/v2/remote.php",
            "line": 35,
            "function": "exec",
            "class": "OCA\\DAV\\Server",
            "type": "->",
            "args": []
          },
          {
            "file": "/var/www/nextcloud/remote.php",
            "line": 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; rv:80.0) Gecko/20100101 Firefox/80.0",
  "version": "19.0.2.2"
}

Cc @nextcloud/server-triage

@acsfer Yup I only get it then I select alot of file within a folder to delete. Idk why this is happening but this should be looked at and fixed!

I got worried that my database got corrupt and I build a new server and still the same issue so definitely not a my server instance your anyone else that's having the issue out there.

cc @canadaduane @jcfischer

Same to me - since upgrade to 19.0.2

Came here to say that I have the same problem with ALL instances of NC right after upgrading to 19.0.2. Even performed a fresh installation of 19.0.2 - the problem is still here.

After some debugging, I found it only happens if I try to delete multiple files at once. If I delete the same files one after one, everything works perfectly. But select them all - and deadlock message is here...

Another update: the issue exists even after adding "'filelocking.enabled' => false" line to config file.

Yeah the message is not from the file locking feature, but from a database lock

Cc @icewind1991 @rullzer anything changed in filesystem recently with regards to that?

I get various forms of DeadlockException almost every time I sync files (last time I wrote a comment about it: https://github.com/nextcloud/server/issues/10473#issuecomment-650783226). I guess it's finally happening with MySQL as well.

There are quite a few issues related to these errors (https://github.com/nextcloud/server/issues/11136, https://github.com/nextcloud/server/issues/15047, https://github.com/nextcloud/server/issues/21537). These errors are not dangerous by themselves. The error means that 2 database transactions could not be executed at the same time and one of them got cancelled ( see https://en.wikipedia.org/wiki/Deadlock ). Retrying that transaction should be enough, but Nextcloud does not seem to handle these errors at all.

DeadlockExceptions can only happen when multiple requests are made to the Nextcloud server at the same time, so testing requires adding/removing multiple files, not just one. It should also only happen on queries that read/modify multiple rows.

My most recent DeadlockException:

Doctrine\DBAL\Exception\DeadlockException: An exception occurred while executing 'UPDATE "oc_filecache" SET "size" = GREATEST(?, "size" + ?) WHERE ("storage" = ?) AND ("path_hash" IN ('d41d8cd98f00b204e9800998ecf8427e', '45b963397aa40d4a0063e0d85e4fe7a1', 'f55b8b9ffac161f2bbd566bd5a4c8075', 'd642cac0349fb48bcc52d75171a3ce7c')) AND ("size" > '-1')' with params [-1, 3691355, 2]: SQLSTATE[40P01]: Deadlock detected: 7 ERROR: deadlock detected DETAIL: Process 2427 waits for ShareLock on transaction 44023088; blocked by process 2425. Process 2425 waits for ShareLock on transaction 44023091; blocked by process 2427. HINT: See server log for query details. CONTEXT: while rechecking updated tuple (325,6) in relation "oc_filecache"

@APTX Thank you for the detailed info, hopefully the dev team can figure something out.

Not sure this helps, but these are the queries (along with the back traces) which seem to trigger this for me:

UPDATE oc_filecache SET mtime = GREATEST(mtime, ?)

[webdav] Fatal: Doctrine\DBAL\Exception\DeadlockException: An exception occurred while executing 'UPDATE `oc_filecache` SET `mtime` = GREATEST(`mtime`, ?), `etag` = ? WHERE (`storage` = ?) AND (`path_hash` IN ('d41d8cd98f00b204e9800998ecf8427e', '45b963397aa40d4a0063e0d85e4fe7a1', '5ef60ea8991f2576a90bb23baa5e4399', '48056cb550ab7052ab094f43fbb60058', 'fa7f16366733c3a3ea5b328fd5b52fa3', '6f979bb2b50146cf44f3065c1d67f59d', 'c11f4c49a04a182bbc89e93f52d09f32', '8b89822309373a5aae36013d86a47681'))' with params [1598854372, "5f4c94e4f3cb9", 9]:

SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction at <<closure>>

 0. /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php line 169
    Doctrine\DBAL\Driver\AbstractMySQLDriver->convertException("An exception oc ... n", Doctrine\DBAL\Dr ... ]})
 1. /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php line 145
    Doctrine\DBAL\DBALException::wrapException(Doctrine\DBAL\Driver\PDOMySql\Driver {}, Doctrine\DBAL\Dr ... ]}, "An exception oc ... n")
 2. /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php line 1063
    Doctrine\DBAL\DBALException::driverExceptionDuringQuery(Doctrine\DBAL\Driver\PDOMySql\Driver {}, Doctrine\DBAL\Dr ... ]}, "UPDATE `oc_file ... )", {1: 1598854372,2: "5f4c94e4f3cb9",3: 9})
 3. /var/www/nextcloud/lib/private/DB/Connection.php line 214
    Doctrine\DBAL\Connection->executeUpdate("UPDATE `oc_file ... )", [1598854372,"5f4c94e4f3cb9",9], [1,2,1])
 4. /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Query/QueryBuilder.php line 203
    OC\DB\Connection->executeUpdate("UPDATE `oc_file ... )", {dcValue1: 15988 ... 9}, {dcValue1: 1,dcValue2: 2,dcValue3: 1})
 5. /var/www/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php line 216
    Doctrine\DBAL\Query\QueryBuilder->execute()
 6. /var/www/nextcloud/lib/private/Files/Cache/Propagator.php line 101
    OC\DB\QueryBuilder\QueryBuilder->execute()
 7. /var/www/nextcloud/lib/private/Files/Cache/HomePropagator.php line 49
    OC\Files\Cache\Propagator->propagateChange("files/ ... 6", 1598854372, 0)
 8. /var/www/nextcloud/lib/private/Files/Cache/Updater.php line 166
    OC\Files\Cache\HomePropagator->propagateChange("files ... 6", 1598854372)
 9. /var/www/nextcloud/lib/private/Files/View.php line 329
    OC\Files\Cache\Updater->remove("files/<file> ... 6")
10. /var/www/nextcloud/lib/private/Files/View.php line 1173
    OC\Files\View->removeUpdate(OCA\Files_Trashb ... }}, "files/<file> ... 6")
11. /var/www/nextcloud/lib/private/Files/View.php line 718
    OC\Files\View->basicOperation("unlink", "/<file> ... 6", ["delete"])
12. /var/www/nextcloud/apps/dav/lib/Connector/Sabre/File.php line 455
    OC\Files\View->unlink("/<file> ... 6")
13. /var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Tree.php line 183
    OCA\DAV\Connector\Sabre\File->delete()
14. /var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/CorePlugin.php line 295
    Sabre\DAV\Tree->delete("files/<file> ... 6")
15. /var/www/nextcloud/3rdparty/sabre/event/lib/WildcardEmitterTrait.php line 89
    Sabre\DAV\CorePlugin->httpDelete(Sabre\HTTP\Request {}, Sabre\HTTP\Response {})
16. /var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php line 474
    Sabre\DAV\Server->emit("method:DELETE", [Sabre\HTTP\Requ ... }])
17. /var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php line 251
    Sabre\DAV\Server->invokeMethod(Sabre\HTTP\Request {}, Sabre\HTTP\Response {})
18. /var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php line 319
    Sabre\DAV\Server->start()
19. /var/www/nextcloud/apps/dav/lib/Server.php line 320
    Sabre\DAV\Server->exec()
20. /var/www/nextcloud/apps/dav/appinfo/v2/remote.php line 35
    OCA\DAV\Server->exec()
21. /var/www/nextcloud/remote.php line 167
    require_once("/var/www/nextcl ... p")

DELETE /remote.php/dav/files/...
from <ip> by <user> at 2020-08-31T08:12:53+02:00

UPDATE oc_filecache SET size = ?

[webdav] Fatal: Doctrine\DBAL\Exception\DeadlockException: An exception occurred while executing 'UPDATE `oc_filecache` SET `size` = ? WHERE (`fileid` = ?) AND ((`size` <> ?) OR (`size` IS NULL))' with params [93564, 2024096, 93564]:

SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction at <<closure>>

 0. /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php line 169
    Doctrine\DBAL\Driver\AbstractMySQLDriver->convertException("An exception oc ... n", Doctrine\DBAL\Dr ... ]})
 1. /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php line 145
    Doctrine\DBAL\DBALException::wrapException(Doctrine\DBAL\Driver\PDOMySql\Driver {}, Doctrine\DBAL\Dr ... ]}, "An exception oc ... n")
 2. /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php line 1063
    Doctrine\DBAL\DBALException::driverExceptionDuringQuery(Doctrine\DBAL\Driver\PDOMySql\Driver {}, Doctrine\DBAL\Dr ... ]}, "UPDATE `oc_file ... )", {1: 93564,2: "** ... 4})
 3. /var/www/nextcloud/lib/private/DB/Connection.php line 214
    Doctrine\DBAL\Connection->executeUpdate("UPDATE `oc_file ... )", [93564,"*** sens ... 4], [2,1,2])
 4. /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Query/QueryBuilder.php line 203
    OC\DB\Connection->executeUpdate("UPDATE `oc_file ... )", {dcValue1: "***  ... 4}, {dcValue1: 1,dcValue2: 2,dcValue3: 2})
 5. /var/www/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php line 216
    Doctrine\DBAL\Query\QueryBuilder->execute()
 6. /var/www/nextcloud/lib/private/Files/Cache/Cache.php line 363
    OC\DB\QueryBuilder\QueryBuilder->execute()
 7. /var/www/nextcloud/lib/private/Files/Cache/Cache.php line 898
    OC\Files\Cache\Cache->update("*** sensitive parameters replaced ***")
 8. /var/www/nextcloud/lib/private/Files/Cache/HomeCache.php line 43
    OC\Files\Cache\Cache->calculateFolderSize("files/<file> ... t", OC\Files\Cache\CacheEntry {})
 9. /var/www/nextcloud/lib/private/Files/Cache/Cache.php line 830
    OC\Files\Cache\HomeCache->calculateFolderSize("files/<file> ... t", null)
10. /var/www/nextcloud/lib/private/Files/Cache/Cache.php line 842
    OC\Files\Cache\Cache->correctFolderSize("files/<file> ... t")
11. /var/www/nextcloud/lib/private/Files/Cache/Cache.php line 842
    OC\Files\Cache\Cache->correctFolderSize("files/<file> ... t")
12. /var/www/nextcloud/lib/private/Files/Cache/Cache.php line 842
    OC\Files\Cache\Cache->correctFolderSize("files/<file> ... s")
13. /var/www/nextcloud/lib/private/Files/Cache/Cache.php line 842
    OC\Files\Cache\Cache->correctFolderSize("files/<file> ... 5")
14. /var/www/nextcloud/lib/private/Files/Cache/Updater.php line 217
    OC\Files\Cache\Cache->correctFolderSize("files/<file> ... 4")
15. /var/www/nextcloud/apps/files_trashbin/lib/Trashbin.php line 289
    OC\Files\Cache\Updater->renameFromStorage(OCA\Files_Trashb ... }}, "files/<file> ... 4", "files_trashbin/ ... 2")
16. /var/www/nextcloud/apps/files_trashbin/lib/Trash/LegacyTrashBackend.php line 108
    OCA\Files_Trashbin\Trashbin::move2trash("<file> ... 4")
17. /var/www/nextcloud/apps/files_trashbin/lib/Trash/TrashManager.php line 103
    OCA\Files_Trashbin\Trash\LegacyTrashBackend->moveToTrash(OCA\Files_Trashb ... }}, "files/<file> ... 4")
18. /var/www/nextcloud/apps/files_trashbin/lib/Storage.php line 192
    OCA\Files_Trashbin\Trash\TrashManager->moveToTrash(OCA\Files_Trashb ... }}, "files/<file> ... 4")
19. /var/www/nextcloud/apps/files_trashbin/lib/Storage.php line 99
    OCA\Files_Trashbin\Storage->doDelete("files/<file> ... 4", "unlink")
20. /var/www/nextcloud/lib/private/Files/View.php line 1161
    OCA\Files_Trashbin\Storage->unlink("files/<file> ... 4")
21. /var/www/nextcloud/lib/private/Files/View.php line 718
    OC\Files\View->basicOperation("unlink", "/<file> ... 4", ["delete"])
22. /var/www/nextcloud/apps/dav/lib/Connector/Sabre/File.php line 455
    OC\Files\View->unlink("/<file> ... 4")
23. /var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Tree.php line 183
    OCA\DAV\Connector\Sabre\File->delete()
24. /var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/CorePlugin.php line 295
    Sabre\DAV\Tree->delete("files/ ... 4")
25. /var/www/nextcloud/3rdparty/sabre/event/lib/WildcardEmitterTrait.php line 89
    Sabre\DAV\CorePlugin->httpDelete(Sabre\HTTP\Request {}, Sabre\HTTP\Response {})
26. /var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php line 474
    Sabre\DAV\Server->emit("method:DELETE", [Sabre\HTTP\Requ ... }])
27. /var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php line 251
    Sabre\DAV\Server->invokeMethod(Sabre\HTTP\Request {}, Sabre\HTTP\Response {})
28. /var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php line 319
    Sabre\DAV\Server->start()
29. /var/www/nextcloud/apps/dav/lib/Server.php line 320
    Sabre\DAV\Server->exec()
30. /var/www/nextcloud/apps/dav/appinfo/v2/remote.php line 35
    OCA\DAV\Server->exec()
31. /var/www/nextcloud/remote.php line 167
    require_once("/var/www/nextcl ... p")

DELETE /remote.php/dav/files/...
from <ip> by <user> at 2020-08-31T08:12:52+02:00

UPDATE oc_filecache SET storage = ?, path_hash = MD5(CONCAT(?, SUBSTR(path, ?))), path = CONCAT(?, SUBSTR(path, ?))

[webdav] Fatal: Doctrine\DBAL\Exception\DeadlockException: An exception occurred while executing 'UPDATE `oc_filecache` SET `storage` = ?, `path_hash` = MD5(CONCAT(?, SUBSTR(`path`, ?))), `path` = CONCAT(?, SUBSTR(`path`, ?)) WHERE (`storage` = ?) AND (`path` LIKE ?)' with params [9, "files_trashbin\/files\/08.d1598854370", 59, "files_trashbin\/files\/08.d1598854370", 59, 9, "files\/<file>\/%"]:

SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction at <<closure>>

 0. /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php line 169
    Doctrine\DBAL\Driver\AbstractMySQLDriver->convertException("An exception oc ... n", Doctrine\DBAL\Dr ... ]})
 1. /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php line 145
    Doctrine\DBAL\DBALException::wrapException(Doctrine\DBAL\Driver\PDOMySql\Driver {}, Doctrine\DBAL\Dr ... ]}, "An exception oc ... n")
 2. /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php line 1063
    Doctrine\DBAL\DBALException::driverExceptionDuringQuery(Doctrine\DBAL\Driver\PDOMySql\Driver {}, Doctrine\DBAL\Dr ... ]}, "UPDATE `oc_file ... )", {1: 9,2: "files_ ... "})
 3. /var/www/nextcloud/lib/private/DB/Connection.php line 214
    Doctrine\DBAL\Connection->executeUpdate("UPDATE `oc_file ... )", [9,"files_trashb ... "], [1,2,1,2,1,1,2])
 4. /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Query/QueryBuilder.php line 203
    OC\DB\Connection->executeUpdate("UPDATE `oc_file ... )", {dcValue1: "file ... "}, {dcValue1: 2,dcV ... 2})
 5. /var/www/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php line 216
    Doctrine\DBAL\Query\QueryBuilder->execute()
 6. /var/www/nextcloud/lib/private/Files/Cache/Cache.php line 647
    OC\DB\QueryBuilder\QueryBuilder->execute()
 7. /var/www/nextcloud/lib/private/Files/Cache/Cache.php line 585
    OC\Files\Cache\Cache->moveFromCache(OC\Files\Cache\HomeCache {}, "files/<file> ... 8", "files_trashbin/files/08.d1598854370")
 8. /var/www/nextcloud/lib/private/Files/Cache/Updater.php line 199
    OC\Files\Cache\Cache->move("files/<file> ... 8", "files_trashbin/files/08.d1598854370")
 9. /var/www/nextcloud/apps/files_trashbin/lib/Trashbin.php line 289
    OC\Files\Cache\Updater->renameFromStorage(OCA\Files_Trashb ... }}, "files/<file> ... 8", "files_trashbin/files/08.d1598854370")
10. /var/www/nextcloud/apps/files_trashbin/lib/Trash/LegacyTrashBackend.php line 108
    OCA\Files_Trashbin\Trashbin::move2trash("<file> ... 8")
11. /var/www/nextcloud/apps/files_trashbin/lib/Trash/TrashManager.php line 103
    OCA\Files_Trashbin\Trash\LegacyTrashBackend->moveToTrash(OCA\Files_Trashb ... }}, "files/<file> ... 8")
12. /var/www/nextcloud/apps/files_trashbin/lib/Storage.php line 192
    OCA\Files_Trashbin\Trash\TrashManager->moveToTrash(OCA\Files_Trashb ... }}, "files/<file> ... 8")
13. /var/www/nextcloud/apps/files_trashbin/lib/Storage.php line 118
    OCA\Files_Trashbin\Storage->doDelete("files/<file> ... 8", "rmdir")
14. /var/www/nextcloud/lib/private/Files/View.php line 1161
    OCA\Files_Trashbin\Storage->rmdir("files/<file> ... 8")
15. /var/www/nextcloud/lib/private/Files/View.php line 350
    OC\Files\View->basicOperation("rmdir", "/<file> ... 8", ["delete"])
16. /var/www/nextcloud/apps/dav/lib/Connector/Sabre/Directory.php line 308
    OC\Files\View->rmdir("/<file> ... 8")
17. /var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Tree.php line 183
    OCA\DAV\Connector\Sabre\Directory->delete()
18. /var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/CorePlugin.php line 295
    Sabre\DAV\Tree->delete("files/<file> ... 8")
19. /var/www/nextcloud/3rdparty/sabre/event/lib/WildcardEmitterTrait.php line 89
    Sabre\DAV\CorePlugin->httpDelete(Sabre\HTTP\Request {}, Sabre\HTTP\Response {})
20. /var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php line 474
    Sabre\DAV\Server->emit("method:DELETE", [Sabre\HTTP\Requ ... }])
21. /var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php line 251
    Sabre\DAV\Server->invokeMethod(Sabre\HTTP\Request {}, Sabre\HTTP\Response {})
22. /var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php line 319
    Sabre\DAV\Server->start()
23. /var/www/nextcloud/apps/dav/lib/Server.php line 320
    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 167
    require_once("/var/www/nextcl ... p")

DELETE /remote.php/dav/files/<file>
from <ip> by <user> at 2020-08-31T08:12:50+02:00

+1 on tthe issue. I seem to be unable to delete folders that contain subfolders since the update.

Doing so will make the linux desktop sync-client throw errors at me for hours at which point I just killed the sync client for now...

Doing a scan --all now with the hope it will fix things.

Yesterday i tried deleting files from my IOS app and this was my error log files took forever to delete and i had to hot delete 2 or 3 times

image

https://github.com/nextcloud/server/pull/22563 may fix this. Feedback welcome.

Just applied patch 4a3f6a7616fee24c0877e2d63ca2bdd9789e9cf1 to nextcloud 19.0.2 and restarted apache2.

Trying to delete multiple files at once still gives the same error messages.

I have same problems. I can't delete multiple files. When I files one by one and wait some seconds between these steps it seems to work. But my logs are full with similar error messages like yours.

MariaDB [(none)]> SELECT @@GLOBAL.tx_isolation, @@tx_isolation;
+-----------------------+----------------+
| @@GLOBAL.tx_isolation | @@tx_isolation |
+-----------------------+----------------+
| READ-COMMITTED        | READ-COMMITTED |
+-----------------------+----------------+

Output of MariaDB SHOW ENGINE INNODB STATUS\G:

------------------------
LATEST DETECTED DEADLOCK
------------------------
2020-09-04 12:45:28 0x7fce70f63700
*** (1) TRANSACTION:
TRANSACTION 91989232, ACTIVE 0 sec starting index read
mysql tables in use 1, locked 1
LOCK WAIT 4 lock struct(s), heap size 1128, 4 row lock(s), undo log entries 1
MySQL thread id 257055, OS thread handle 140524754528000, query id 6196914 10.1.0.4 nextcloud Updating
UPDATE `oc_filecache` SET `mtime` = GREATEST(`mtime`, 1599216328), `etag` = '5f521ac8effdb' WHERE (`storage` = 1) AND (`path_hash` IN ('d41d8cd98f00b204e9800998ecf8427e', '45b963397aa40d4a0063e0d85e4fe7a1', '56c303da11d07c61688947bb3296276a'))
*** (1) WAITING FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 13131 page no 245 n bits 136 index PRIMARY of table `nextcloud`.`oc_filecache` trx id 91989232 lock_mode X locks rec but not gap waiting
Record lock, heap no 46 PHYSICAL RECORD: n_fields 18; compact format; info bits 0
 0: len 8; hex 800000000000ba29; asc        );;
 1: len 6; hex 0000057ba4e3; asc    {  ;;
 2: len 7; hex 27000001a209a0; asc '      ;;
 3: len 8; hex 8000000000000001; asc         ;;
 4: len 10; hex 66696c65732f54657374; asc files/Test;;
 5: len 30; hex 353663333033646131316430376336313638383934376262333239363237; asc 56c303da11d07c61688947bb329627; (total 32 bytes);
 6: len 8; hex 8000000000000002; asc         ;;
 7: len 4; hex 54657374; asc Test;;
 8: len 8; hex 8000000000000002; asc         ;;
 9: len 8; hex 8000000000000001; asc         ;;
 10: len 8; hex 80000000004f9b3e; asc      O >;;
 11: len 8; hex 800000005f521ac8; asc     _R  ;;
 12: len 8; hex 800000005f521ac8; asc     _R  ;;
 13: len 4; hex 80000000; asc     ;;
 14: len 8; hex 8000000000000000; asc         ;;
 15: len 13; hex 35663532316163386565346637; asc 5f521ac8ee4f7;;
 16: len 4; hex 8000001f; asc     ;;
 17: SQL NULL;

*** (2) TRANSACTION:
TRANSACTION 91989219, ACTIVE 0 sec starting index read
mysql tables in use 1, locked 1
4 lock struct(s), heap size 1128, 3 row lock(s), undo log entries 2
MySQL thread id 257058, OS thread handle 140524635174656, query id 6196920 10.1.0.5 nextcloud Updating
UPDATE `oc_filecache` SET `size` = '5217086' WHERE (`fileid` = 2) AND ((`size` <> '5217086') OR (`size` IS NULL))
*** (2) HOLDS THE LOCK(S):
RECORD LOCKS space id 13131 page no 245 n bits 136 index PRIMARY of table `nextcloud`.`oc_filecache` trx id 91989219 lock_mode X locks rec but not gap
Record lock, heap no 46 PHYSICAL RECORD: n_fields 18; compact format; info bits 0
 0: len 8; hex 800000000000ba29; asc        );;
 1: len 6; hex 0000057ba4e3; asc    {  ;;
 2: len 7; hex 27000001a209a0; asc '      ;;
 3: len 8; hex 8000000000000001; asc         ;;
 4: len 10; hex 66696c65732f54657374; asc files/Test;;
 5: len 30; hex 353663333033646131316430376336313638383934376262333239363237; asc 56c303da11d07c61688947bb329627; (total 32 bytes);
 6: len 8; hex 8000000000000002; asc         ;;
 7: len 4; hex 54657374; asc Test;;
 8: len 8; hex 8000000000000002; asc         ;;
 9: len 8; hex 8000000000000001; asc         ;;
 10: len 8; hex 80000000004f9b3e; asc      O >;;
 11: len 8; hex 800000005f521ac8; asc     _R  ;;
 12: len 8; hex 800000005f521ac8; asc     _R  ;;
 13: len 4; hex 80000000; asc     ;;
 14: len 8; hex 8000000000000000; asc         ;;
 15: len 13; hex 35663532316163386565346637; asc 5f521ac8ee4f7;;
 16: len 4; hex 8000001f; asc     ;;
 17: SQL NULL;

*** (2) WAITING FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 13131 page no 10 n bits 160 index PRIMARY of table `nextcloud`.`oc_filecache` trx id 91989219 lock_mode X locks rec but not gap waiting
Record lock, heap no 3 PHYSICAL RECORD: n_fields 18; compact format; info bits 0
 0: len 8; hex 8000000000000002; asc         ;;
 1: len 6; hex 0000057ba4f0; asc    {  ;;
 2: len 7; hex 2f000001a10794; asc /      ;;
 3: len 8; hex 8000000000000001; asc         ;;
 4: len 5; hex 66696c6573; asc files;;
 5: len 30; hex 343562393633333937616134306434613030363365306438356534666537; asc 45b963397aa40d4a0063e0d85e4fe7; (total 32 bytes);
 6: len 8; hex 8000000000000001; asc         ;;
 7: len 5; hex 66696c6573; asc files;;
 8: len 8; hex 8000000000000002; asc         ;;
 9: len 8; hex 8000000000000001; asc         ;;
 10: len 8; hex 80000000004ad20b; asc      J  ;;
 11: len 8; hex 800000005f521ac8; asc     _R  ;;
 12: len 8; hex 800000005f521217; asc     _R  ;;
 13: len 4; hex 80000000; asc     ;;
 14: len 8; hex 8000000000000000; asc         ;;
 15: len 13; hex 35663532316163386566666462; asc 5f521ac8effdb;;
 16: len 4; hex 8000001f; asc     ;;
 17: SQL NULL;

*** WE ROLL BACK TRANSACTION (1)

now im having sync issues i deleted these files but somehow still in the system. this bug is very bad

image

LATEST DETECTED DEADLOCK

2020-09-04 14:17:00 0x7f9f480c3700
* (1) TRANSACTION:
TRANSACTION 26302302, ACTIVE 0 sec starting index read
mysql tables in use 1, locked 1
LOCK WAIT 4 lock struct(s), heap size 1136, 3 row lock(s), undo log entries 1
MySQL thread id 15512, OS thread handle 140343225358080, query id 1739477 localhost axadmin updating
UPDATE oc_filecache SET size = '10056210310' WHERE (fileid = 709463) AND ((size <> '10056210310') OR (size IS NULL))

* (1) HOLDS THE LOCK(S):
RECORD LOCKS space id 32 page no 2770 n bits 312 index fs_storage_path_hash of table nextcloud.oc_filecache trx id 26302302 lock_mode X locks re c but not gap
Record lock, heap no 3 PHYSICAL RECORD: n_fields 3; compact format; info bits 32
0: len 8; hex 8000000000000003; asc ;;
1: len 30; hex 623065323032383265646231316237383333363063666661326432396335; asc b0e20282edb11b783360cffa2d29c5; (total 32 bytes);
2: len 8; hex 80000000000ae59c; asc ;;

* (1) WAITING FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 32 page no 5561 n bits 104 index PRIMARY of table nextcloud.oc_filecache trx id 26302302 lock_mode X locks rec but not gap waiting
Record lock, heap no 26 PHYSICAL RECORD: n_fields 18; compact format; info bits 0
0: len 8; hex 80000000000ad357; asc W;;
1: len 6; hex 00000191575c; asc W\;;
2: len 7; hex 02000000f618a3; asc ;;
3: len 8; hex 8000000000000003; asc ;;
4: len 12; hex 66696c65732f50686f746f73; asc files/Photos;;
5: len 30; hex 643031626236376537623731646434396664303662616439323266353231; asc d01bb67e7b71dd49fd06bad922f521; (total 32 bytes);
6: len 8; hex 80000000000000f9; asc ;;
7: len 6; hex 50686f746f73; asc Photos;;
8: len 8; hex 8000000000000002; asc ;;
9: len 8; hex 8000000000000001; asc ;;
10: len 8; hex 8000000257872eff; asc W . ;;
11: len 8; hex 800000005f5292ac; asc _R ;;
12: len 8; hex 800000005f5292aa; asc _R ;;
13: len 4; hex 80000000; asc ;;
14: len 8; hex 8000000000000000; asc ;;
15: len 13; hex 35663532393261633637356365; asc 5f5292ac675ce;;
16: len 4; hex 8000001f; asc ;;
17: len 0; hex ; asc ;;

* (2) TRANSACTION:
TRANSACTION 26302300, ACTIVE 0 sec fetching rows
mysql tables in use 1, locked 1
LOCK WAIT 477 lock struct(s), heap size 57552, 16 row lock(s), undo log entries 12
MySQL thread id 15511, OS thread handle 140343775688448, query id 1739476 localhost axadmin Searching rows for update
UPDATE oc_filecache SET storage = 3, path_hash = MD5(CONCAT('files_encryption/keys/files_trashbin/files/20-09-04 11-32-06 2306.jpg.d1599247020', SUBS TR(path, 62))), path = CONCAT('files_encryption/keys/files_trashbin/files/20-09-04 11-32-06 2306.jpg.d1599247020', SUBSTR(path, 62)) WHERE (storage = 3) AND (path LIKE 'files\_encryption/keys/files/Photos/20-09-04 11-32-06 2306.jpg/%')

* (2) HOLDS THE LOCK(S):
RECORD LOCKS space id 32 page no 5561 n bits 104 index PRIMARY of table nextcloud.oc_filecache trx id 26302300 lock_mode X locks rec but not gap
Record lock, heap no 26 PHYSICAL RECORD: n_fields 18; compact format; info bits 0
0: len 8; hex 80000000000ad357; asc W;;
1: len 6; hex 00000191575c; asc W\;;
2: len 7; hex 02000000f618a3; asc ;;
3: len 8; hex 8000000000000003; asc ;;
4: len 12; hex 66696c65732f50686f746f73; asc files/Photos;;
5: len 30; hex 643031626236376537623731646434396664303662616439323266353231; asc d01bb67e7b71dd49fd06bad922f521; (total 32 bytes);
6: len 8; hex 80000000000000f9; asc ;;
7: len 6; hex 50686f746f73; asc Photos;;
8: len 8; hex 8000000000000002; asc ;;
9: len 8; hex 8000000000000001; asc ;;
10: len 8; hex 8000000257872eff; asc W . ;;
11: len 8; hex 800000005f5292ac; asc _R ;;
12: len 8; hex 800000005f5292aa; asc _R ;;
13: len 4; hex 80000000; asc ;;
14: len 8; hex 8000000000000000; asc ;;
15: len 13; hex 35663532393261633637356365; asc 5f5292ac675ce;;
16: len 4; hex 8000001f; asc ;;
17: len 0; hex ; asc ;;

* (2) WAITING FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 32 page no 2770 n bits 312 index fs_storage_path_hash of table nextcloud.oc_filecache trx id 26302300 lock_mode X locks re c but not gap waiting
Record lock, heap no 3 PHYSICAL RECORD: n_fields 3; compact format; info bits 32
0: len 8; hex 8000000000000003; asc ;;
1: len 30; hex 623065323032383265646231316237383333363063666661326432396335; asc b0e20282edb11b783360cffa2d29c5; (total 32 bytes);
2: len 8; hex 80000000000ae59c; asc ;;

* WE ROLL BACK TRANSACTION (1)

@nickvergessen any updates on this?

Same problems here, on 19.0.2 and mysql. This bug also occurs when a Windows sync client reads files from a server (w/o any write operations). This is a production system, so I cannot install a patch, but I'm happy to provide more (debugging) information if required.

Not fixed in 19.0.3. Affected versions are:

  • 18.0.8
  • 18.0.9
  • 19.0.2
  • 19.0.3

I can confirm not fixed on 19.0.3

@acsfer Did you only update to 18.0.8 or did it work on 18.0.7 ?

Well i have one instance on 18 and I don't think the problem was present at 18.0.7.

I can only confirm that it wasn't at 19.0.1.

You can see that the linked issue #22563 remains open, so no fix has yet made it into a release. Once that issue is closed, then you might see it in a release.

Do you all have encryption enabled or had encryption enabled at some point?

Yes encryption is enabled on mine.

I did have, several years ago, probably before the migration to Nextcloud - and there might be some remnants left in the file system (I spotted owncloud_private_key and public-keys directories) but currently I have no encryption enabled.

@nickvergessen encryption is completely disabled on my side on all instances and all of them have the issue.

I have encryption enabled (default encryption module). But it looks the bug affects non-encrypted instances as well.

I have default encryption module enabled since 1-2 years.

@nickvergessen I've just set up a new instance and i can confirm problem is there; I've just upload 20 files, select them and and delete. Immediately, lots of messages like "Error deleting file..."

I'm using MariaDB 10.4, Redis 5, PHP 7.3 and Object Storage as primary (anybody else wit object storage)?

Perhaps, I'm not able to reproduce it the same way at https://try.nextcloud.com/ can anybody reproduce it there just like you do on your own instances?

In case you guys need some more info, I don't use Redis at all. Posting this because noticed some messages in this and other issues claim the issue might be related to Redis. So, it's not related, Redis is not installed on my server.

@nickvergessen I've just set up a new instance and i can confirm problem is there; I've just upload 20 files, select them and and delete. Immediately, lots of messages like "Error deleting file..."

I'm using MariaDB 10.4, Redis 5, PHP 7.3 and Object Storage as primary (anybody else wit object storage)?

On which distribution are you running this? Maybe it's some special version combination?

@MorrisJobke Ubuntu 18.04.

image

Sentry log here:

PDOException: SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction

#20 /var/www/internaltest.lan/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php(117): PDOStatement::execute
#19 /var/www/internaltest.lan/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php(117): Doctrine\DBAL\Driver\PDOStatement::execute
#18 /var/www/internaltest.lan/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(1054): Doctrine\DBAL\Connection::executeUpdate
#17 /var/www/internaltest.lan/lib/private/DB/Connection.php(214): OC\DB\Connection::executeUpdate
#16 /var/www/internaltest.lan/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Query/QueryBuilder.php(203): Doctrine\DBAL\Query\QueryBuilder::execute
#15 /var/www/internaltest.lan/lib/private/DB/QueryBuilder/QueryBuilder.php(216): OC\DB\QueryBuilder\QueryBuilder::execute
#14 /var/www/internaltest.lan/lib/private/Files/Cache/Propagator.php(101): OC\Files\Cache\Propagator::propagateChange
#13 /var/www/internaltest.lan/lib/private/Files/Cache/Updater.php(166): OC\Files\Cache\Updater::remove
#12 /var/www/internaltest.lan/lib/private/Files/View.php(329): OC\Files\View::removeUpdate
#11 /var/www/internaltest.lan/lib/private/Files/View.php(1173): OC\Files\View::basicOperation
#10 /var/www/internaltest.lan/lib/private/Files/View.php(718): OC\Files\View::unlink
#9 /dav/lib/Connector/Sabre/File.php(458): OCA\DAV\Connector\Sabre\File::delete
#8 /var/www/internaltest.lan/3rdparty/sabre/dav/lib/DAV/Tree.php(183): Sabre\DAV\Tree::delete
#7 /var/www/internaltest.lan/3rdparty/sabre/dav/lib/DAV/CorePlugin.php(295): Sabre\DAV\CorePlugin::httpDelete
#6 /var/www/internaltest.lan/3rdparty/sabre/event/lib/WildcardEmitterTrait.php(89): Sabre\DAV\Server::emit
#5 /var/www/internaltest.lan/3rdparty/sabre/dav/lib/DAV/Server.php(474): Sabre\DAV\Server::invokeMethod
#4 /var/www/internaltest.lan/3rdparty/sabre/dav/lib/DAV/Server.php(251): Sabre\DAV\Server::start
#3 /var/www/internaltest.lan/3rdparty/sabre/dav/lib/DAV/Server.php(319): Sabre\DAV\Server::exec
#2 /dav/lib/Server.php(320): OCA\DAV\Server::exec
#1 /dav/appinfo/v2/remote.php(35): require_once
#0 /var/www/internaltest.lan/remote.php(167): null

I've just set up a new instance and i can confirm problem is there; I've just upload 20 files, select them and and delete. Immediately, lots of messages like "Error deleting file..."

I did the same minutes ago... I didn't even need to upload any files - once I select multiple files (photos that are created by NC installer in user space by default) and try to delete them, the same message is displayed. Didn't even enable encryption, completely fresh and stock installation.

CentOS 7, Apache 2.4, PHP 7.4.9. No Redis or another caching module enabled.

@nickvergessen I've just set up a new instance and i can confirm problem is there; I've just upload 20 files, select them and and delete. Immediately, lots of messages like "Error deleting file..."

I'm using MariaDB 10.4, Redis 5, PHP 7.3 and Object Storage as primary (anybody else wit object storage)?

Perhaps, I'm not able to reproduce it the same way at https://try.nextcloud.com/ can anybody reproduce it there just like you do on your own instances?

Hello,
I uploaded a folder with 19 random items to https://try.nextcloud.com/. Then I entered that folder, marked all the files and deleted them. Nextcloud only sent 18 of the 19 files to the trash and I received an error message:

nextcloud_error

Thanks @AntonioDeTeo so this CAN BE reproduced at Nextcloud demo1 instance too @MorrisJobke !

@nickvergessen I've just set up a new instance and i can confirm problem is there; I've just upload 20 files, select them and and delete. Immediately, lots of messages like "Error deleting file..."

I'm using MariaDB 10.4, Redis 5, PHP 7.3 and Object Storage as primary (anybody else wit object storage)?

On which distribution are you running this? Maybe it's some special version combination?

My setup is Ubuntu 20.04 PHP7.4 MySQL 8 Redis Server Apache 2

I've tried it a few times on try.nextcloud.com but no issues deleting files :cry: 30 files at a time, select - choose from ... menu 'delete', they get deleted, no errors.

@jospoortvliet just right now.

image

One second time:

image
image

@jospoortvliet based on my input this was not happening on version 18.05 and lower so im not sure what changed in the code.
@acsfer do you agree ?

Can't tell about v18, but it was not happening in 19.0.1.

For me I did see it happening on 19.0.1 but not as much it was random on 19.0.1

For me this is also occurring since version 19.0.1. The screencast shows the error occurring from the client sync.

Delete error

This is the error in the log

[webdav] Fatal: Doctrine\DBAL\Exception\DeadlockException: An exception occurred while executing 'UPDATE `oc_filecache` SET `size` = ? WHERE (`fileid` = ?) AND ((`size` <> ?) OR (`size` IS NULL))' with params [2623495, 351251, 2623495]:

SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction at <<closure>>

 0. /home/ewiqzonl/public_html/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php line 169
    Doctrine\DBAL\Driver\AbstractMySQLDriver->convertException("An exception oc ... n", Doctrine\DBAL\Dr ... ]})
 1. /home/ewiqzonl/public_html/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php line 145
    Doctrine\DBAL\DBALException::wrapException(Doctrine\DBAL\Driver\PDOMySql\Driver {}, Doctrine\DBAL\Dr ... ]}, "An exception oc ... n")
 2. /home/ewiqzonl/public_html/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php line 1063
    Doctrine\DBAL\DBALException::driverExceptionDuringQuery(Doctrine\DBAL\Driver\PDOMySql\Driver {}, Doctrine\DBAL\Dr ... ]}, "UPDATE `oc_file ... )", {1: 2623495,2: " ... 5})
 3. /home/ewiqzonl/public_html/lib/private/DB/Connection.php line 214
    Doctrine\DBAL\Connection->executeUpdate("UPDATE `oc_file ... )", [2623495,"*** se ... 5], [2,1,2])
 4. /home/ewiqzonl/public_html/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Query/QueryBuilder.php line 203
    OC\DB\Connection->executeUpdate("UPDATE `oc_file ... )", {dcValue1: "***  ... 5}, {dcValue1: 1,dcValue2: 2,dcValue3: 2})
 5. /home/ewiqzonl/public_html/lib/private/DB/QueryBuilder/QueryBuilder.php line 216
    Doctrine\DBAL\Query\QueryBuilder->execute()
 6. /home/ewiqzonl/public_html/lib/private/Files/Cache/Cache.php line 363
    OC\DB\QueryBuilder\QueryBuilder->execute()
 7. /home/ewiqzonl/public_html/lib/private/Files/Cache/Cache.php line 898
    OC\Files\Cache\Cache->update("*** sensitive parameters replaced ***")
 8. /home/ewiqzonl/public_html/lib/private/Files/Cache/HomeCache.php line 43
    OC\Files\Cache\Cache->calculateFolderSize("files/Pictures/Screenshots", OC\Files\Cache\CacheEntry {})
 9. /home/ewiqzonl/public_html/lib/private/Files/Cache/Cache.php line 830
    OC\Files\Cache\HomeCache->calculateFolderSize("files/Pictures/Screenshots", null)
10. /home/ewiqzonl/public_html/lib/private/Files/Cache/Cache.php line 842
    OC\Files\Cache\Cache->correctFolderSize("files/Pictures/Screenshots")
11. /home/ewiqzonl/public_html/lib/private/Files/Cache/Updater.php line 217
    OC\Files\Cache\Cache->correctFolderSize("files/Pictures/ ... g")
12. /home/ewiqzonl/public_html/apps/files_trashbin/lib/Trashbin.php line 289
    OC\Files\Cache\Updater->renameFromStorage(OCA\Files_Trashb ... }}, "files/Pictures/ ... g", "files_trashbin/ ... 9")
13. /home/ewiqzonl/public_html/apps/files_trashbin/lib/Trash/LegacyTrashBackend.php line 108
    OCA\Files_Trashbin\Trashbin::move2trash("Pictures/Screen ... g")
14. /home/ewiqzonl/public_html/apps/files_trashbin/lib/Trash/TrashManager.php line 103
    OCA\Files_Trashbin\Trash\LegacyTrashBackend->moveToTrash(OCA\Files_Trashb ... }}, "files/Pictures/ ... g")
15. /home/ewiqzonl/public_html/apps/files_trashbin/lib/Storage.php line 192
    OCA\Files_Trashbin\Trash\TrashManager->moveToTrash(OCA\Files_Trashb ... }}, "files/Pictures/ ... g")
16. /home/ewiqzonl/public_html/apps/files_trashbin/lib/Storage.php line 99
    OCA\Files_Trashbin\Storage->doDelete("files/Pictures/ ... g", "unlink")
17. /home/ewiqzonl/public_html/lib/private/Files/View.php line 1161
    OCA\Files_Trashbin\Storage->unlink("files/Pictures/ ... g")
18. /home/ewiqzonl/public_html/lib/private/Files/View.php line 718
    OC\Files\View->basicOperation("unlink", "/Pictures/Scree ... g", ["delete"])
19. /home/ewiqzonl/public_html/apps/dav/lib/Connector/Sabre/File.php line 455
    OC\Files\View->unlink("/Pictures/Scree ... g")
20. /home/ewiqzonl/public_html/3rdparty/sabre/dav/lib/DAV/Tree.php line 183
    OCA\DAV\Connector\Sabre\File->delete()
21. /home/ewiqzonl/public_html/3rdparty/sabre/dav/lib/DAV/CorePlugin.php line 295
    Sabre\DAV\Tree->delete("files/arnomuhre ... g")
22. /home/ewiqzonl/public_html/3rdparty/sabre/event/lib/WildcardEmitterTrait.php line 89
    Sabre\DAV\CorePlugin->httpDelete(Sabre\HTTP\Request {}, Sabre\HTTP\Response {})
23. /home/ewiqzonl/public_html/3rdparty/sabre/dav/lib/DAV/Server.php line 474
    Sabre\DAV\Server->emit("method:DELETE", [Sabre\HTTP\Requ ... }])
24. /home/ewiqzonl/public_html/3rdparty/sabre/dav/lib/DAV/Server.php line 251
    Sabre\DAV\Server->invokeMethod(Sabre\HTTP\Request {}, Sabre\HTTP\Response {})
25. /home/ewiqzonl/public_html/3rdparty/sabre/dav/lib/DAV/Server.php line 319
    Sabre\DAV\Server->start()
26. /home/ewiqzonl/public_html/apps/dav/lib/Server.php line 320
    Sabre\DAV\Server->exec()
27. /home/ewiqzonl/public_html/apps/dav/appinfo/v2/remote.php line 35
    OCA\DAV\Server->exec()
28. /home/ewiqzonl/public_html/remote.php line 167
    require_once("/home/ewiqzonl/ ... p")

DELETE /remote.php/dav/files/arnomuhren/Pictures/Screenshots/Screenshot_20200831-001253_Telegram_FOSS.png
from 185.65.134.233 by arnomuhren at 2020-09-14T20:00:10+00:00

Spaces dont make a difference. The last image shows the diff i reverted in my PR which didn't work. It looks like we are now just locking too long overall

I had these issues before version 18, and now they reappeared with version 19.0.3
(Is there a downgrade option back to 18.x.x?)

I hab these issues before version 18, and now they reappeared with version 19.0.3

I run multiple NC instances since version 15, and never had similar issues with any version, except v19.

I hab these issues before version 18, and now they reappeared with version 19.0.3

I run multiple NC instances since version 15, and never had similar issues with any version, except v19.

Me too.

@kitzler-walli I agree with you. I had these issues in 18 for quite some time and they appeared with 19.0.2 again

same problem ao NC 19.0.3 + postgresql
here a snippet from tcpdump

`

Created
Date: Thu, 17 Sep 2020 13:00:37 GMT
Server: Apache/2.4.29 (Ubuntu)
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate
Pragma: no-cache
Referrer-Policy: no-referrer
X-Content-Type-Options: nosniff
X-Download-Options: noopen
X-Frame-Options: SAMEORIGIN
X-Permitted-Cross-Domain-Policies: none
X-Robots-Tag: none
X-XSS-Protection: 1; mode=block
Content-Security-Policy: default-src 'none';
X-OC-MTime: accepted
X-Hash-SHA256: 67b9678646223b9b652123e40619714c3874ed44fee352e9609b0a7f902b1b16
X-Hash-SHA1: 991ab725bce1a41bf25ee7fc3e6dda8bf827639b
X-Hash-MD5: c6d16b1eb39f689a8b6cce88206c66da
OC-FileId: 00189919oc02irckjlv9
OC-ETag: "c6786d7974cb20d5363f9e9b899ef4d6"
Set-Cookie: oc_sessionPassphrase=9UR9y%2BIxHuIl...um6tNqNvQCQqx4RmGNbf4n%2BJD; path=/; secure; HttpOnly; SameSite=Lax
Set-Cookie: __Host-nc_sameSiteCookielax=true; path=/; httponly;secure; expires=Fri, 31-Dec-2100 23:59:59 GMT; SameSite=lax
Set-Cookie: __Host-nc_sameSiteCookiestrict=true; path=/; httponly;secure; expires=Fri, 31-Dec-2100 23:59:59 GMT; SameSite=strict
Set-Cookie: oc02irckjlv9=qo7bdafl7b0psq9vvuub4par7c; path=/; secure; HttpOnly; SameSite=Lax
Content-Length: 0
ETag: "c6786d7974cb20d5363f9e9b899ef4d6"
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/html; charset=UTF-8

MOVE /remote.php/webdav/clap/d/KG/6TFDGKXGZEGWRZOGTDFDF4YEGAZO6Q/Xf7evP_k8kFGUUWtd1aJGTCxUV1DcyW19dCkISIyrXJaFvbhjew84H9IQ4TtTEgJ0VHNkYUNtZ8=.c9r HTTP/1.1
Destination: http://nextcloud.mydomain.de/remote.php/webdav/clap/d/IZ/SNIPVYTWZVVDZ5W2VQ2SJOAEQNWFEA/m7tbzXUuYdZSg49Zt5BwXxT5htQJr9kvZXpxwg==.c9r
Content-Type: text/xml
Depth: infinity
Authorization: Basic c3RlZmZlbi5yZW5rZXI6SEs1ZnAtb...Vdnc2YtQmpBSkg=
Host: nextcloud.mydomain.de
Connection: Keep-Alive
Accept-Encoding: gzip
User-Agent: okhttp/4.7.2

HTTP/1.1 500 Internal Server Error
Date: Thu, 17 Sep 2020 13:00:38 GMT
Server: Apache/2.4.29 (Ubuntu)
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate
Pragma: no-cache
Referrer-Policy: no-referrer
X-Content-Type-Options: nosniff
X-Download-Options: noopen
X-Frame-Options: SAMEORIGIN
X-Permitted-Cross-Domain-Policies: none
X-Robots-Tag: none
X-XSS-Protection: 1; mode=block
Content-Security-Policy: default-src 'none';
Set-Cookie: oc_sessionPassphrase=%2FCZbsvYyh...bKEYq4CxkU5FxjFXDQiOvCaR; path=/; secure; HttpOnly; SameSite=Lax
Set-Cookie: __Host-nc_sameSiteCookielax=true; path=/; httponly;secure; expires=Fri, 31-Dec-2100 23:59:59 GMT; SameSite=lax
Set-Cookie: __Host-nc_sameSiteCookiestrict=true; path=/; httponly;secure; expires=Fri, 31-Dec-2100 23:59:59 GMT; SameSite=strict
Set-Cookie: oc02irckjlv9=n50p2bldqgvdn14k0mnqsrbh5k; path=/; secure; HttpOnly; SameSite=Lax
Connection: close
Transfer-Encoding: chunked
Content-Type: application/xml; charset=utf-8

36a


Doctrine\DBAL\Exception\DeadlockException
An exception occurred while executing 'UPDATE "oc_filecache" SET "size" = ? WHERE ("fileid" = ?) AND (("size" <> ?) OR ("size" IS NULL))' with params [76228833, 189776, 76228833]:

SQLSTATE[40P01]: Deadlock detected: 7 ERROR: deadlock detected
DETAIL: Process 662056 waits for ShareLock on transaction 349595545; blocked by process 662212.
Process 662212 waits for ShareLock on transaction 349595558; blocked by process 650488.
Process 650488 waits for ExclusiveLock on tuple (5784,152) of relation 456803 of database 456663; blocked by process 662056.
HINT: See server log for query details.
CONTEXT: while locking tuple (5784,152) in relation "oc_filecache"

0

`

@nickvergessen any updates on this case?

Hello everyone! Dose anyone have any updates on this?

22563

For completeness: Yes, sqlite instances are affected as well.

@nickvergessen I just appied the fix and still nothing? or is the fix still being worked on?

image

I get the error when syncing new files (via desktop client), rather than deleting them.

Can we please reopen this ticket ?

Earlier I set up a new Nextcloud instance (version 20.0) and the problem still exists.
2020-10-06_20-40-25

I've the same issue with 19.0.3
Ubuntu 18
MySQL 5.7
PHP 7.3.23

This entry is shown 740x in the log viewer:
Doctrine\DBAL\Exception\DeadlockException: An exception occurred while executing 'UPDATEoc_filecacheSETsize= ? WHERE (fileid= ?) AND ((size<> ?) OR (sizeIS NULL))' with params [121812234, 92670, 121812234]: SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction

19.0.4 seems to trigger this less often, but problem remains.

19.0.4 seems to trigger this less often, but problem remains.

I'm on 20 and same.

Same issue on NC20 Docker (MariaDB (tested with postgres and same results, but they appear less often), redis).
Steps to reproduce :

  1. Create a bunch of files touch $(seq 1 150) the size doesn't matter.
  2. Upload them/Sync them
  3. Select all and delete
    What should happen: all files are moved to the trash bin.
    What actually happens: only a few files are moved, and the others result in a bunch of errors.
    The logs & MariaDB are reporting that deadlocks are the cause of this issue.

EDIT tested this on a vanilla sqlite docker NC20 instance, same issue.
EDIT2 Tried this on a vanilla postgresql docker NC20 instance, and couldn't get a lock issue even after uploading 200 files and deleting them. No error at all.

same on docker 19.0.3

hello any updates on this?

Hello, i am on v20 + postgresql 12 and have the same issue

NC20, same problem. Yes, mark it as an offtopic :)

They included/backported to 20 https://github.com/nextcloud/server/pull/23185 in the 20.0.1 update. Also supposed to resolve this. Will update my server tonight and check.

Edit: as commented below by acsfer and axheli, this does not fix it. Thanks for the update.
Edit2: actually updating did solve the issue for me...

@Broekman it doesn't fix. See https://github.com/nextcloud/server/pull/23109 and previous comments here in this issue.

@Broekman Yes, @acsfer is correct #23109 doesn't fix this issue.

Any leads on this?

Today, I've tested this in 3 of my instances with nextcloud encryption disabled.
These are existing instances (all under Nextcloud 19.0.4) where I've face this issue before.

As of today, in none of them, i was able to reproduce the problem.
Uploaded and deleted more than 200 files in each without any log message.

Enabled:
  - accessibility: 1.5.0
  - activity: 2.12.1
  - cloud_federation_api: 1.2.0
  - comments: 1.9.0
  - contactsinteraction: 1.0.0
  - dav: 1.15.0
  - external: 3.6.0
  - federatedfilesharing: 1.9.0
  - federation: 1.9.0
  - files: 1.14.0
  - files_pdfviewer: 1.8.0
  - files_rightclick: 0.16.0
  - files_sharing: 1.11.0
  - files_trashbin: 1.9.0
  - files_versions: 1.12.0
  - files_videoplayer: 1.8.0
  - logreader: 2.4.0
  - lookup_server_connector: 1.7.0
  - notifications: 2.7.0
  - oauth2: 1.7.0
  - onlyoffice: 6.1.0
  - password_policy: 1.9.1
  - photos: 1.1.0
  - privacy: 1.3.0
  - provisioning_api: 1.9.0
  - ransomware_protection: 1.7.0
  - settings: 1.1.0
  - sharebymail: 1.9.0
  - systemtags: 1.9.0
  - theming: 1.10.0
  - twofactor_backupcodes: 1.8.0
  - twofactor_totp: 5.0.0
  - twofactor_u2f: 6.0.0
  - viewer: 1.3.0
  - workflowengine: 2.1.0

Today, I've tested this in 3 of my instances with nextcloud encryption disabled.
These are existing instances (all under Nextcloud 19.0.4) where I've face this issue before.

As of today, in none of them, i was able to reproduce the problem.
Uploaded and deleted more than 200 files in each without any log message.

So you're not getting the problem anymore ?!

@axheli i wasn't able to reproduce it anymore, no. 馃

@acsfer what in the world happen? Man that's wired.

Now you're mentioning it, beside app and server software updates as usual _(like PHP 7.4.11 to 7.4.12, etc)_ I've moved from Redis to Memcached 2 weeks ago:

<?php
$CONFIG = [
 'filelocking.enabled' => false,
 'memcache.local' => '\\OC\\Memcache\\APCu',
 'memcache.distributed' => '\\OC\\Memcache\\Memcached',
 'memcached_servers' => [
    ['memcached.lan', 11211],
  ],
  'memcached_options' => [
    // Set timeouts to 5000ms
    \Memcached::OPT_CONNECT_TIMEOUT => 5000,
    \Memcached::OPT_RETRY_TIMEOUT => 5000,
    \Memcached::OPT_SEND_TIMEOUT => 5000,
    \Memcached::OPT_RECV_TIMEOUT => 5000,
    \Memcached::OPT_POLL_TIMEOUT => 5000,
    \Memcached::OPT_LIBKETAMA_COMPATIBLE => true,
    \Memcached::OPT_BINARY_PROTOCOL => true,
    \Memcached::OPT_SERIALIZER => \Memcached::SERIALIZER_IGBINARY,
  ],
];

@Broekman it doesn't fix. See #23109 and previous comments here in this issue.

Just did the updates to 20.0.1 today and it actually solved the issue for me (with Redis).

@Broekman it doesn't fix. See #23109 and previous comments here in this issue.

Just did the updates to 20.0.1 today and it actually solved the issue for me (with Redis).

Are you using encryption ?

@Broekman it doesn't fix. See #23109 and previous comments here in this issue.

Just did the updates to 20.0.1 today and it actually solved the issue for me (with Redis).

Are you using encryption ?

Yes, server side (default encryption module).

All specifications for reference:
Arch Linux (kern. 5.9.2-arch1-1) x86_64
Nginx 1.19.3-1
Nextcloud 20.0.1-1
PHP (fpm) 7.4.12-1
MySQL (MariaDB) 10.5.6
php-redis 5.3.2-1
Server side encryption (default encryption module).

  'memcache.local' => '\\OC\\Memcache\\APCu',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'redis' =>
  array (
    'host' => '/run/redis/redis.sock',
    'port' => 0,
    'dbindex' => 0,
    'password' => 'xxxxxx',
    'timeout' => 1.5,
  ),

After making a completely fresh installation of 20.0.1 on the same server (using the same settings, including default encryption module), problem seems to be gone.

Stilling having this issue on Nextcloud 20.0.1 fresh new install no encryption

I will have to add since the fresh install with encryption this error does not come up very often.

Just recently encountered this issue again. Therefore: still an issue with 20.0.1.

Found this thread while looking at https://github.com/nextcloud/server/issues/7312, which may be caused by this issue, or I'm just experiencing both at once. My one-user server instance is almost totally unresponsive, 504ing all but a couple times. I'm running Nextcloud 20.0.1 in the linuxserver/nextcloud Docker container on unRAID with Redis for cache and locks.
In investigating, I noticed that my oc_filecache table was very large, the oc_filecache.ibd file was 50GB.

+--------------------------------------------+--------+---------+------------+-----------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+---------------------+------------+-------------+----------+-----------------------+---------+------------------+-----------+
| Name                                       | Engine | Version | Row_format | Rows      | Avg_row_length | Data_length | Max_data_length | Index_length | Data_free | Auto_increment | Create_time         | Update_time         | Check_time | Collation   | Checksum | Create_options        | Comment | Max_index_length | Temporary |
+--------------------------------------------+--------+---------+------------+-----------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+---------------------+------------+-------------+----------+-----------------------+---------+------------------+-----------+
| oc_filecache                               | InnoDB |      10 | Compressed | 100805590 |            350 | 35342245888 |               0 |  15323897856 |   9961472 |      189033890 | 2020-11-15 00:34:22 | 2020-11-15 00:54:54 | NULL       | utf8mb4_bin |     NULL | row_format=COMPRESSED |         |                0 | N         |

In my case I believe it ballooned due to the issue https://github.com/nextcloud/server/issues/23238, where Nextcloud may have recursively navigated through broken symlinks created by files managed by a separate program. I had several rows in the oc_filecache table with //// parts of file names repeating until apparent max file name length. I ran DELETE FROM oc_filecache WHERE path LIKE '%//%'; as recommended in https://github.com/nextcloud/server/issues/23238 but it failed with a generic error. The file size did not change. Someone in https://github.com/nextcloud/server/issues/7312 suggested that the table was mostly empty and defragmented. As you can see above my table has some free space but not a lot. I attempted to run OPTIMIZE TABLE oc_filecache, but it failed with the following error:

+------------------------+----------+----------+-------------------------------------------------------------------+
| Table                  | Op       | Msg_type | Msg_text                                                          |
+------------------------+----------+----------+-------------------------------------------------------------------+
| nextcloud.oc_filecache | optimize | note     | Table does not support optimize, doing recreate + analyze instead |
| nextcloud.oc_filecache | optimize | error    | Duplicate entry '181940707' for key 'PRIMARY'                     |
| nextcloud.oc_filecache | optimize | status   | Operation failed                                                  |
+------------------------+----------+----------+-------------------------------------------------------------------+

Hoping for a fix soon! Also a occ files:clear_cache would be super useful!

Just recently encountered this issue again. Therefore: still an issue with 20.0.1.

This issue should deserve more attention, a single user can render a whole Nextcloud instance unusable just by uploading a bunch of files at once through the web interface.
Maybe a quick and dirty fix could be a brute-force solution doing a before update statement trigger on oc_filecache that takes a share row exclusive lock?

This issue should deserve more attention, a single user can render a whole Nextcloud instance unusable just by uploading a bunch of files at once through the web interface.
Maybe a quick and dirty fix could be a brute-force solution doing a before update statement trigger on oc_filecache that takes a share row exclusive lock?

This!

We dont need a "useful" dashboard or users' online status indicators. What is important is that core-functionality is working reliably.

This issue should deserve more attention, a single user can render a whole Nextcloud instance unusable just by uploading a bunch of files at once through the web interface.
Maybe a quick and dirty fix could be a brute-force solution doing a before update statement trigger on oc_filecache that takes a share row exclusive lock?

This!

We dont need a "useful" dashboard or users' online status indicators. What is important is that core-functionality is working reliably.

Well said! 馃憦 Couldn't agree more

I too confirm that the issue isn't (fully) gone. Although not seen for a while and for sure not as bad as before, it still happened once or twice over the past 20 days. For me at least it isn't really causing any headaches anymore compared to before.

All specifications for reference:
Arch Linux (kern. 5.9.2-arch1-1) x86_64
Nginx 1.19.3-1
Nextcloud 20.0.1-1
PHP (fpm) 7.4.12-1
MySQL (MariaDB) 10.5.6
php-redis 5.3.2-1
Server side encryption (default encryption module).
Four users.

  'memcache.local' => '\\OC\\Memcache\\APCu',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'redis' =>
  array (
    'host' => '/run/redis/redis.sock',
    'port' => 0,
    'dbindex' => 0,
    'password' => 'xxxxxx',
    'timeout' => 1.5,
  ),

I got this problem 1st time today Vers 19.1 ... I renamed the locked file via web like:

Old name: Filename.mp4
New name: Filenamexxx.mp4

after this i was able to delete file... hope this helps someone

I was just trying to sync a library of ~8000 small svg-files totalling about 13MB.
My nextcloud-client log and apache error log is a total mess: about 4000 error messages about the SQL deadlock.
Also my windows-notification bar is flowing over with sync errors.

As a temporary workaround, can't we lower the severity of these error messages to "NOTICE" or something since these errors usually are not fatal? Also, the sync issues are solved during the next sync batch anyway.

Doctrine\DBAL\Exception\UniqueConstraintViolationException: An exception occurred while executing 'UPDATE oc_filecache SET storage = ?, path = ?, path_hash = ?, name = ?, parent = ? WHERE fileid = ?' with params [7, "files_encryption/keys/files_trashbin/files/IMG_20201127_210544.jpg.d1606534166", "a7e731be82d0e2437bf88e56ff9d1cea", "IMG_20201127_210544.jpg.d1606534166", 201065, 200988]: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '7-a7e731be82d0e2437bf88e56ff9d1cea' for key 'fs_storage_path_hash'

Was this page helpful?
0 / 5 - 0 ratings