Skip to content

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

Closed

Description

@ChristophWurst

⚠️ 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

Activity

  1. ChristophWurst commented on Feb 13, 2024

    @ChristophWurst
    MemberAuthor

    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.

  2. self-assigned this
    on Jul 22, 2024
  3. 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[/+] on Jul 22, 2024
  4. added and removed
    1. to developAccepted and waiting to be taken care of
    on Jul 25, 2024
  5. moved this from 📄 To do to 🏗️ In progress in 💌 📅 👥 Groupware teamon Jul 25, 2024
  6. moved this from 🏗️ In progress to ☑️ Done in 💌 📅 👥 Groupware teamon Aug 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions