Question

Am I misunderstanding this crazy high SHMMAX value for postgres? Any thing else I should look at for a postgres server fatal errror?

I have a postgres server running as a backend for a low-usage flask site on a digital ocean droplet. The only thing that’s going in is small amounts of text.

Suddenly this happened:

2017-08-16 04:49:26 UTC [13529-1] FATAL: could not map anonymous shared memory: Cannot allocate memory 2017-08-16 04:49:26 UTC [13529-2] HINT: This error usually means that PostgreSQL’s request for a shared memory segment exceeded available memory, swap space, or huge pages. To reduce the request size (currently 148488192 bytes), reduce PostgreSQL’s shared memory usage, perhaps by reducing shared_buffers or max_connections.

According to cat /proc/sys/kernel/shmmax:

SHMMAX is: 18446744073692774399 or 18e18 bytes! (Postgres documentation does say it’s bytes, not bits) How did the error message get 148488192 bytes? I guess some kind of overflow. But this value is crazy!

My droplet only has 512Mb of memory.

Am I missing something?

Clearly this isn’t the only thing that went wrong – why would a low usage site with which only puts ~2kb of text in a table at a time suddenly be using too much memory?

FYI: This is my first time using a database or running a website.

I’m doing it as a low-stakes learning exercise, so any pointers into other logs I should look at, changing/what is happening with SHMMAX, or what else to look out for would be greatly appreciated. It was running smoothly for a couple of months before this, and after rebooting the droplet, everything has continued to run smoothly.

The full Postgres logs were:

2017-08-16 04:49:17 UTC [1583-2] LOG: received fast shutdown request 2017-08-16 04:49:17 UTC [1583-3] LOG: aborting any active transactions 2017-08-16 04:49:17 UTC [1588-2] LOG: autovacuum launcher shutting down 2017-08-16 04:49:17 UTC [5146-1] user@user FATAL: terminating connection due to administrator command 2017-08-16 04:49:17 UTC [5149-1] user@user FATAL: terminating connection due to administrator command 2017-08-16 04:49:17 UTC [5147-1] user@user FATAL: terminating connection due to administrator command 2017-08-16 04:49:17 UTC [1585-1] LOG: shutting down 2017-08-16 04:49:17 UTC [1585-2] LOG: database system is shut down 2017-08-16 04:49:26 UTC [13529-1] FATAL: could not map anonymous shared memory: Cannot allocate memory 2017-08-16 04:49:26 UTC [13529-2] HINT: This error usually means that PostgreSQL’s request for a shared memory segment exceeded available memory, swap space, or huge pages. To reduce the request size (currently 148488192 bytes), reduce PostgreSQL’s shared memory usage, perhaps by reducing shared_buffers or max_connections.


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Hello,

I could suggest adding a bit more RAM to your server as described here:

https://docs.digitalocean.com/products/droplets/how-to/resize/

Or alternatively, you could add a swap file so that you have some additional buffer:

https://www.digitalocean.com/community/tutorials/how-to-add-swap-space-on-ubuntu-16-04

Best,

Bobby