Skip to content

Issues to solve with locking #16664

Closed
Closed

Description

@PVince81
  1. Add sleep(10); here: https://github.com/owncloud/core/blob/master/lib/private/files/cache/cache.php#L551
  2. Setup sync client
  3. Close sync client
  4. Copy a big folder "test" locally
  5. Start the sync client
  6. Quickly, while it starts uploading: refresh the web UI
  7. Rename "test" to "re"
  8. Sync client fails with error "could not find folder 'test'" after a bunch of uploads, which is expected
  9. In web UI: "re" is still empty, but "data/$user/re" contains files
  10. Sync client resumes upload, but in the end not all files are present in "test"

We need to tweak the locking to be able to avoid such situations.

  • rename folder with slow cache update still loses contents, see Data loss on rename of a 49 GB folder #13391 (comment)
  • BUG: properly handle LockedException in web UI: when renaming a locked folder in the web UI: exception returned as "500 Internal Server Error" but logged properly:
  • BUG: make etag precondition + final rename atomic: Slow transfer can bypass etag precondition check, no conflict file #16569 (the current locking did not help, might need to retry after acquireLock is set for small files)
  • BUG: sleep after chunk assembly but before final rename, then rename parent folder: sync fails with "could not rename part file to final file". We should bundle chunking inside a transaction. But the current behavior might be ok as it doesn't cause any data corruption.
  • BUG: [minor] move big folder to ext storage in web UI, sync client running: sync client cannot download any of the moved files as long as the move is happening (even if the files are there already). Once the move is done, the sync client retries and can get the file. Would still be nice to have to be able to download files as soon as they are moved (but keep the lock on the folder)
    To clarify: download should be forbidden in the source folder, but not in the target folder.

Tests:

  • TEST: move big folder to ext storage. During the slow move, cannot rename source or target folder: locked.
  • TEST: cannot rename folder while it is being moved to trash (tested with slow ext storage, copy from storage to trash)
  • TEST: cannot upload into a folder while it is being moved to trash
  • TEST: cannot rename a folder while chunks are being assembled (added sleep() in the chunk assembly loop), LockedException
  • TEST: slow down streamCopy for WebDAV upload and try renaming the parent folder
  • TEST: delete folder while uploading inside (with slow streamCopy): denied by locked error
  • TEST: kill sync client during upload (with slow streamCopy): lock expires after PHP timeout
  • TEST: simulate "expected filesize did not match" error: lock was properly released despite exception (shutdown handler)
  • TEST: cannot rename target folder when restoring it from trash
  • TEST: cannot download files inside a folder that is being moved to trash (source folder)
  • TEST: restore big folder from trash to SFTP (slow), try restoring it at the same time. Restore fails due to lock.
  • TEST: rename "test" to "test2", sleep before the actual rename: cannot create "test2" in another thread because locked

Sharing (locks must work across users):

  • TEST: slow upload of small file as owner, recipient cannot download while locked
  • TEST: slow upload of small file as recipient, owner cannot download while locked
  • TEST: owner moves folder, recipient cannot rename source or target folder
  • TEST: recipient moves folder, owner cannot rename source or target folder
  • TEST: delete subfolder as recipient, owner cannot rename/download contents
  • TEST: delete subfolder as owner, recipient cannot rename/download contents
  • TEST: owner unshares folder (can be slow with encryption), recipient cannot rename/download folder contents => raised as Unshare from user must lock path to avoid recipient access #17244
  • TEST: delete file in thread A, try and share it in thread B. Share must fail because of lock. 🚫 => raised as Lock sharing operations when file is locked #17243
  • TEST: delete subfolder as owner in thread A, recipent can still unshare from self in thread B(TBC?) ❓
  • TEST: delete subfolder as recipient in thread A, owner can still unshare from that recipient in thread B (TBC?) ❓ works but produces warning (sleep in move2trash after setupTrash)
  • TEST: unshare from self twice
  • TEST: share with group/user with encryption enabled (make key creation slow with sleep): recipient should not get access to the files until this is done 🚫 FAIL, raised as [concurrency] Access newly shared encrypted folder before all keys are ready #16621
  • TEST: as owner, rename parent folder of shared folder when locked by recipient
  • TEST: as recipient, rename parent folder of shared folder when locked by owner

Versions:

Previews:

  • TEST: if file was locked (not downloadable) during preview creation, preview needs to retry later
    (achieved by overwriting a pic file that has no preview yet, and sleep in streamCopy)

Encryption:

  • TEST: general testing if locking works like

Zip download:

s2s and locking

  • TEST: share "local" from server A to server B. On server A, slow-upload+overwrite file (sleep after acquireLock in sabre/file). Server B cannot download. 🚫 FAIL for some reason server B can still download => raised as Put file on remote share seems to bypass lock #17275

Activity

  1. added this to the milestone on Jun 1, 2015
  2. PVince81 commented on Jun 1, 2015

    @PVince81
    ContributorAuthor

    @icewind1991 see above

  3. PVince81 commented on Jun 1, 2015

    @PVince81
    ContributorAuthor

    I suggest to focus on the scanner first so we can get the most critical issue solved at last.

  4. PVince81 commented on Jun 3, 2015

    @PVince81
    ContributorAuthor
  5. icewind1991 commented on Jun 3, 2015

    @icewind1991
    Contributor

    BUG: rename folder during upload still has inconsistency between cache and on-disk data

    Not really something we can fix without having the client manually acquire a lock on the folder it's uploading to, it's not an issue with concurrent requests

  6. PVince81 commented on Jun 3, 2015

    @PVince81
    ContributorAuthor

    @icewind1991 I still think it should be possible to recover from this situation without having missing files, even if one half is in one folder and the other half in the other one. Goal is to avoid having a situation where files are completely lost. Either the rename operation needs to stop/fail or the sync client will give up once one of the uploads doesn't reach its target.
    Not sure, but this might be related to scanner locking too.

  7. icewind1991 commented on Jun 3, 2015

    @icewind1991
    Contributor

    Not sure, but this might be related to scanner locking too.

    It's not

    The problem has nothing to do with concurrent requests, it's caused because uploading a folder from the sync client takes multiple requests, there is no way to make that atomic without manually managing a lock for it.

    A different way to fix it unrelated to locking would be to have the sync client specify the fileid of the target folder, that way the server can either return a proper error (folder renamed to ...., try again with that path) or get the target folder from that id

  8. PVince81 commented on Jun 3, 2015

    @PVince81
    ContributorAuthor

    The upload doesn't have to be atomic. The sync client would upload 5 files of 10, then get the locked error because someone started renaming the folder (the folder rename must be atomic), and it would give up until the folder is freed again. So in the end the first folder would have 5 files, and then the sync client would recreate the original folder name (once unlocked) to reupload all files.
    Hmm I guess it means in the end we'd have a folder with 5 files (the renamed one) and another folder with the original name but all the 10 ones.
    But then there's the etag/rename change that might be detected.
    Tricky indeed.

  9. PVince81 commented on Jun 18, 2015

    @PVince81
    ContributorAuthor

    I'll try and go through the list again and raise separate tickets.

    But before I do we need to fix the regressions: #16998
    and also #16963 which has a high risk of influencing a lot of the code paths, which means that retesting only makes sense once that one is finished.

  10. PVince81 commented on Jun 29, 2015

    @PVince81
    ContributorAuthor

    Assigning to self to verify the failed cases I found before.
    If they still happen, I'll make separate tickets for them.

    I expect the following to still have issues: sharing (share and unshare currently do not set locks) and also versions (version operations aren't transactional yet). Hopefully these should not be critical.

  11. PVince81 commented on Jun 30, 2015

    @PVince81
    ContributorAuthor

    Moving to 8.1.1.

    Remaining issues are related to versions that is lacking locking.

  12. modified the milestones: , on Jun 30, 2015
  13. PVince81 commented on Jul 1, 2015

    @PVince81
    ContributorAuthor

    All outstanding issues have been raised as separate tickets, closing this one.

  14. modified the milestones: , on Jul 1, 2015
  15. locked as resolved and limited conversation to collaborators on Aug 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions