mirror of
https://github.com/floccusaddon/floccus.git
synced 2026-04-25 14:16:12 +03:00
[GH-ISSUE #792] MySQL troubles #500
Labels
No labels
browser-specific
bug
correctness issues
enhancement
feature: Google Drive
feature: Linkwarden
feature: git
feature: nextcloud-bookmarks
feature: tabs
feature: webdav
help wanted
native-app
priority: high
priority: low
priority: medium
pull-request
question
question
stale
upstream
waiting for more information
wontfix
🙁 Not following issue template
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/floccus#500
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @faaaaabi on GitHub (Jan 16, 2021).
Original GitHub issue: https://github.com/floccusaddon/floccus/issues/792
As mentioned in #476 I still have massive CPU load when using Bookmarks v4.0.5, Floccus v4.4.6, Nextcloud v20.0.1 in combination with syncing floccus
Here are some database insights:
Originally posted by @faaaaabi in https://github.com/marcelklehr/floccus/issues/476#issuecomment-726923253
@marcelklehr commented on GitHub (Jan 16, 2021):
You could try having mysql/mariadb rebuild the table by doing
-- https://dev.mysql.com/doc/refman/8.0/en/rebuilding-tables.html
i.e.
or try one of https://stackoverflow.com/questions/30051510/how-can-i-rebuild-indexes-and-update-stats-in-mysql-innodb
@marcelklehr commented on GitHub (Jan 20, 2021):
A different option as the one above may not work is to drop the index in question and recreate it manually.
That would mean creating a new index first:
@panachoi commented on GitHub (Jan 21, 2021):
So, is the "proper" way to do this:
see the output of:
mysql> show index from oc_bookmarks;
oc_bookmarks | 1 | IDX_3EE1CD04A76ED395 | 1 | user_id
KEY
IDX_3EE1CD04A76ED395(user_id),Then:
ALTER TABLE oc_bookmarks ADD INDEX
bookmarks_userid(user_id);Then:
ALTER TABLE oc_bookmarks DROP INDEX IDX_3EE1CD04A76ED395;
And thats it ?
@marcelklehr commented on GitHub (Jan 21, 2021):
That's the idea. Before you do that, try @faaaaabi's analytical queries above to see if your indexes are actually the problem.
@panachoi commented on GitHub (Jan 21, 2021):
This gets more "interesting" for comparison:
I certainly didn't set this, buit this looks suspiciously like the issue here.
Just checked a "newer" (different) mysql server
I'm now wondering where/why @faaaaabi variables have been hand-modified (essentially doubled)
@mnalis commented on GitHub (Jan 21, 2021):
@panachoi defaults may differ depending on GNU/Linux distribution used (or even other OS), or specific defaults for that Mysql / MariaDB version, etc. so that difference between different systems is not that important.
What is important is that:
to check this, also would be interesting:
free -h(memory use)ps auxfwww | grep mysql(memory used by mysqld)uptimeorcat /proc/loadavg(system load)cat /proc/cpuinfo(number of processors)Output of those should be obtained while the slow operation is in progress.
Also, how exactly is massive CPU load being determined? And is it really only CPU load (processes in
Rstate) or systemloadavg(as returned byuptimecommand, which counts bothRunning processes, and processes inDstate - often due to being swapped out due to insufficient memory or blocked by slow disk I/O)But while I'm not using
oc_bookmarks, theEXPLAIN SELECTdoes look suspicious - thekeycolumn should not beNULLif table contains any data and possible indexes.ANALYZE TABLE tablename(or slowerOPTIMIZE table tablename) might sometimes help.@faaaaabi if you run that "SELECT" command by hand, how long does it take to execute?
@KlugFR commented on GitHub (Mar 9, 2021):
Same issue here with the last versions of the apps (NC 20.0.8, according bookmarks and Floccus 4.6.0).
With Floccus enabled in firefox on my mac, load on the NextCloud server was over 8 all the time, with 4 to 20 php-fpm processes at 100% CPU each all the time.
With Floccus disabled, load drops down to 0.2 on the server...
You can see the CPU usage drop on the graph (4 x E2697-v3 cores, the VM is on its own on the host).
I disabled sync at 15h54 and re-enabled it for testing at 15h59 after I fixed the two "looks like broken" indexes in oc_bookmarks.
Even if the issue is named after mysql, the issue seems to be in php-fpm CPU usage, not mariadb.
@marcelklehr commented on GitHub (Mar 9, 2021):
@KlugFR If you experience different problems, this may be the wrong issue for you. The focus of this issue is MySQL/MariaDB troubles. Or did I get this wrong?
@KlugFR commented on GitHub (Mar 9, 2021):
Initial issue (https://github.com/floccusaddon/floccus/issues/476) of the OP is the same as I encountered : massive CPU.
In the initial issue (closed) the OP suggested it could be mysql issues but nothing in his posts links "massive CPU" and "mysql (or mariadb) server".
I posted here because I think the issue is not mysql (or mariadb) related: even with broken/fixed indexes, the issue is in php-fpm, even with the current versions of the apps.
@marcelklehr commented on GitHub (Mar 9, 2021):
Ah, I see. #476 was fixed, though. This issue was opened, because it is a separate problem. I encourage you to open a new issue detailing your problem. (Warning: Please stick to the issue template, as your issue will be closed otherwise.)
@faaaaabi commented on GitHub (Mar 12, 2021):
Thanks for the tip.
After dumping, re-importing and re-indexing, the problem still persists.
300 rows in set (1 min 40.444 sec)
@mnalis commented on GitHub (Mar 15, 2021):
@faaaaabi that is interesting; while
oc_bookmarkslookup does not seem to be using indexes, it is just several hundreds rows, so it should not be that bad. Spending any amount of time inCreating sort indexsounds strange though.could you also do:
I'm interested in output of
select count(*), and output ofshow profile. For main long query (which you replace with the slow query you see inshow full processlist), please do not paste full data output, but just statistics at the end (like you did above - "xxx rows in a set (x min yy sec)")Also, if do you have shell access on machine running
mysqld(might be different from machine running nextcloud web server), and if so could you send outputs I asked for in https://github.com/floccusaddon/floccus/issues/792#issuecomment-764907180 (especiallyfree -hand 'ps auxfwww | grep mysql` are important).It might help me point you to few things you can try (but they are very dependent on memory use on the server)
@faaaaabi commented on GitHub (Mar 15, 2021):
MySQL runs in a docker container without cgroup limits. The machine also has plenty of memory. Nevertheless here is the output from inside the MySQL container.:
@mnalis commented on GitHub (Mar 17, 2021):
Sending dataandCreating sort indexare two longest running states here. Thread states are explained here. Might be (or not) caused by slow random disk I/O.However, preceding
Converting HEAP to Ariais indicative that temporary tables did not fit into memory and were moved to disk, which could lead to slowdowns (especially if using rotational media HDDs). Should not have such drastic effects, but you never know.select count(*) from oc_bookmarks_tree;then wait for few syncs to run and then run it again? What are the numbers? (and what version of OC bookmarks app are you currently on - still4.0.5or newer)?Because it looks suspicious to me that you have just
796bookmarks (oc_bookmarkstable), but55116entries inoc_bookmarks_tree, which should (as I understand it) only contain extra entries for folders etc. (so should probably have less then1000entries or so - definitely nowhere near55000). @marcelklehr do I get that correctly, or are there legitimate cases foroc_bookmarks_treeto grow so much bigger thanoc_bookmarks?In my opinion (but I'm not bookmarks app developer!), if that number grows while no new bookmarks are added, it might indicate a bug in Bookmarks app. Even if it does not grow, it might've been bug in previous versions on bookmarks app, (and perhaps root cause of slowness). If that is the case, maybe you'd want to try: (1) backuping bookmarks just in case, (2) removing the bookmarks app, (3) dropping old oc_bookmarks* tables , (4) reinstalling newest Bookmarks app, (5) trying to sync again and checking the counts and speed again.
@marcelklehr commented on GitHub (Jul 24, 2021):
Hey there!
It's been a while, but I've finally uncovered the reason for this peculiar behavior and will release a patch to the bookmarks app shortly: https://github.com/nextcloud/bookmarks/pull/1608
The problem was that the query in question needs to load all bookmarks in the db initially since they could all potentially be viewed by the current user (if they are shared with the current user, which however, will only be discovered after a JOIN). My solution, now, is to initially only load bookmarks by users that have shared bookmarks with the current user, which is still not ideal, but should be a much smaller set than ALL.
@marcelklehr commented on GitHub (Jul 24, 2021):
the tree table should not grow much larger than the bookmarks table, except for cases where the same bookmark is in multiple folders. There is now a repair step that should get rid of all superfluous tree entries.
@marcelklehr commented on GitHub (Jul 26, 2021):
Should be fixed with https://github.com/nextcloud/bookmarks/releases/tag/v4.4.0
@github-actions[bot] commented on GitHub (Mar 20, 2023):
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.