Server: oc_mounts is updated all the time with the same information

Created on 13 Feb 2017  路  4Comments  路  Source: nextcloud/server

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 f9d94edb0fd0ce)

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.

1. to develop bug filesystem

Most helpful comment

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).

All 4 comments

cc @icewind1991

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 馃槃

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).

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 :)

Was this page helpful?
0 / 5 - 0 ratings