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

oc_mounts is updated all the time with the same information #3461

Closed
GreenArchon opened this issue Feb 12, 2017 · 4 comments · Fixed by #3588
Closed

oc_mounts is updated all the time with the same information #3461

GreenArchon opened this issue Feb 12, 2017 · 4 comments · Fixed by #3588
Labels
1. to develop Accepted and waiting to be taken care of bug feature: filesystem

Comments

@GreenArchon
Copy link
Contributor

GreenArchon commented Feb 12, 2017

Steps to reproduce

  1. Have a basic new NC11 or master instance, with local storage, mysql database
  2. Create user{1,2}
  3. Create n (5 in the following logs) folders in user1, share them with user2
  4. Logon with user2, let the first time logon and database be populated, etc.
  5. Log off user2
  6. Start logging sql queries
  7. Log on user2

Expected behaviour

Performance is relatively smooth, and already being up to date, oc_mounts is not updated

Actual behaviour

Login, and every page load is slow as **** (~10 sec on test instance with 5 folders shared)

Query log is full of

		33661 Query	UPDATE `oc_mounts` SET `storage_id` = '1', `mount_point` = '/user2/files/folder 5/', `mount_id` = NULL WHERE (`user_id` = 'user2') AND (`root_id` = 36)
		33661 Query	UPDATE `oc_mounts` SET `storage_id` = '1', `mount_point` = '/user2/files/folder 4/', `mount_id` = NULL WHERE (`user_id` = 'user2') AND (`root_id` = 35)
170212 18:00:18	33661 Query	UPDATE `oc_mounts` SET `storage_id` = '1', `mount_point` = '/user2/files/folder 3/', `mount_id` = NULL WHERE (`user_id` = 'user2') AND (`root_id` = 34)
		33661 Query	UPDATE `oc_mounts` SET `storage_id` = '1', `mount_point` = '/user2/files/folder 2/', `mount_id` = NULL WHERE (`user_id` = 'user2') AND (`root_id` = 33)
		33661 Query	UPDATE `oc_mounts` SET `storage_id` = '1', `mount_point` = '/user2/files/folder 1/', `mount_id` = NULL WHERE (`user_id` = 'user2') AND (`root_id` = 31)

Full means, for 5 folders shared, when logging in then logging out, 95 updates (or 19/share), all updating to exactly the same values.

On my (relatively small) production system, each update (ie for each share) on oc_mounts takes 0.05 to 0.5s, with 10-30 shares/user...

Server configuration

Operating system: Centos 7

Web server: apache

Database: mysql

PHP version: 5.6

Nextcloud version: (see Nextcloud admin page) 11.0.1, master (as of f9d94ed)

Updated from an older Nextcloud/ownCloud or fresh install: Irrelevant (happens in local test setup as well as production instance)

Are you using external storage, if yes which one: local

Are you using encryption: no

Are you using an external user-backend, if yes which one: Irrelevant (happens in local test setup as well as LDAP instance)

Diagnostics and hack-fix

Digging into the code, it seems that the function findChangedMounts() (lib/private/Files/Config/UserMountCache.php#L138), which determines if the db needs to be updated always returns all the mounts as having changed, because this condition is always true:

if (
	$newMount->getRootId() === $cachedMount->getRootId() &&
	(
		$newMount->getMountPoint() !== $cachedMount->getMountPoint() ||
		$newMount->getStorageId() !== $cachedMount->getStorageId() ||
		$newMount->getMountId() !== $cachedMount->getMountId()
	)
) {
	$changed[] = $newMount;
}

Looking into details, it seems that $newMount->getStorageId() is a string while $cachedMount->getStorageId() is an int (or vice versa, I don't remember), at least for the test case presented at the top.

I would have done a pull request, but I'm unsure whether getStorageID should be an int or a string. In the meantime, changing the !== to != solves the issue, and everything is fast and smooth again and I now believe the "Nextcloud 11 is faster" claims.

Note that this might be related to people having issues in #2272 and #3134.

@MorrisJobke
Copy link
Member

cc @icewind1991

@icewind1991
Copy link
Member

I would have done a pull request, but I'm unsure whether getStorageID should be an int or a string.

As the phpdoc would tell you, and int 😄

@GreenArchon
Copy link
Contributor Author

GreenArchon commented Feb 15, 2017

As the phpdoc would tell you, and int 😄

Damn, my laziness has been busted :-P

Very well, (unless you wanna do it) I'll prepare a pull request in the next few days (depending on free time).

@MorrisJobke
Copy link
Member

Very well, (unless you wanna do it) I'll prepare a pull request in the next few days (depending on free time).

Awesome :) Thanks in advance :)

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 bug feature: filesystem
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants