Nextcloud gives MySQL "Memory allocation error: 1038 Out of sort memory"

My YunoHost server

Hardware: Old laptop or computer
YunoHost version: 4.3.4.2
I have access to my server : Through SSH and webadmin. I also have direct physical access to the server if needed.
Are you in a special context or did you perform some particular tweaking on your YunoHost instance ? : no

Description of my issue

For several weeks, my Nextcloud installation has been inaccessible. My CalDAV synchronization has failed, general file synchronization has too, and I’ve been unable to log in to the Nextcloud web UI.

My CalDAV app and Nextcloud’s error logs report the same error:

“message”:“An exception occurred while executing a query: SQLSTATE[HY001]: Memory allocation error: 1038 Out of sort memory, consider increasing server sort buffer size” […]

Well, I know how to search for error codes. I found this StackOverflow question, as well as this post here on the forum (which linked back to StackOverflow). I edited /etc/mysql/my.cnf and /etc/mysql/mariadb.cnf and increased the value of sort_buffer_size to 256K. I’ve rebooted the server, and:

Nothing. I still encounter the same errors in the same situations.

I’m puzzled, so I’m coming to you. What can I do to fix this “Out of sort memory” issue, since I thought I’d increased the sort buffer as others recommended?

Thanks in advance.

1 Like

I had some problems (probably unrelated) with Nextcloud earlier, also tried (without success) to solve it by increasing memory allocations.

In my case, the file cache had taken on monstrous proportions, preventing any upgrade of Nextcloud. Deleting the cache deleted all information about shares, but enabled upgrades.

Which version is your Nextcloud, and how much space does your database (du -hs /var/lib/mysql/nextcloud/) take? Mine was 300+GB, and is now 300-MB.

I’m running Nextcloud v22.2.3~ynh1, and my Nextcloud database is currently 47M. Not nearly the 300+ GB you ran into, yikes!

That is up to date and a small database, should not give any troubles. I imagine you had a look at RAM usage; if there’s ample RAM available, you could double the sort buffers once more.

After the trouble I had before were settled, Yunohost diagnosis told me there was something off with the MySQL config (those enlarged buffers), and I reverted them to the default. No problem, with a larger DB than yours and smaller buffers (but not so many users, that could be a thing).

Sorry to not be of any more help!

I seem to have solved this, at least for now, by increasing the sort_buffer_size even further, to 2M. Now I can access the web GUI and I’m no longer receiving the error 1038.

Sources I followed included:

There are some suggestions that the Circles app (in Nextcloud) may also be a culprit. I did not do anything to disable it in this case, but I’m pointing it out in case that is helpful to others in a similar predicament.

1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.