Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues to solve with locking #16664

Closed
36 of 46 tasks
PVince81 opened this issue Jun 1, 2015 · 12 comments
Closed
36 of 46 tasks

Issues to solve with locking #16664

PVince81 opened this issue Jun 1, 2015 · 12 comments

Comments

@PVince81
Copy link
Contributor

PVince81 commented Jun 1, 2015

  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
@PVince81 PVince81 added this to the 8.1-current milestone Jun 1, 2015
@PVince81
Copy link
Contributor Author

PVince81 commented Jun 1, 2015

@icewind1991 see above

@PVince81
Copy link
Contributor Author

PVince81 commented Jun 1, 2015

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

@PVince81
Copy link
Contributor Author

PVince81 commented Jun 3, 2015

@icewind1991
Copy link
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

@PVince81
Copy link
Contributor Author

PVince81 commented Jun 3, 2015

@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.

@icewind1991
Copy link
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

@PVince81
Copy link
Contributor Author

PVince81 commented Jun 3, 2015

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.

@PVince81
Copy link
Contributor Author

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.

@ghost
Copy link

ghost commented Jun 18, 2015

thank you @PVince81

@PVince81
Copy link
Contributor Author

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.

@PVince81 PVince81 assigned PVince81 and unassigned icewind1991 Jun 29, 2015
@PVince81
Copy link
Contributor Author

Moving to 8.1.1.

Remaining issues are related to versions that is lacking locking.

@PVince81 PVince81 modified the milestones: 8.1.1-next-maintenance, 8.1-current Jun 30, 2015
@PVince81
Copy link
Contributor Author

PVince81 commented Jul 1, 2015

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

@PVince81 PVince81 closed this as completed Jul 1, 2015
@MorrisJobke MorrisJobke modified the milestones: 8.1-current, 8.1.1-next-maintenance Jul 1, 2015
@lock lock bot locked as resolved and limited conversation to collaborators Aug 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants