Repository navigation
cron.php OCA\DAV\CardDAV\SyncJob causes a high load daily #7184
Description
Activity
cc @georgehrke
@CamZie Do you have a lot of federated shares?
@georgehrke we do not have any federated shares.
I would like to ask if there are any news for this problem?
I would like to ask if there are any news for this problem?
Not yet. I forgot to ask: Do you use any user-backend? If yes, how fast is the connection to the user-backend?
I'm asking because
OCA\DAV\CardDAV\SyncJobdoes not touch any user address book. All it does is creating/updating VCards for each user in the system address book and if you use federated shares sync the system address book with other instances.Thank you for the information. We are not using any user-backend and simply have all the users in the MySQL database.
Is it possible that the cause of this problem is the OCA\DAV\CardDAV\SyncJob, which creates/updates the vCards for each users in one try?
Is it possible that the cause of this problem is the OCA\DAV\CardDAV\SyncJob, which creates/updates the vCards for each users in one try?
So you are not sure that the high load was caused by
OCA\DAV\CardDAV\SyncJob, but it was just a wild guess?Can you check in the
oc_jobstable what other jobs are scheduled for the instance? Maybe thelast_runcolumn will give a hint what job took so much time.We were sure that this was caused by the OCA\DAV\CardDAV\SyncJob, because we also saw the following entry on the database:
id: 565626 class: OCA\DAV\CardDAV\SyncJob argument: null last_run: 1512512102 last_checked: 1512549901 reserved_at: 0 execution_duration: 9260Looks like we need to optimise that job then. @rullzer @schiessle @blizzz Any idea for this?
I'd have to run test. But I see why it fails.
The first part of the job is actually playing nice I'd say: https://github.com/nextcloud/server/blob/master/apps/dav/lib/CardDAV/SyncService.php#L320-L325
Just for each user update that user which seems fine (and makes sense).
However the second part: https://github.com/nextcloud/server/blob/master/apps/dav/lib/CardDAV/SyncService.php#L328
Creates a huge structure in RAM. We should probably try to add a generator or something here... I'll see if I can add 10k users easily to my dev setup and see it perform
Mmmm so thinking more about this... why don't we just listen to the postDelete hook properly... and then drop the user from the sytemaddressbook...
Aaaah because the mapping is reversed... (sorry for the live debug log :P)
Ok so I was wrong. https://github.com/nextcloud/server/blob/master/apps/dav/lib/CardDAV/SyncService.php#L328 is actually very fast.
https://github.com/nextcloud/server/blob/master/apps/dav/lib/CardDAV/SyncService.php#L321 is slow
This is because we regenerate the vcard all the time. Which requires fetching an avatar. Which goes to disk etc.
However the more I look at it the more I wonder why we have this job. This should all be handled by the hooks in place already. And for the times we don't let users just use the occ command I'd say.
So I just checked.
- Creating a user => Creates it in the systemaddressbook
- Deleting a user => Deletes it from the systemaddressbook
- Updating a user => Updates it in the systemaddressbook
So I think we can just remove the cronjob for this.
All user backends should properly emit those hooks and if not we should fix them.Worst comes to worst users can always trigger a sync via the occ command.
Reacted by Arthur Schiwon- added 2 commits that reference this issue
on Dec 29, 2017 PR in #7644
- added a commit that references this issue
on Jan 2, 2018 - added a commit that references this issue
on Jan 3, 2018
Steps to reproduce
Expected behaviour
Job should run quickly and the load on the server should not go higher.
Actual behaviour
It runs for hours depending on the amount of users. For approximately 5000 users it needs 3 hours. It tries to parse all users and their addressbook cards in one pass, which causes a high load on the database and takes up more server resource than it should.
Server configuration
Operating system: Debian 9.1 (stretch)
Web server: Nginx 1.10.3
Database: MySQL 5.8
PHP version: 7
Nextcloud version: 12.0.2
Contacts version: 2.0.1
Updated from an older Nextcloud or fresh install: Updated from Nextcloud version 12
Signing status:
List of activated apps:
Nextcloud configuration:
Are you using encryption: yes
Client configuration
Browser:
not relevant because it is a CLI/server side issue
Operating system:
not relevant because it is a CLI/server side issue
Logs
Web server error log
Web server error log
Nextcloud log (data/nextcloud.log)
Nextcloud log
Browser log
Browser log