Skip to content

Close cursor early in calculateFolderSize - #13752

Merged
MorrisJobke merged 1 commit into
masterfrom
closecursor1
Jan 29, 2015
Merged

MorrisJobke merged 1 commit into
masterfrom
closecursor1

Conversation

@PVince81

Copy link
Copy Markdown
Contributor

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

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
@scrutinizer-notifier

Copy link
Copy Markdown

The inspection completed: 5 new issues

@PVince81 PVince81 added this to the 8.0-current milestone Jan 29, 2015
@DeepDiver1975

Copy link
Copy Markdown
Contributor

refs #13705

@PVince81

Copy link
Copy Markdown
Contributor Author

checked the md5 of the uploaded files, all was well.
See the original issue for sample images (a folder full of small pics)

I just tried the following (all was with encryption enabled), upload in parallel from:

  1. Firefox upload into a folder "sub1"
  2. Chromium upload into a folder "sub2"
  3. Sync client upload into a folder "sub3"

Then checked md5, all fine. No database is locked exception.

Next step: upload into same folder.

@ghost

ghost commented Jan 29, 2015

Copy link
Copy Markdown

Refer to this link for build results (access rights to CI server needed):
https://ci.owncloud.org//job/pull-request-analyser-ng-simple/8256/
🚀 Test PASSed. 🚀

@PVince81

Copy link
Copy Markdown
Contributor Author

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.

@PVince81

Copy link
Copy Markdown
Contributor Author

If that works well we might want to backport this @karlitschek

@PVince81

Copy link
Copy Markdown
Contributor Author

I tried with the new sync client master (owncloud/client@43d6dbb) and I observed this:
Without the fix: massive floodage of the logs with "database is locked"

With this fix: all worked fine, nothing in log!

Please review, this will also fix parallel upload + sqlite

@PVince81

Copy link
Copy Markdown
Contributor Author

Fixes #12429

Copy link
Copy Markdown

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) { ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or simply if($resultRow) ;)

Copy link
Copy Markdown
Contributor Author

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)

Copy link
Copy Markdown
Contributor Author

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.

Copy link
Copy Markdown

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?

Copy link
Copy Markdown
Contributor Author

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

Copy link
Copy Markdown

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? ;-)

@PVince81

Copy link
Copy Markdown
Contributor Author

Uploading to a shared folder as recipient with parallel upload also seems to work fine.
I did see some harmless warnings, possibly unrelated: #13761

@icewind1991

Copy link
Copy Markdown
Contributor

Looks good 👍

@MorrisJobke

Copy link
Copy Markdown
Contributor

Tested parallel upload ... no suspicious warnings/errors 👍

MorrisJobke added a commit that referenced this pull request Jan 29, 2015
Close cursor early in calculateFolderSize
@MorrisJobke
MorrisJobke merged commit acf0582 into master Jan 29, 2015
@MorrisJobke
MorrisJobke deleted the closecursor1 branch January 29, 2015 13:23
@PVince81

Copy link
Copy Markdown
Contributor Author

@karlitschek backport to OC 7 ?

@karlitschek

Copy link
Copy Markdown
Contributor

Please backport! Thanks

@MorrisJobke

Copy link
Copy Markdown
Contributor

stable7 234f33e

@guruz

guruz commented Jan 29, 2015

Copy link
Copy Markdown
Contributor

Please backport! Thanks

... but then #13615 (comment) needs to be included in oC and backported too.
Not sure if this is clear, but you cannot sanely use sqlite3 without a busy wait handler (or manually handling BUSY return value). This is a regression, the handler had been there in oC5.

@PVince81 It would be good to test that PROPFIND lock case before your "fix" here with and without #13615

@PVince81

Copy link
Copy Markdown
Contributor Author

I think even if the PROPFIND case doesn't work, this fix already fixes the upload case.
So in the worst case it means we need additional fixing.

Can whoever was having the PROPFIND lock issue help testing this ? @davivel ?

@PVince81

Copy link
Copy Markdown
Contributor Author

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)

@guruz

guruz commented Jan 29, 2015

Copy link
Copy Markdown
Contributor

Thanks for your explanations on IRC, you're right of course. It's two independant things.. :)

@guruz

guruz commented Jan 29, 2015

Copy link
Copy Markdown
Contributor

Followup: #13772

@PVince81

Copy link
Copy Markdown
Contributor Author

Tested the backport on stable7, also works fine with parallel uploads.

@DeepDiver1975

Copy link
Copy Markdown
Contributor

stable7 234f33e

this backport did let stable7 to fall apart - #13788

We will stop this cherry-pick nightmare ....

@karlitschek

Copy link
Copy Markdown
Contributor

:-( @DeepDiver1975 agreed

@lock lock Bot locked as resolved and limited conversation to collaborators Aug 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants