Can't increase db_shared_buffers (0.1% of total ram) and db_work_mem (0.03% of total ram)

This is a bit of a head scratcher :upside_down_face:

Have a freshly migrated Discourse instance on a new server.

Getting the error in logs: PG::DiskFull (ERROR: could not resize shared memory segment "/PostgreSQL.1759815625" to 8388608 bytes: No space left on device )

It’s strange because, the previous server (64gb ram) didn’t have this issue and I had these set:

db_shared_buffers: "25632MB"
db_work_mem: "160MB"

On the new server (128gb ram), I can’t increase above the baseline defaults (I tried tripling the values below and get the same PG DiskFull error):

db_shared_buffers: "128MB"
db_work_mem: "40MB"

Previous machine has docker 27.x on it (auto installed via the discourse installer). New machine installed docker.io as per instructions (so 26.x). I tried switching to docker 27.x to see if that was related - but it didn’t change anything. Both are on the Stable Discourse branch, version 3.3.2.

It seems shm_size might be the main culprit:

Though no idea why it wasn’t an issue on the previous server and it is on the new server. The only other main difference is the old server uses Ubuntu 22.04 LTS and the new server is on 24.04 LTS.

I tried this also, but the changes get overwritten when the container is started again

shm_size appears to be hardcoded into the launcher:

Any insights or help would be appreciated! :meow_heart:

Refers to the hard drive space, not the ram.

1 Like

Thanks @pfaffman - I thought that too initially, but then I read this thread:

There is a lot of free space also :confused:

1 Like

So a quick duct tape fix is to simply edit the launcher file like:

cd /var/discourse
vi launcher

Then replace all 3 occurances of
--shm-size=512m
with the desired ram amount (I went with 50% of system ram).

Then rebuild. Will need to edit it again every time the launcher updates.

Seems to be doing the job for the time being.

water leaking fix with flex tape

1 Like

So to follow up in case someone else faces this issue - the above solved this for me. I do not need to edit shm-size in the launcher anymore.

This was found after noticing this warning during rebuild:
WARNING Memory overcommit must be enabled! Without it, a background save or replication may fail under low memory condition. Being disabled, it can can also cause failures without low memory condition, see https://github.com/jemalloc/jemalloc/issues/1328. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.

2 Likes