Unusably slow server, timeouts - seems related to mounts

I love Nextcloud and use my home server constantly. I’m running into a brutal intermittent performance issue and I’m hoping someone might have ideas on how to work around the problem until I can properly debug it or a fix is released.

The main symptoms are very slow HTTP response times from the web UI, slow WebDAV responses, and timeouts from desktop and mobile clients (they show the server as “offline”). This slowness seems to last for somewhere around 24 hours then seems to resolve on its own. It happens every one to three months or so.

I don’t see anything useful in the logs, but when I run show processlist in MariaDB during the slowdown I see many INSERT and DELETE statements running against the oc_mounts table.

I’ve tried restarting the server (destroying and re-creating Docker containers), disabling apps like External storages support, Talk, Activity, and Full text search, killing the cron job, and killing my elasticsearch server. None of these attempts have helped.

It is in the issue tracker here:

Possibly related:

Interesting, the bout of slowness (as well as the excessive INSERTs and DELETEs) stopped after a few hours. My server is back to normal: lightning fast web UI, WebDAV. Desktop and mobile clients are happy (not timing out). Maybe there’s some periodic (weekly?) Nextcloud clean-up job gone awry?

Latest thing I’ve tried: deleting rows from oc_mounts with NULL in mount_provider_class.

I’m also wondering if its safe to do some cleanup on oc_mounts. I’ll copy my question here from https://github.com/nextcloud/server/issues/35311#issuecomment-1468851352

I have thousands of rows in my oc_mounts table where root_id doesn’t relate to any rows in oc_filecache. Is this expected?

Here’s a few made-up rows that look like what I have about 4,700 of in my oc_mounts table:

id storage_id root_id user_id mount_point mount_id mount_provider_class
1994832 17 3502192 fred /fred/files/Photos/ 4 OCA\Files_External\Config\ConfigAdapter
1994833 17 3502192 bob /bob/files/Photos/ 4 OCA\Files_External\Config\ConfigAdapter
1994834 17 3502192 joe /joe/files/Photos/ 4 OCA\Files_External\Config\ConfigAdapter

But there’s no row in oc_filecache with a fileid of 3502192.