-
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
Close cursor early in calculateFolderSize #13752
Conversation
This method triggers additional queries in $this->update() so to avoid potential database locks or delays, we close the cursor as soon as it is not needed any more
The inspection completed: 5 new issues |
refs #13705 |
checked the md5 of the uploaded files, all was well. I just tried the following (all was with encryption enabled), upload in parallel from:
Then checked md5, all fine. No database is locked exception. Next step: upload into same folder. |
Refer to this link for build results (access rights to CI server needed): |
Upload different files into the same folder seemed to work, too. I'll see if I can test parallel uploads now with the sync client. |
If that works well we might want to backport this @karlitschek |
I tried with the new sync client master (owncloud/client@43d6dbb) and I observed this: With this fix: all worked fine, nothing in log! Please review, this will also fix parallel upload + sqlite |
Fixes #12429 |
@@ -596,6 +596,7 @@ public function calculateFolderSize($path, $entry = null) { | |||
'WHERE `parent` = ? AND `storage` = ?'; | |||
$result = \OC_DB::executeAudited($sql, array($id, $this->getNumericStorageId())); | |||
if ($row = $result->fetchRow()) { | |||
$result->closeCursor(); |
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.
Isn't it slightly better to move this line outside the if
check, add an additional statement $resultRow = $result->fetchRow();
and change the if-statement to if ($row = $resultRow) {
?
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.
or simply if($resultRow)
;)
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.
It would be slightly better, yes. But I think the current approach is still acceptable.
I preferred investing my time in testing this bad bug and making sure it work instead of making the code perfect. (note: still busy testing)
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.
Feel free to make the change yourself if you think that's very important.
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.
@PVince81
I am probably not up to it, since I don't have a test environment and am only following the changes. The advantage of my proposed approach is that the connection to the database is freed at the earliest point and additionally in a single place. This might prevent regressions, once other parts of that function are touched or additional cases added to the if
statement.
If you still think I should provide a commit without me having a test environment and practically zero php-experience, I would provide it. Should I then create a new PR with a feature branch having your commit against HEAD
of master?
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.
I don't think the performance gain for this change will be that much, but anyway if you'd like to contribute, you should fork the core repo and then submit PRs of a feature branch to core master.
You are saying you have zero PHP experience and yet are making suggestions to improve PHP code ? 😉
Anyway, there's always opportunities to learn.
If you are interested in contributing code/changes, I suggest to setup a dev env http://doc.owncloud.org/server/7.0/developer_manual/general/devenv.html
Then fork the project and submit a PR to master from a feature branch.
Please note that we are currently in the final phase of 8.0 release (so a bit of a rush to finish it), so any non-critical PRs will have to wait for 8.1. 😄
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.
Thanks for elaborating. I knew most about it, yet primarily wanted to know, if you consider this kind of change too much of nitpicking. Certainly no rush is needed for this kind of change, so don't bother with me right now.
No php, but isn't it all the same at an abstract level? ;-)
Uploading to a shared folder as recipient with parallel upload also seems to work fine. |
Looks good 👍 |
Tested parallel upload ... no suspicious warnings/errors 👍 |
Close cursor early in calculateFolderSize
@karlitschek backport to OC 7 ? |
Please backport! Thanks |
stable7 234f33e |
... but then #13615 (comment) needs to be included in oC and backported too. @PVince81 It would be good to test that PROPFIND lock case before your "fix" here with and without #13615 |
I think even if the PROPFIND case doesn't work, this fix already fixes the upload case. Can whoever was having the PROPFIND lock issue help testing this ? @davivel ? |
I think this PR here doesn't fix a "BUSY" case but really a "LOCK" case. The SELECT statement was still open while we were trying to do UPDATEs on the same table in some situations, which would directly lock because the same PHP request cannot wait for itself (deadlock) |
Thanks for your explanations on IRC, you're right of course. It's two independant things.. :) |
Followup: #13772 |
Tested the backport on stable7, also works fine with parallel uploads. |
:-( @DeepDiver1975 agreed |
This method triggers additional queries in $this->update() so to avoid
potential database locks or delays, we close the cursor as soon as it is not needed any more
This seems to fix the "database is locked" issue happening here during upload: #12429 (I have an environment where it could be reproduced consistently)
@DeepDiver1975 @guruz @icewind1991