SQL suddenly uses high CPU

Hi,
I am running nextcloud for a long time, but out of the sudden my mariadb uses 100 % of one core for ever. After a reboot everything is for about 28 minutes fine, but then “usr/sbin/mariadbd” starts to use so much CPU.

The errlor log of nextcloud and mariadbd is empty.
I even tried switching to postgresql. It worked for ~6 h and then out of the sudden in the middle of the night this task started:
postgres: 13/main: nextcloud_db_user nextcloud_db 127.0.0.1(54756) SELECT
and it is running since over 500 minutes. About an hour ago a second task (the same but with a different pid) runs for exact 10 minutes with a pause of 2-6 minutes in between. Now the server uses most the time 4 CPU cores @ 100 %. What is the reason for this CPU usage?

NC: 21.0.3.1
PHP: 8.0.8
SQL: PostgreSQL 13.3

It happend again: After a reboot it was fine for ~12 h. Then, in the middle of the night the same job starts again every 20 minutes and it runs for exact 7 minutes. That’s too much!!

mariadb can log slow sql queries…

system runs low of ram, disk, …? Broken/currupted tables?

This is the only thing in the log file slow sql query log file, which appeared every minute:

# Time: 210727 17:36:53
# User@Host: nextcloud[nextcloud] @ localhost []
# Thread_id: 14176  Schema: nextcloud  QC_hit: No
# Query_time: 3.882616  Lock_time: 0.000038  Rows_sent: 1  Rows_examined: 1381078
# Rows_affected: 0  Bytes_sent: 137
SET timestamp=1627400213;
SELECT `path` FROM `oc_filecache` WHERE (`storage` = 2) AND (`size` < 0) ORDER BY `fileid` DESC LIMIT 1;

Can I see something equal with postgres?

RAM is 1.8 GB used out of 12 GB (it’s a LXC under Proxmox on a R620 - I even tried to give the container 100 GB of RAM and it doesn’t solve the problem). Disk is about 1 TB free.
How can I check for broken or corrupted tables?

probably it as something to do with the cronjob?

Edit: antivirus seems to be the bad boy. I deactivated it and the load is reduced.

1 Like