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

Enabling polls slows down Nextcloud when using MariaDB/MySQL #3010

Closed
7 of 12 tasks
Pilzinsel64 opened this issue Aug 4, 2023 · 15 comments · Fixed by #3024
Closed
7 of 12 tasks

Enabling polls slows down Nextcloud when using MariaDB/MySQL #3010

Pilzinsel64 opened this issue Aug 4, 2023 · 15 comments · Fixed by #3024

Comments

@Pilzinsel64
Copy link

⚠️ This issue respects the following points: ⚠️

  • This is a bug, not a question or a configuration/webserver/proxy issue.
  • This issue is not already reported on Github (I've searched it).
  • I agree to follow Nextcloud's Code of Conduct.

What went wrong, what did you observe?

  • Enabling the polls app on a fresh instance is very slow.
  • As long as the polls app is enabled, the instance slows down at certain actions. You can especially see that when simply running occ command.
Video.mp4

What did you expect, how polls should behave instead?

  • Enabling the polls app on a fresh instance should be much faster.
  • The polls app should not extremely slow down the whole instance.

What steps does it need to replay this bug?

  1. On a not fresh instance, do all the steps from occ polls:db:purge manually.
  2. Install the polls app.
  3. Run occ and notice the time it takes until something shows up.
  4. Disable the polls app.
  5. Run occ and notice the time it takes until something shows up.

Installation method

Installed/updated from the appstore (Apps section of your site)

Installation type

First time installation

Affected polls version

5.2.0

Which browser did you use, when experiencing the bug?

  • Firefox
  • Chrome
  • Chromium/Chromium based (i.e. Edge)
  • Safari
  • Other/Don't know

Other browser

No response

Add your browser log here

No response

Additional client environment information

No response

NC version

Nextcloud 27 (Nextcloud Hub 5)

Other Nextcloud version

No response

PHP engine version

PHP 8.1

Other PHP version

& PHP 8.2

Database engine

MariaDB

Database Engine version or other Database

& MySQL

Which user-backends are you using?

  • Default user-backend (database)
  • LDAP/ Active Directory
  • SSO - SAML
  • Other/Don't know

Add your nextcloud server log here

No response

Additional environment informations

I have three instances with differnt setup and on different servers. I try keeping it clear.

  • 3x Ubuntu Server 22.04 LTS (amd64 & arm64) as OS
  • 2x Nextcloud manual installed using Plesk Obsidian as Apache, DB & File management (I DON'T use the Nextcloud plugin available for Plesk!! It is bad!)
  • 1x Nextcloud via Snap

Configuration report

{
    "system": {
        "maintenance": false,
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "cloud.pilzinsel64.de",
            "dragoncloud.ddnss.de"
        ],
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "tempdirectory": "\/var\/www\/vhosts\/pilzinsel64.de\/pilzcloud-data\/tmp",
        "dbtype": "mysql",
        "version": "27.0.1.2",
        "overwrite.cli.url": "https:\/\/cloud.pilzinsel64.de",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "",
        "dbtableprefix": "oc_",
        "mysql.utf8mb4": true,
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "app_install_overwrite": [
            "occweb",
            "dropit",
            "files_external_onedrive",
            "ocdownloader",
            "files_readmemd",
            "joplin",
            "workflow_script",
            "twofactor_email",
            "files_markdown",
            "files_automatedtagging",
            "files_accesscontrol",
            "external",
            "files_downloadactivity",
            "files_trackdownloads",
            "terms_of_service",
            "issuetemplate",
            "deck",
            "whiteboard",
            "announcementcenter",
            "documentserver_community",
            "extract",
            "files_3d",
            "hsts",
            "files_texteditor",
            "drop_account",
            "side_menu",
            "apporder",
            "groupfolders",
            "files_linkeditor",
            "login_notes",
            "onlyoffice",
            "talk_simple_poll",
            "talk_matterbridge",
            "twofactor_admin",
            "twofactor_gateway",
            "tasks",
            "twofactor_nextcloud_notification",
            "forms",
            "workflow_pdf_converter",
            "files_retention",
            "flow_notifications",
            "video_converter",
            "integration_whiteboard",
            "hidesidebars",
            "impersonate",
            "file_sharing_invalid_notifier",
            "collectives",
            "approval",
            "jsloader",
            "theming_customcss",
            "cfg_share_links",
            "files_downloadlimit",
            "webhooks"
        ],
        "theme": "",
        "loglevel": 2,
        "twofactor_enforced": "false",
        "twofactor_enforced_groups": [],
        "twofactor_enforced_excluded_groups": [
            "Bot"
        ],
        "filelocking.enabled": true,
        "updater.release.channel": "stable",
        "activity_use_cached_mountpoints": true,
        "remember_login_cookie_lifetime": 15552000,
        "htaccess.RewriteBase": "\/",
        "htaccess.IgnoreFrontController": true,
        "simpleSignUpLink.shown": false,
        "filelocking.ttl": 300,
        "blacklisted_files": [],
        "sharing.enable_share_accept": false,
        "overwriteprotocol": "https",
        "skeletondirectory": "",
        "share_folder": "\/Shares",
        "mail_smtpmode": "smtp",
        "mail_sendmailmode": "smtp",
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpauth": 1,
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpname": "***REMOVED SENSITIVE VALUE***",
        "mail_smtppassword": "***REMOVED SENSITIVE VALUE***",
        "ldapIgnoreNamingRules": false,
        "ldapProviderFactory": "OCA\\User_LDAP\\LDAPProviderFactory",
        "mail_smtpport": "465",
        "mail_smtpsecure": "ssl",
        "default_locale": "de",
        "trusted_proxies": "***REMOVED SENSITIVE VALUE***",
        "memcache.distributed": "\\OC\\Memcache\\Redis",
        "memcache.local": "\\OC\\Memcache\\Redis",
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "redis": {
            "host": "***REMOVED SENSITIVE VALUE***",
            "port": 6379
        },
        "default_phone_region": "DE",
        "addAllowedFrameAncestorDomain": "*.pilzinsel64.de:*"
    }
}

List of activated Apps

Enabled:
  - activity: 2.19.0
  - admin_audit: 1.17.0
  - announcementcenter: 6.6.1
  - apporder: 0.15.0
  - approval: 1.1.0
  - bruteforcesettings: 2.7.0
  - calendar: 4.4.4
  - cfg_share_links: 4.1.0
  - circles: 27.0.1
  - cloud_federation_api: 1.10.0
  - collectives: 2.6.1
  - comments: 1.17.0
  - contacts: 5.3.2
  - contactsinteraction: 1.8.0
  - dashboard: 7.7.0
  - dav: 1.27.0
  - deck: 1.10.0
  - documentserver_community: 0.1.13
  - drop_account: 2.2.0
  - external: 5.2.0
  - extract: 1.3.6
  - federatedfilesharing: 1.17.0
  - federation: 1.17.0
  - file_sharing_invalid_notifier: 0.1.1
  - files: 1.22.0
  - files_3d: 0.5.0
  - files_accesscontrol: 1.17.0
  - files_automatedtagging: 1.17.0
  - files_downloadactivity: 1.16.0
  - files_downloadlimit: 1.1.0
  - files_external: 1.19.0
  - files_external_onedrive: 1.1.0
  - files_linkeditor: 1.1.16
  - files_markdown: 2.4.1
  - files_pdfviewer: 2.8.0
  - files_retention: 1.16.0
  - files_rightclick: 1.6.0
  - files_sharing: 1.19.0
  - files_texteditor: 2.15.1
  - files_trashbin: 1.17.0
  - files_versions: 1.20.0
  - firstrunwizard: 2.16.0
  - flow_notifications: 1.7.0
  - forms: 3.3.1
  - groupfolders: 15.0.1
  - impersonate: 1.14.0
  - integration_openai: 1.0.11
  - integration_whiteboard: 0.0.15
  - login_notes: 1.2.0
  - logreader: 2.12.0
  - lookup_server_connector: 1.15.0
  - nextcloud_announcements: 1.16.0
  - notifications: 2.15.0
  - notify_push: 0.6.3
  - oauth2: 1.15.1
  - occweb: 0.1.0
  - onlyoffice: 8.1.0
  - password_policy: 1.17.0
  - photos: 2.3.0
  - privacy: 1.11.0
  - provisioning_api: 1.17.0
  - recommendations: 1.6.0
  - related_resources: 1.2.0
  - serverinfo: 1.17.0
  - settings: 1.9.0
  - sharebymail: 1.17.0
  - side_menu: 3.10.3
  - spreed: 17.0.3
  - support: 1.10.0
  - survey_client: 1.15.0
  - systemtags: 1.17.0
  - talk_matterbridge: 1.26.0
  - tasks: 0.15.0
  - terms_of_service: 2.2.0
  - text: 3.8.0
  - theming: 2.2.0
  - theming_customcss: 1.14.0
  - twofactor_backupcodes: 1.16.0
  - twofactor_email: 2.7.3
  - twofactor_gateway: 0.20.0
  - twofactor_nextcloud_notification: 3.7.0
  - twofactor_totp: 9.0.0
  - updatenotification: 1.17.0
  - user_migration: 4.0.1
  - user_status: 1.7.0
  - viewer: 2.1.0
  - weather_status: 1.7.0
  - webhooks: 0.4.3
  - workflow_pdf_converter: 1.12.0
  - workflow_script: 1.12.0
  - workflowengine: 2.9.0
Disabled:
  - encryption: 2.15.0
  - polls: 5.2.0 (installed 5.2.0)
  - snowflakestheme: 1.0.0 (installed 1.0.0)
  - social: 0.6.1 (installed 0.6.1)
  - suspicious_login: 5.0.0 (installed 4.3.0)
  - twofactor_admin: 4.1.9 (installed 4.1.9)
  - user_ldap: 1.17.0 (installed 1.10.2)

Nextcloud Signing status

No errors have been found.

Additional Information

  • I tested this on all my three instanced. All have a different configuration and a different webserver configuration. It is hard to tell you exactly all details above, I force on a manual installed instance with less apps on a Ubuntu Server 22.04 LTS with Plesk installed.
  • Regarding the installation mode: It doesn't matter if installed manually, via app store or via occ.
  • The problem weren't there forever. It started within the past year. I just regoniced the instances slowed down after an update but never found the reason. Then I disabled each single app and found out that enabling the polls app is the source of the slowdown.
  • The client environment isn't the source here, for sure. It doesn't matter from where I connect to the server via SSH or what browser. It's a only server thing, for sure.
  • Before I recored the videa, I removed the log file, so the output should be a lot more clear for you. :) And as you can see, there is nothing relevant. There is also nothing regarind polls app when enabling debug mode.
@Pilzinsel64 Pilzinsel64 added the bug label Aug 4, 2023
@Pilzinsel64
Copy link
Author

I got around the information log level. When enabling the app, this both entries get added after a long while and shortly before the app is activated successfully:
grafik

@Pilzinsel64
Copy link
Author

Pilzinsel64 commented Aug 6, 2023

Another useful note: This problem does happen with a fresh install via MariaDB or MySQL. This does NOT happen with SQLite!
There is nothing in mysql.cnf, so everything should be on default.

@Pilzinsel64 Pilzinsel64 changed the title Enabling polls slows down Nextcloud Enabling polls slows down Nextcloud when using MariaDB/MySQL Aug 6, 2023
@dartcafe
Copy link
Collaborator

dartcafe commented Aug 8, 2023

Thanks for your report, but to me it seems to be a performance problem on your side.

Enabling an app on nextcloud triggers the repair steps, like it does while updating. So it is not surprising, that the overall performance is affected since this process.

The repair steps are necessary to check the db integrity and performs fixes, when possible. If there is a more effective way to check this, I am happy for every proposal or direct PR.

@dartcafe dartcafe removed the bug label Aug 8, 2023
@dartcafe
Copy link
Collaborator

dartcafe commented Aug 8, 2023

I don't have a clue, what in polls can affect the instance performance, when installed. I fact, I can't reproduce it.

@Pilzinsel64
Copy link
Author

Thank you for taking a look into! :)

Hm, I understand that there must be a repair step, but that should be called once when enabling, right? So it can't be the reason for this as it doesn't get fixed during the time.

Does the repair step get triggered each time when OCC get throw all apps? What is the entry point there? Maybe then I can get a look to. I mean, I found out that even OCC triggers that delay, so I hoped that when OCC goes throw all apps, there might be just a simple and small area we would need to check. What do you think?

Hm, strange that you aren't able to reproduce. But it is also strange that this issue hasn't been logged so far. Maybe it is a thing on my side?

I have three sompletrly different setups and I am able to reproduce it each single time on all the servers I have, don't matter if snap or manual installation, and don't matter if MySQL or mariadb.

Since one of them is a snap installation, you hopefully can reproduce that by quickly installing a snap via sudo snap install nextcloud.
This is the database configuration for snap installations: https://github.com/nextcloud-snap/nextcloud-snap/blob/master/src/mysql/my.cnf

@dartcafe
Copy link
Collaborator

dartcafe commented Aug 9, 2023

The repair steps are called only once but every time while updating or enabling the app: See docs. We are using the pre-migration and post-migration steps. This explains the delay on enabling.

On all systems I maintain, this just takes maximum 10 seconds. This is rather long compaired to the other apps but IMHO acceptable, since it is a maintaining job.

Why occ seems to be affected, is a miracle to me. I have no idea if and why any polls method should be called by just executing occ.

@dartcafe
Copy link
Collaborator

dartcafe commented Aug 9, 2023

I got around the information log level. When enabling the app, this both entries get added after a long while and shortly before the app is activated successfully: grafik

This is from a repair step checking the hashed values.

@dartcafe
Copy link
Collaborator

dartcafe commented Aug 9, 2023

If you want to find any loaded class you can add a logging of the classname inside the constructor method.

i.e. \OC::$server->getLogger()->debug(get_class());

@Pilzinsel64
Copy link
Author

Why occ seems to be affected, is a miracle to me. I have no idea if and why any polls method should be called by just executing occ.

And exactly this is the point! Why even occ does have the delay? Yes, it also have a delay when accessing the web page from hour to hour very randomly (any app and only when polls is enabled).

The occ command, how does it collect the commands? Maybe this is the point where polls get triggered.
(Sorry for stupid questions, I'm not very fimilar with nc app development yet. :D)

This is rather long compaired to the other apps but IMHO acceptable, since it is a maintaining job.

Of course, I also accept that. Thats totaliy fine when ebaling the app. :)

@dartcafe
Copy link
Collaborator

I could drill down it a little bit. Seems that with calling the occ the commands classes are loaded. The db commands are loading the database schema inside the constructor. This can ex plain, why the issue occurs with a db engine other than sqlite.

The occ command, how does it collect the commands?

The information of the commands is stored inside the ./appinfo/info.xml file. occ parses the commands and loads the corresponding classes to collect detailed information. Doing so the constructors are executed down to the indexManager and tableManager with the schema method.

I have to change the strategy of the commands and redesign the database methods. Another affected issue is #2980, which will also be covered with this redesign.

@Pilzinsel64
Copy link
Author

Pilzinsel64 commented Aug 13, 2023

Aaaah, I understand! Good catch, thanks for that investigation. :)
So, with after movign away the one call from constructor the db sheme should only be loaded if really reaquired and probably speed up the website too. Looking fordward to test these changes. ;)

@dartcafe
Copy link
Collaborator

I changed the construction and the strategy of using the TableManager and IndexManager.
Although the issue is a minor one - the delay of the occ command is not really a problem- I was annoyed from the strategy I tried before. So this was a good reason for refactoring these methods. Unfortunately I could not resolve #2980 without doubling the code, but anyways.

@dartcafe
Copy link
Collaborator

BTW: The performance of updates and enabling will not be improved by this fix.

@Pilzinsel64
Copy link
Author

Thank you a lot! I goive the new beta build a try soon. :)

BTW: The performance of updates and enabling will not be improved by this fix.

Sure, that's fine. I just did wonder if that is the same issue as I didn't regioniced the in the past. So, eveything that isn't 100% the default/known behavior is suspicious, you probably know that. :D

Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants