Closed seriouz closed 1 year ago
Hi @seriouz,
Thanks for reporting this issue, and sorry for the delay on getting back to you. We have reproduced the issue and are looking into it. We will write you back once we have an update.
Thanks for investigating the issue.
Hi @seriouz,
We found the cause of the issue. The internal logic to determine the node ID uses the service name plus a custom REPMGR_NODE_ID_START_SEED
environment variable. The reason behind the error is that the default value is 1000
, and you have two services with the same initial-ID
in your docker-compose file. I mean, for both services pg-0
and pgw-0
, the calculated ID is 1000
by default in both services, so that's why you get the "this is already a primary node" error message. You can easily fix it by either setting the REPMGR_NODE_ID_START_SEED=2000
environment variable for the pgw-0
service, or by renaming the service with a non-duplicated number.
It worked fine for me after updating the definition for the pgw-0
service as below
pgw-0:
image: bitnami/postgresql-repmgr:latest
ports:
- 6439:5432
volumes:
- /docker/local/database_repmgr2/pgw-0:/bitnami/postgresql
environment:
- POSTGRESQL_POSTGRES_PASSWORD=adminpassword
- POSTGRESQL_USERNAME=customuser
- POSTGRESQL_PASSWORD=custompassword
- POSTGRESQL_DATABASE=customdatabase
- REPMGR_PASSWORD=repmgrpassword
- REPMGR_PRIMARY_HOST=pg-0
- REPMGR_PRIMARY_PORT=5432
- REPMGR_PARTNER_NODES=pg-0:5432,pg-1:5432,pgw-0:5432
- REPMGR_NODE_NAME=pgw-0
- REPMGR_NODE_NETWORK_NAME=pgw-0
- REPMGR_PORT_NUMBER=5432
- REPMGR_NODE_TYPE=witness
- BITNAMI_DEBUG=true
- REPMGR_NODE_ID_START_SEED=2000
deploy:
resources:
limits:
memory: 5G
replicas: 1
placement:
max_replicas_per_node: 1
After that, you can see in the logs that the witness node is properly connected to the cluster
$ docker-compose up -d && docker-compose logs -f
(...)
debian-11-pgw-0-1 | postgresql-repmgr 16:06:26.60 INFO ==> ** Starting repmgrd **
debian-11-pgw-0-1 | [2023-03-22 16:06:26] [NOTICE] repmgrd (repmgrd 5.3.3) starting up
debian-11-pgw-0-1 | INFO: set_repmgrd_pid(): provided pidfile is /tmp/repmgrd.pid
debian-11-pgw-0-1 | [2023-03-22 16:06:26] [NOTICE] starting monitoring of node "pgw-0" (ID: 2000)
debian-11-pg-0-1 | [2023-03-22 16:06:28] [NOTICE] new standby "pg-1" (ID: 1001) has connected
debian-11-pg-0-1 | [2023-03-22 16:06:28] [NOTICE] new witness "pgw-0" (ID: 2000) has connected
Also, if you check the cluster status from one of the nodes, you can see the three nodes
$ docker-compose exec -it pg-1 bash
I have no name!@29b979158258:/$ /opt/bitnami/scripts/postgresql-repmgr/entrypoint.sh repmgr -f /opt/bitnami/repmgr/conf/repmgr.conf cluster show
postgresql-repmgr 16:08:48.21
postgresql-repmgr 16:08:48.22 Welcome to the Bitnami postgresql-repmgr container
postgresql-repmgr 16:08:48.22 Subscribe to project updates by watching https://github.com/bitnami/containers
postgresql-repmgr 16:08:48.22 Submit issues and feature requests at https://github.com/bitnami/containers/issues
postgresql-repmgr 16:08:48.22
ID | Name | Role | Status | Upstream | Location | Priority | Timeline | Connection string
------+-------+---------+-----------+----------+----------+----------+----------+------------------------------------------------------------------------------------------
1000 | pg-0 | primary | * running | | default | 100 | 1 | user=repmgr password=repmgrpassword host=pg-0 dbname=repmgr port=5432 connect_timeout=5
1001 | pg-1 | standby | running | pg-0 | default | 100 | 1 | user=repmgr password=repmgrpassword host=pg-1 dbname=repmgr port=5432 connect_timeout=5
2000 | pgw-0 | witness | * running | pg-0 | default | 0 | n/a | user=repmgr password=repmgrpassword host=pgw-0 dbname=repmgr port=5432 connect_timeout=5
This isn't a problem in the Helm chart because by default, helm enumerates the different pods with different ID numbers, so these naming collisions don't happen.
Please let us know if it worked for you using the extra environment variable.
Thanks for you sharing! I've tested it and it worked flawlessly!
I have just one request left: Could you please update the docs and mention the we have to use REPMGR_NODE_ID_START_SEED
on vanilla Docker.
Name and Version
bitnami/postgresql-repmgr
What architecture are you using?
amd64
What steps will reproduce the bug?
I have problems setting up the PostgreSQL Repmgr with the new witness node. I've tried multiple variants but neither did work. The witness node in Docker throws an error and shuts down:
Here is my compose:
What do you see instead?
Then the container fails with on the first time (no database exists) with:
The other times it fails with: