Skip to content

OCA\DAV\Connector\Sabre\Exception\FileLocked - DB race condition #8239

Description

Steps to reproduce

  1. Create a new user via admin user
  2. Login with new user
  3. Try to delete the files

Expected behaviour

All files should be deleted

Actual behaviour

All files, except "Nextcloud Manual.pdf" gets deleted

I checked my db for the "locked" table, but all files are set to "0"
Yes, this always happens
Yes, this also happend with other files, as well when I tried to rename files

All tests passed and cron works correct

Server configuration

Operating system: Ubuntu 16.04.3 LTS

Web server: Apache/2.4.29

Database: MySQL 5.7.21

PHP version: 7.2.2

Nextcloud version: 13

Updated from an older Nextcloud/ownCloud or fresh install: clean install

Where did you install Nextcloud from: wget, clean install

Logging

OCA\DAV\Connector\Sabre\Exception\FileLocked: "Nextcloud Manual.pdf" is locked
/var/www/html/cloud/3rdparty/sabre/dav/lib/DAV/Tree.php - line 179: OCA\DAV\Connector\Sabre\File->delete()
/var/www/html/cloud/3rdparty/sabre/dav/lib/DAV/CorePlugin.php - line 287: Sabre\DAV\Tree->delete('Nextcloud Manua...')
[internal function] Sabre\DAV\CorePlugin->httpDelete(Object(Sabre\HTTP\Request), Object(Sabre\HTTP\Response))
/var/www/html/cloud/3rdparty/sabre/event/lib/EventEmitterTrait.php - line 105: call_user_func_array(Array, Array)
/var/www/html/cloud/3rdparty/sabre/dav/lib/DAV/Server.php - line 479: Sabre\Event\EventEmitter->emit('method DELETE', Array)
/var/www/html/cloud/3rdparty/sabre/dav/lib/DAV/Server.php - line 254: Sabre\DAV\Server->invokeMethod(Object(Sabre\HTTP\Request), Object(Sabre\HTTP\Response))
/var/www/html/cloud/apps/dav/appinfo/v1/webdav.php - line 80: Sabre\DAV\Server->exec()
/var/www/html/cloud/remote.php - line 164: require_once('/var/www/html/c...')
{main}

Activity

  1. FriedCircuits commented on Feb 15, 2018

    @FriedCircuits

    I have the same exact issue. Mine started when I removed a directory while it was still syncing. I had to fix the php file size and now if it put it back it won't sync or if I deleted it I can't delete the empty folder on the server. The data store has a bunch of file parts. But the error in the log is the same as above whenever I try and delete the folder in the UI.

    I am on php 7.0 and NC 13.

  2. FriedCircuits commented on Feb 15, 2018

    @FriedCircuits

    Just FYI I fixed it by deleting the file from the filecache table and then deleting the folder manually. Hope that helps you. Then ran scan files for the user to be sure everything was well.

    Edit: Seems like I can't use the folder name again. If I do the problem comes back and it won't sync and get the same error above again in the logs.

  3. nickvergessen commented on Feb 22, 2018

    @nickvergessen
    Member

    are you using database file locking of nextcloud? Please post the output of ./occ config:list system

  4. FriedCircuits commented on Mar 18, 2018

    @FriedCircuits

    Sorry for the delay. I haven't seen the error since but in my case it looks like file locking is enabled.

    "filelocking.enabled": true,

  5. castillo92 commented on Mar 31, 2018

    @castillo92
    Contributor

    Me too, waiting for response.

    NextCloud v13.0.1

    EDIT:

    Well, I fix it adding this line to the config file....

    sudo nano /var/www/nextcloud/config/config.php
    
    'filelocking.enabled' => false,
    
  6. major5012 commented on Apr 30, 2018

    @major5012

    @nickvergessen I have a number of these errors also.

    "OCA\DAV\Connector\Sabre\Exception\FileLocked"

    NC 13.0.2
    PHP 5.6.35

    ./occ config:list system

        "memcache.local": "\\OC\\Memcache\\APCu",
        "filelocking.enabled": "true",
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "redis": {
            "host": "***REMOVED SENSITIVE VALUE***",
            "port": 6379,
            "timeout": 0
        },
    
  7. dinkonin commented on Jun 13, 2018

    @dinkonin

    Same problem with Nextcloud 13.0.4 , php 7.1.18 , redis 4.0.9 with this settings

      'memcache.local' => '\\OC\\Memcache\\APCu',
      'memcache.locking' => '\\OC\\Memcache\\Redis',
      'redis' => 
       array (
        'host' => 'localhost',
        'port' => 6379,
      ),
    
    
  8. stephanedupont commented on Jun 16, 2018

    @stephanedupont

    Same problem since I updated to Nextcloud 13.0.4. Was working fine before. Now if I'm doing some stuff like updating/deleting a file that was just created moments ago, I have this error.

    Fixed by adding

    'filelocking.enabled' => false,
    

    ... but what does that imply? Is it safe to disable file locking?

  9. tapete commented on Jun 17, 2018

    @tapete

    Same problem since I updated to Nextcloud 13.0.4. Was working fine before.

    Exactly the same problem with my nextcloud instance. It also came with the 13.0,4 update. It seems that the error occurs only if a file is synced, which is locked at my local NTFS file system.

  10. bl4ckOut commented on Jun 18, 2018

    @bl4ckOut

    Same here since 13.0.4. Disabling file locking is not a solution for me.

    @linucksrox
    I can confirm that oc_file_locks table is empty. Only temporary solution which works for me is to:

    • occ files:cleanup
    • occ files:scan -all
    • occ maintenance:repair

    (currently my repair.sh)

  11. linucksrox commented on Jun 18, 2018

    @linucksrox

    I have tried the solution outlined on the Nextcloud forums (https://help.nextcloud.com/t/file-is-locked-how-to-unlock/1883) but it doesn't help with our issue. We also tried rebooting the client's machine and rebooting the Nextcloud server to no avail.
    Another interesting note is that there are 0 records in the oc_file_locks table but the client is still complaining that the files are locked and new entries are still appearing in the server log.

  12. linucksrox commented on Jun 18, 2018

    @linucksrox

    In my case, I only had one user complaining about this problem so I did these steps manually:

    • paused their desktop client
    • moved the folder (and affected files) to another location
    • deleted the folder/files from the web interface
    • ran occ files:scan --path="username"
    • unpaused the client (getting green checkmark at this point)
    • moved folder back into place and let it sync

    At this point there were some complaints from the client, but after waiting a few minutes they cleared themselves

    • went into redis-cli to check which files were locked, as I use redis on a Unix socket, I ran redis-cli -s /var/run/redis/redis.sock --scan
    • looked up the file hashes after the fileslocked/ portion of the keys in the oc_filecache table path_hash column (I'm assuming these go together) and confirmed none were present in oc_filecache
    • deleted those keys from the redis database one at a time: redis-cli -s /var/run/redis/redis.sock
      • DEL "fullkeyvalue"

    Maybe none of the redis stuff I did helped anything, but if I run into this issue again I will start by clearing the keys from redis first to see if that makes any difference as it seems to be the only place left that nobody is talking about here.

  13. 27 remaining items

  14. tapete commented on Jul 9, 2018

    @tapete

    Ok, I applied the changes in MemcacheLockingProvider.php yesterday and up to now there are no locking errors. Thanks to everyone!

  15. dutchwhizzman commented on Jul 9, 2018

    @dutchwhizzman

    So what happens next, will it make it to 13.0.5 ?

  16. MorrisJobke commented on Jul 10, 2018

    @MorrisJobke
    Member

    So what happens next, will it make it to 13.0.5 ?

    Yes - it's planned for 13.0.5

  17. dutchwhizzman commented on Aug 8, 2018

    @dutchwhizzman

    I see 13.0.5 is out. Did this make it to the release?

  18. linucksrox commented on Aug 8, 2018

    @linucksrox

    Yep, that fix posted above was merged into stable13 on July 10, then 13.0.5 was released on July 23 including the fix. We should probably close this issue.

  19. albertogscotti commented on Aug 10, 2018

    @albertogscotti

    Still have the issue on 13.0.5

  20. Temtaime commented on Aug 11, 2018

    @Temtaime
    Member

    Doctrine\DBAL\Exception\UniqueConstraintViolationException: An exception occurred while executing 'INSERT INTO oc_filecache (mimepart,mimetype,mtime,size,etag,storage_mtime,permissions,parent,checksum,path_hash,path,name,storage) SELECT ?,?,?,?,?,?,?,?,?,?,?,?,? FROM oc_filecache WHERE storage = ? AND path_hash = ? HAVING COUNT(*) = 0' with params ["1", "2", 1533325280, -1, "5b64afe067e8e", 1533325280, 31, 149894, "", "7fc567a03abec499cb8690b5e6b8f337", "files_versions/tools/firmware", "firmware", 1, 1, "7fc567a03abec499cb8690b5e6b8f337"]: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '1-7fc567a03abec499cb8690b5e6b8f337' for key 'fs_storage_path_hash'

    Seems to be related, having this for 13.0.5

  21. jacobHclarkson commented on Aug 19, 2018

    @jacobHclarkson

    I am having the same issue. Version 13.0.5.

  22. idevwebs commented on Aug 20, 2018

    @idevwebs

    This just happened here today on 13.0.4. I then updated to 13.0.5 and the uploads are working in the app again. Not sure if this is because of the upgrade process or if latest version did fix it. Will post back if comes up again.

  23. removed this from the Nextcloud 14 milestone on Aug 24, 2018
  24. ak1n commented on Oct 23, 2018

    @ak1n

    I have these errors spamming the logs with a fresh 14 install via docker upon the first single user attempting to sync files. Fixes or recommendations would be appreciated. Reference setup: https://gitlab.com/deepthought/nextcloud-docker

    errors: Fatal | webdav | OCA\DAV\Connector\Sabre\Exception\FileLocked: "..." is locked

    result from sudo docker exec --user www-data nextcloud-docker_app_1 php occ config:list system:

    {
        "system": {
            "memcache.local": "\\OC\\Memcache\\APCu",
            "apps_paths": [
                {
                    "path": "\/var\/www\/html\/apps",
                    "url": "\/apps",
                    "writable": false
                },
                {
                    "path": "\/var\/www\/html\/custom_apps",
                    "url": "\/custom_apps",
                    "writable": true
                }
            ],
            "filelocking.enabled": true,
            "memcache.locking": "\\OC\\Memcache\\Redis",
            "redis": {
                "host": "***REMOVED SENSITIVE VALUE***",
                "port": 6379,
                "timeout": 0
            },
            "passwordsalt": "***REMOVED SENSITIVE VALUE***",
            "secret": "***REMOVED SENSITIVE VALUE***",
            "trusted_domains": [
                "localhost",
                "redacted ip"
            ],
            "datadirectory": "***REMOVED SENSITIVE VALUE***",
            "dbtype": "mysql",
            "version": "14.0.3.0",
            "overwrite.cli.url": "http:\/\/localhost",
            "dbname": "***REMOVED SENSITIVE VALUE***",
            "dbhost": "***REMOVED SENSITIVE VALUE***",
            "dbport": "",
            "dbtableprefix": "",
            "mysql.utf8mb4": true,
            "dbuser": "***REMOVED SENSITIVE VALUE***",
            "dbpassword": "***REMOVED SENSITIVE VALUE***",
            "installed": true,
            "instanceid": "***REMOVED SENSITIVE VALUE***"
        }
    }
    
  25. ak1n commented on Oct 27, 2018

    @ak1n

    Seems related: #6160

  26. MorrisJobke commented on Nov 12, 2018

    @MorrisJobke
    Member

    Doctrine\DBAL\Exception\UniqueConstraintViolationException: An exception occurred while executing 'INSERT INTO oc_filecache (mimepart,mimetype,mtime,size,etag,storage_mtime,permissions,parent,checksum,path_hash,path,name,storage) SELECT ?,?,?,?,?,?,?,?,?,?,?,?,? FROM oc_filecache WHERE storage = ? AND path_hash = ? HAVING COUNT(*) = 0' with params ["1", "2", 1533325280, -1, "5b64afe067e8e", 1533325280, 31, 149894, "", "7fc567a03abec499cb8690b5e6b8f337", "files_versions/tools/firmware", "firmware", 1, 1, "7fc567a03abec499cb8690b5e6b8f337"]: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '1-7fc567a03abec499cb8690b5e6b8f337' for key 'fs_storage_path_hash'

    This kind of stuff is fix in a generic way via #12371 and for this specific one additionally in #12413 (which will also be back ported)

  27. added this to the Nextcloud 15 milestone on Nov 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions