Skip to content
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

Use Delta for subscription calendars instead of deleting and reinserting all events #43541

Open
4 of 8 tasks
Tracked by #46171
ChristophWurst opened this issue Feb 13, 2024 · 1 comment
Open
4 of 8 tasks
Tracked by #46171
Assignees
Labels
1. to develop Accepted and waiting to be taken care of 28-feedback bug feature: caldav Related to CalDAV internals performance 🚀

Comments

@ChristophWurst
Copy link
Member

⚠️ This issue respects the following points: ⚠️

Bug description

#42345 / #43261 shows a long running transaction for the webcal background sync:

Exception: Long running transaction
#9 /var/www/nextcloud/lib/private/DB/Connection.php(680): OC\DB\Connection::commit
#8 /var/www/nextcloud/lib/private/DB/ConnectionAdapter.php(154): OC\DB\ConnectionAdapter::commit
#7 /var/www/nextcloud/lib/public/AppFramework/Db/TTransactional.php(64): OCA\DAV\CalDAV\CalDavBackend::atomic
#6 /dav/lib/CalDAV/CalDavBackend.php(3075): OCA\DAV\CalDAV\CalDavBackend::purgeAllCachedEventsForSubscription
#5 /dav/lib/CalDAV/WebcalCaching/RefreshWebcalService.php(101): OCA\DAV\CalDAV\WebcalCaching\RefreshWebcalService::refreshSubscription
#4 /dav/lib/BackgroundJob/RefreshWebcalJob.php(115): OCA\DAV\BackgroundJob\RefreshWebcalJob::run
#3 /var/www/nextcloud/lib/public/BackgroundJob/Job.php(81): OCP\BackgroundJob\Job::start
#2 /var/www/nextcloud/lib/public/BackgroundJob/Job.php(67): OCP\BackgroundJob\Job::execute
#1 /dav/lib/BackgroundJob/RefreshWebcalJob.php(108): OCA\DAV\BackgroundJob\RefreshWebcalJob::execute
#0 /var/www/nextcloud/cron.php(152): null

Steps to reproduce

  1. Set up Nextcloud 28.0.2
  2. Install Calendar
  3. Add a webcal subscription

Expected behavior

Fast transaction

Installation method

None

Nextcloud Server version

28

Operating system

None

PHP engine version

None

Web server

None

Database engine version

None

Is this bug present after an update or on a fresh install?

None

Are you using the Nextcloud Server Encryption module?

None

What user-backends are you using?

  • Default user-backend (database)
  • LDAP/ Active Directory
  • SSO - SAML
  • Other

Configuration report

No response

List of activated Apps

No response

Nextcloud Signing status

No response

Nextcloud Logs

No response

Additional info

No response

@ChristophWurst ChristophWurst added bug 1. to develop Accepted and waiting to be taken care of performance 🚀 feature: caldav Related to CalDAV internals labels Feb 13, 2024
@ChristophWurst
Copy link
Member Author

Stepped through the code quickly. Looks like

SELECT `synctoken` FROM `oc_calendarsubscriptions` WHERE `id` = :dcValue1;
INSERT INTO `oc_calendarchanges` (`uri`, `synctoken`, `calendarid`, `operation`, `calendartype`) VALUES(:dcValue1, :dcValue2, :dcValue3, :dcValue4, :dcValue5);
UPDATE `oc_calendarsubscriptions` SET `synctoken` = :dcValue1 WHERE `id` = :dcValue2;

is called for each item in the subscription. This subscription has >2k entries. That makes 6k queries just to purge old data.

@miaulalala miaulalala self-assigned this Jul 22, 2024
@miaulalala miaulalala changed the title [Bug]: Long running transaction at \OCA\DAV\CalDAV\CalDavBackend::purgeAllCachedEventsForSubscription Use Delta for subscription calendars instead of deleting and reinserting all events Jul 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1. to develop Accepted and waiting to be taken care of 28-feedback bug feature: caldav Related to CalDAV internals performance 🚀
Projects
Status: 📄 To do
Development

No branches or pull requests

3 participants