-
-
Notifications
You must be signed in to change notification settings - Fork 4.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
CalDAV/CardDAV: put every method from backends that does multiple DB calls in transactions #36528
Conversation
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.
Psalm found more than 10 potential problems in the proposed changes. Check the Files changed tab for more details.
03b3fe7
to
4cf6aa8
Compare
Psalm issues are existing ones. |
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.
Best enjoyed as https://github.com/nextcloud/server/pull/36528/files?w=1
👍 Good stuff. This might not even fix nasty database issues but improve performance a bit if changes are committed in one transaction.
I added an extra commit 27e717c to use the QueryBuilder properly in the |
27e717c
to
3f8b383
Compare
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.
@tcitworld would you mind fixing the conflicts? Then we should be able to merge this. I can also take over the rebase if you want. Thanks a lot! :) |
so update the baseline then in order to fix psalm? |
01cd399
to
bafaad1
Compare
It was a specific change in PHPDoc that didn't match the inherited class, my bad. Upstream PR at sabre-io/dav#1457 |
bafaad1
to
7dd0c38
Compare
/rebase |
…does multiple DB calls in transactions In a lot of methods we're doing read-after-writes (for instance calling updateProperties after touching calendar objects). There's also a lot of deleting methods that do stuff sequentially which could cause trouble. This should avoid this kind of issues. Signed-off-by: Thomas Citharel <tcit@tcit.fr>
…rementing synctoken Now that we're in a transaction, we can reuse the sync token's previous value without trouble, and rewrite the increment UPDATE query without dirty direct SQL. Signed-off-by: Thomas Citharel <tcit@tcit.fr>
7dd0c38
to
ff3b69b
Compare
Goodbye rebase issues :) |
Hello DB issues :(
We have quite some log entries like this in the meantime. {
"file": "…/3rdparty/sabre/dav/lib/CalDAV/Schedule/Plugin.php",
"line": 538,
"function": "put",
"class": "Sabre\\CalDAV\\CalendarObject",
"type": "->",
"args": [
"*** sensitive parameters replaced ***"
]
},
{
"file": "…/apps/dav/lib/CalDAV/Schedule/Plugin.php",
"line": 179,
"function": "scheduleLocalDelivery",
"class": "Sabre\\CalDAV\\Schedule\\Plugin",
"type": "->",
"args": [
[
"Sabre\\VObject\\ITip\\Message",
"92c36c40-48fe-483b-9cff-…",
"VEVENT",
"REQUEST",
1,
"mailto:b…e@nextcloud.com",
"*** sensitive parameters replaced ***",
"mailto:s…s@nextcloud.com",
"*** sensitive parameters replaced ***",
"*** sensitive parameters replaced ***",
[
"Sabre\\VObject\\Component\\VCalendar",
"*** sensitive parameters replaced ***",
"VCALENDAR"
],
false
]
]
},
{
"file": "…/3rdparty/sabre/event/lib/WildcardEmitterTrait.php",
"line": 89,
"function": "scheduleLocalDelivery",
"class": "OCA\\DAV\\CalDAV\\Schedule\\Plugin",
"type": "->",
"args": [
[
"Sabre\\VObject\\ITip\\Message",
"92c36c40-48fe-483b-9cff-…",
"VEVENT",
"REQUEST",
1,
"mailto:b…e@nextcloud.com",
"*** sensitive parameters replaced ***",
"mailto:s…s@nextcloud.com",
"*** sensitive parameters replaced ***",
"*** sensitive parameters replaced ***",
[
"Sabre\\VObject\\Component\\VCalendar",
"*** sensitive parameters replaced ***",
"VCALENDAR"
],
false
]
]
}, |
Interesting. Sounds like we need savepoints to make sure inner transactions don't explode outer ones. Another suspicious issue might be #38902 (comment) |
Using nested transactions without savepoints is actually deprecated by Doctrine: https://www.doctrine-project.org/projects/doctrine-dbal/en/current/reference/transactions.html#transaction-nesting Without savepoints, a nested transaction can be rollbacked but not handled properly in the "real" transaction, leading to the following error: Transaction commit failed because the transaction has been marked for rollback only. Ref #36528 (comment) (and possibly) #38902 (comment) Signed-off-by: Thomas Citharel <tcit@tcit.fr>
Using nested transactions without savepoints is actually deprecated by Doctrine: https://www.doctrine-project.org/projects/doctrine-dbal/en/current/reference/transactions.html#transaction-nesting Without savepoints, a nested transaction can be rollbacked but not handled properly in the "real" transaction, leading to the following error: Transaction commit failed because the transaction has been marked for rollback only. Ref #36528 (comment) (and possibly) #38902 (comment) Signed-off-by: Thomas Citharel <tcit@tcit.fr>
Using nested transactions without savepoints is actually deprecated by Doctrine: https://www.doctrine-project.org/projects/doctrine-dbal/en/current/reference/transactions.html#transaction-nesting Without savepoints, a nested transaction can be rollbacked but not handled properly in the "real" transaction, leading to the following error: Transaction commit failed because the transaction has been marked for rollback only. Ref #36528 (comment) (and possibly) #38902 (comment) Signed-off-by: Thomas Citharel <tcit@tcit.fr>
Using nested transactions without savepoints is actually deprecated by Doctrine: https://www.doctrine-project.org/projects/doctrine-dbal/en/current/reference/transactions.html#transaction-nesting Without savepoints, a nested transaction can be rollbacked but not handled properly in the "real" transaction, leading to the following error: Transaction commit failed because the transaction has been marked for rollback only. Ref #36528 (comment) (and possibly) #38902 (comment) Signed-off-by: Thomas Citharel <tcit@tcit.fr>
@tcitworld Do you remember why you used non retry-able In
The reason I am asking is that tasks & calendars in nextcloud are essentially broken for me: almost 10-30% of events/tasks creation and/or moving fail for me in any bulk task/calendar operation (such as calendar import or move tasks from one task list to another) with the following error:
In the logs I have this backtrace I think retry-able atomic has a flaw/issue in implementation: any retry is supposed to have some backoff policy (like truncated exponential backoff), but atomicRetry does not have one. P.S.I managed to fix my error by replacing
|
I have not looked into it, but this method simply didn't exist at the time (#38030 was merged two months after this one was). |
You can, by the way, see how other people struggle with this issue too:
^^^ it seems that in most/all issues, people are using sqlite, but I have feeling that it would fail in similar way on any database, if DB and nextcloud server is on different hosts and there is a network issue (so, the root cause is not sqlite) |
@tcitworld I see... Thank you for quick response. Can you suggest what would the best way to fix the root cause of the issue (which is lack of retries with backoff policy) be? Shall I create a new / separate issue? |
Well a retry at this place won't help if the problem is network issues, as all the other queries including the initial appconfig load will not be retried as well. |
@nickvergessen Thank you. Good points. I did not know about SQLite being discouraged. |
Partial backport of #36528 Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
In a lot of methods we're doing read-after-writes (for instance calling updateProperties after touching calendar objects). There's also a lot of deleting methods that do stuff sequentially which could cause trouble.
This should avoid this kind of issues.
TODO
Checklist