rysilva
By:
rysilva

Postgres stopped running, is there a way I can get alerts if this happens?

August 19, 2017 176 views
PostgreSQL Monitoring Ubuntu 16.04

I recently realized my site was down, and after I checked the logs I noticed I couldn't connect to postgres. Once I started postgres the site was back up.

Couple of questions:

  • What might cause postgres to stop?
  • What's a way that I could get an alert if my site goes down?
1 Answer

Then you would need to check postgres logs to find out why it crashes.

  • Looks like it ran out of memory.

    2017-08-16 15:37:13 UTC [1614-2] LOG:  received fast shutdown request
    2017-08-16 15:37:13 UTC [1614-3] LOG:  aborting any active transactions
    2017-08-16 15:37:13 UTC [1640-2] LOG:  autovacuum launcher shutting down
    2017-08-16 15:37:13 UTC [1637-1] LOG:  shutting down
    2017-08-16 15:37:13 UTC [1637-2] LOG:  database system is shut down
    2017-08-16 15:37:15 UTC [31373-1] FATAL:  could not map anonymous shared memory: Cannot allocate memory
    2017-08-16 15:37:15 UTC [31373-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.
    
    • Google your error and it will give you the solution.

      • I didn't have any trouble starting postgres and I haven't had any issues in the past, so I'm not sure whether there's actually anything to resolve.

        • Postgres running out memory is a sign you're not allocating enough memory to it. If you don't resolve it now, it will happen in the future specially when more people use your site.

Have another answer? Share your knowledge.