Postgresql docker health check

2024-03-13 Thread Amna Abdul Rehman
Hello,

Hope this email finds you well. Currently, I have a running PostgreSQL
container, and I've encountered an issue. When my application runs
overnight, I receive the error message 'FATAL: Sorry, too many clients
already.' To address this, I increased the number of max_connections to
3000, 5000, and also 1, but I still receive the error. Now, I'm
considering implementing a health check. Specifically, I'd like to
automatically restart the PostgreSQL container if this error occurs. How
can I achieve this with a health check in my Docker Compose?

postgres:
restart: always
image: postgres:latest
# mem_limit: 1g
ports:
- ${POSTGRES_PORT}:${POSTGRES_PORT}
volumes:
- ./data/db/postgres:/var/lib/postgresql/data:rw
environment:
- POSTGRES_USER=${POSTGRES_USER}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
- POSTGRES_DB=${POSTGRES_DB}
healthcheck:
test: ["CMD-SHELL", "sh -c 'pg_isready -U ${POSTGRES_USER} -d
${POSTGRES_DB}'"]
interval: 30s
timeout: 10s
retries: 5
extra_hosts:
- "postgres:${HOST_IP}"

Best regards,
-- 
Amna A Rehman
*amnaarehma...@gmail.com *


Re: could not open file "global/pg_filenode.map": Operation not permitted

2024-03-13 Thread Stephen Frost
Greetings,

* Nick Renders (postg...@arcict.com) wrote:
> > ...run them under different users on the system.
> 
> Are you referring to the "postgres" user / role? Does that also mean setting 
> up 2 postgres installation directories?

Yes, two separate MacOS user accounts is what I was suggesting.  You
could use the same postgres binaries though, no need to have two
installation of them.  You'd need seperate data directories, of course,
as you have currently.

> This script runs on a daily basis at 4:30 AM. It did so this morning and 
> there was no issue with cluster B. So even though the issue is most likely 
> related to the script, it does not cause it every time.

Seems likely that it's some sort of race condition.

Thanks,

Stephen


signature.asc
Description: PGP signature