-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
keep a read lock while scanning a file or folder #16729
Conversation
If this can fix the data loss issue #13391 (comment) then it already rocks |
If the issue is not fixed with just this PR we could add a lock for the cache next to the current lock to prevent partial updated cache data being returned from PROPFIND and friends while the cache is being updated |
|
Testing #13391 (comment) It also seemed that the sync client hung in the discovery phase, maybe some changes will be required there as well to make sure it just continues. |
8262d6b
to
d13b862
Compare
@icewind1991 any update on this in regards to fixing #13391 ? I noticed in my analysis yesterday that we need to be careful what data is returned to the client. |
The failure was caused by the trashbin needing the fileinfo in the wrapper for shared files which can triger a scan and run into a locking problem. I've worked around this by making sure the scanning happens in the pre-hook instead of the unlink operation itself. |
@PVince81 can you retest? |
Upload to root folder works now. |
* @param array $params | ||
*/ | ||
public static function ensureFileScannedHook($params) { | ||
self::getUidAndFilename($params['path']); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This ensures that if the file needs to be scanned it's scanned during the pre-hook and not the actual delete operation (where it's write locked)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
=> add a comment // triggers scan indirectly
or something along these lines
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@icewind1991 please add comment to the code as requested - THX
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expanded the phpdoc
@DeepDiver1975 @MorrisJobke please review |
How did you test this ? Which one of the many issues does this fix ? |
It should fix issues where a file is deleted/renamed while the file is being scanned. To test:
Without this patch the rename completes and both the old an new file will show up in the web interface, with this patch the rename fails with a locked exception |
Cool thanks, I'll have a try. |
Works 👍 (side note: I completelty forgot that we had the |
ee191f6
to
9f065ff
Compare
@MorrisJobke @DeepDiver1975 please review, this is blocking some other locking work I would like to do |
@@ -237,12 +239,11 @@ public function put($data) { | |||
} | |||
} | |||
$this->refreshInfo(); | |||
$this->fileView->unlockFile($this->path, ILockingProvider::LOCK_SHARED); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks somehow weird. The lock seems to be never unlocked when an error between the lock and unlock happens. Is this valid nevertheless?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If an exception happens the unlock will be handled by the shutdown handler, since any error here ends the request there is no need to unlock the file before the end of the request
@icewind1991 we need a rebase here - THX |
9f065ff
to
9c0d69a
Compare
@@ -83,6 +89,7 @@ public function __construct(\OC\Files\Storage\Storage $storage) { | |||
$this->storageId = $this->storage->getId(); | |||
$this->cache = $storage->getCache(); | |||
$this->cacheActive = !Config::getSystemValue('filesystem_cache_readonly', false); | |||
$this->lockingProvider = \OC::$server->getLockingProvider(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
inject?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cant without breaking changes to the storage api :(
A new inspection was created. |
@DeepDiver1975 can this be merged? |
My 👍 still applies. Blocks #16963. |
@nickvergessen maybe ? |
👍 |
keep a read lock while scanning a file or folder
Regression: #16998 |
Note that this does not prevent concurrent scanners, only stops the file or folder being changed while scanning
For #16664
cc @DeepDiver1975 @PVince81