Repository navigation
reduce amount of db calls needed for file-locks - #18993
individual-it wants to merge 10 commits into
Conversation
|
A new inspection was created. |
|
cc @icewind1991 I thought transactions make everything go through in a single query? @individual-it Could you do some benchmarking to show the performance impact of this change? Have a look at blackfire.io if you've never done it before |
|
Even with a transaction two queries are still two queries. In fact a transaction generates more DB load then only the two queries. |
|
@Xenopathic: In my tests I'm measuring 2-3% difference to the current master when uploading small files in parallel. I would not say that is super scientific and could be also regarded as measuring tolerance. There are even 3 queries if you count the SELECT sub query insite the INSERT Query https://github.com/owncloud/core/blob/master/lib/private/db/adapter.php#L76 |
|
I understand now. 👍 |
|
Changes look good to me 👍
Preventing race conditions (the same race conditions that cause an exception instead of data loss in #18918 |
|
Cannot merge that one because "Update branch" fails and if I understand it correctly its because failure in "Scrutinizer" |
…or_filelocks Conflicts: lib/private/lock/dblockingprovider.php
|
please review again after consolidating with #19098 |
There was a problem hiding this comment.
Release lock and changelock should not initialize the value to anything but 0
There was a problem hiding this comment.
I followed the logic of the code as it was before
initLockField would set it to 0 then if ($type === self::LOCK_SHARED) it would have become -1
can the lock value be ever -1?
There was a problem hiding this comment.
The update query checks that lock > 0, so it cant set the value to -1
There was a problem hiding this comment.
For changeLock it's important that a locked exception is thrown if the lock is not already the value we expect it to be
There was a problem hiding this comment.
Now I think about it we probably dont need the initLockField for either release or change
There was a problem hiding this comment.
The update query checks that lock > 0, so it cant set the value to -1
that's true. so in the past it would run the query but never change the value if initLockField was just run.
Or more likely initLockField never had to do anything because the line was always there already in changeLock and releaseLock
Now I think about it we probably dont need the initLockField for either release or change
If we expect it to be there than we don't need it.
What about only to run the UPDATE statements in changeLock and releaseLock and throw an exeption if it fails (because the line does not exist)
There was a problem hiding this comment.
It should already throw a locked exception if the row doesn't exist
There was a problem hiding this comment.
will the original cone not throw an \Doctrine\DBAL\DBALException if the UPDATE fails?
https://github.com/owncloud/core/blob/master/lib/private/db/connection.php#L197
There was a problem hiding this comment.
As far as the update query is concerned there is no difference between the lock row not being there or the lock value being unexpected, either way the WHERE clause will return 0 rows
There was a problem hiding this comment.
I dont think we should error on releaseLock
There was a problem hiding this comment.
If that lock could not be released something bad happened. Maybe the lock exception is not the right one to throw but the next layer should know that it could not be released
There was a problem hiding this comment.
The problem is differentiating "lock could not be released" from "file was never locked in the first place", for now don't have it throwing an exception since that's the current behavior
There was a problem hiding this comment.
changed as suggested
|
👍 cc @PVince81 @MorrisJobke @Xenopathic please (re-)review |
There was a problem hiding this comment.
mumble mumble trailing whitespace...
|
LGTM 👍 the minor formatting issues can be fixed by whoever next touches the file |
|
Smashbox test_basicSync still works 👍 |
|
merged as #19267 - THX |
locking functions in dblockingprovider.php need 2 DB calls for a locking operation:
I suggest to set the "lock" field to the correct value already in initLockField. Every time there is no row yet for that file the time for the SQL UPDATE would be saved.