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

[Bug]: <dav> upgrade step takes hours when server connected to large LDAP directory, or has hundreds of users #39744

Closed
6 of 8 tasks
andrewperry opened this issue Aug 8, 2023 · 6 comments · Fixed by #39911
Labels
1. to develop Accepted and waiting to be taken care of 27-feedback bug feature: carddav Related to CardDAV internals feature: dav feature: install and update

Comments

@andrewperry
Copy link

andrewperry commented Aug 8, 2023

⚠️ This issue respects the following points: ⚠️

Bug description

When upgrading from 26.0.4 to 27.0.1 there is a step in the upgrade flow that says:

"Updating <dav> ..."

which seems to query the ldap directory and for every entry in LDAP update the "System Address Book" in the 'addressbooks' table as well as create an account in the 'accounts' table with a corresponding entry in the 'ldap_user_mapping' table.

If a server is connected to an LDAP directory with thousands, tens of thousands or hundreds of thousands of users, this can take hours to recurse through and it does not seem that this is a step that should block the completion of the upgrade. Can this step please be moved to a separate recommendation, like the addition of indexes for performance, that would appear in the admin interface alongside other security & performance recommendations. This would enable the server to get out of maintenance mode quicker, rather than have the server offline for hours (or days) while tens of thousands of LDAP accounts are probed and accounts created and/or carddav 'cards' in the "system" addressbook updated (often without them needing to be as they should only be created when the user attempts to login to nextcloud with their LDAP credentials).

Steps to reproduce

  1. Enable LDAP integration
  2. Attempt to upgrade from Nextcloud 26.0.4 to 27.0.1
  3. Tail updater.log which gives the impression the upgrade is complete but the cli is still hanging at "Updating <dav> ..."
  4. Tail nextcloud.log -f to see the large number of ldap queries continuously race by for hours

Expected behavior

Upgrade should complete without the need to recurse the whole connected LDAP directory.

Installation method

Community Web installer on a VPS or web space

Nextcloud Server version

27

Operating system

Debian/Ubuntu

PHP engine version

PHP 8.1

Web server

Apache (supported)

Database engine version

MariaDB

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

Upgraded to a MAJOR version (ex. 22 to 23)

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

@andrewperry andrewperry added 0. Needs triage Pending check for reproducibility or if it fits our roadmap bug labels Aug 8, 2023
@kesselb
Copy link
Contributor

kesselb commented Aug 8, 2023

cc @ChristophWurst @miaulalala

@kesselb kesselb added 1. to develop Accepted and waiting to be taken care of and removed 0. Needs triage Pending check for reproducibility or if it fits our roadmap labels Aug 8, 2023
@kesselb
Copy link
Contributor

kesselb commented Aug 8, 2023

Thank you 👍

Sounds like a reasonable request.

We run syncInstance from a migration1 during the upgrade.
Indeed, this can take a while if your ldap directory is bigger.

Idea:

  • Setup check to show a warning "Please run dav:sync-system-addressbook to synchronizes users to the system addressbook". Should be shown if a appconfig "pendingSystemAddressbookSync" is there.
  • Change the migration: if (IUserManager.countSeenUsers > 100) then add appconfig "pendingSystemAddressbookSync" else run syncInstance.

Footnotes

  1. https://github.com/nextcloud/server/blob/92c18b252c12acb06c343b11fb36f322f4d17adf/apps/dav/lib/Migration/Version1027Date20230504122946.php

@kesselb kesselb added the good first issue Small tasks with clear documentation about how and in which place you need to fix things in. label Aug 8, 2023
@kesselb
Copy link
Contributor

kesselb commented Aug 8, 2023

		if ($this->userManager->countSeenUsers() > 100) {
			$this->config->setAppValue('dav', 'pendingSystemAddressbookSync', 'yes');
			$output->warning('Skip system address book sync due the large amount of users. Please run dav:sync-system-addressbook manually.');
			return;
		}

@ChristophWurst
Copy link
Member

We could load-balance the instance sync by dispatching a small background job for each user.

Instead of running the migration in a loop for all users at a time, the migration would dispatch a background job for every user known at upgrade time. The cron/background process will then pick up those jobs in the background, even when the system is live and outside of maintenance mode.

Downside: right after upgrade, data is slightly inconsistent.

@solracsf
Copy link
Member

Note: this is not an LDAP only issue but a "lot of users" issue: #39769

@miaulalala
Copy link
Contributor

Can you give us a guesstimate of the amount of users you have @andrewperry ?

@solracsf solracsf changed the title [Bug]: <dav> upgrade step takes hours when server connected to large LDAP directory [Bug]: <dav> upgrade step takes hours when server connected to large LDAP directory, or has hundreds of users Aug 16, 2023
@joshtrichards joshtrichards added feature: install and update and removed good first issue Small tasks with clear documentation about how and in which place you need to fix things in. labels Aug 23, 2023
@Dennis1993 Dennis1993 unpinned this issue Sep 17, 2023
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 27-feedback bug feature: carddav Related to CardDAV internals feature: dav feature: install and update
Projects
Development

Successfully merging a pull request may close this issue.

7 participants