Re: Patroni configuration issue - Mailing list pgsql-admin

From Vijaykumar Jain
Subject Re: Patroni configuration issue
Date
Msg-id CAM+6J9706uiLAtCXdk6Pd_L49fi7rjxvwNxb=rq5nT6Po9EOxw@mail.gmail.com
Whole thread Raw
In response to Patroni configuration issue  (Deepak tyagi <deepaktyagi454@gmail.com>)
Responses Re: Patroni configuration issue  (Vijaykumar Jain <vijaykumarjain.github@gmail.com>)
List pgsql-admin
On Mon, 5 Jul 2021 at 23:58, Deepak tyagi <deepaktyagi454@gmail.com> wrote:
Hi,
After installation and configuration patroni, we are getting below message while checking the patroni status:
Waiting for leader to bootstrap

image.png
So can you please help me to fix it?

although i have not used patroni, but in the interest of trying to reproduce your problem, i tried to do a setup,
 and i was able to reproduce it as below

all etcd and patroni on same node using patroni/README.rst at master · zalando/patroni (github.com)
i.e on different terminals

> etcd --data-dir=data/etcd --enable-v2=true

> ./patroni.py postgres0.yml  -- start this, wait for master to initalize using initdb , patroni show msg "Lock owner: postgresql1; I am postgresql0"
now i force stop this newly elected master. note this node is holding a lock for being a leader

> ./patroni.py postgres1.yml  -- start this when p0 is down. ideally when it is started as replica, it would run a pg_basebackup from the master and identify as replica.
but since the master is down and holding the lock, it is unable to initialize or run initdb, and hence runs with

2021-07-06 03:08:14,797 INFO: Lock owner: None; I am postgresql1
2021-07-06 03:08:14,798 INFO: waiting for leader to bootstrap

ideally, if the cluster was initialized early on with nodes running, patroni would have failed over to this node, but since the db is *not* initialized, it did not failover and kept waitng for a lock.
there are two options here,
either i check if there is any cluster initlialised with a lock is stopped and start it back, or remove the stopped node from the cluster so that another node waiting for lock can now initialize.

once this leader node restarted, the replica would basebackup from  the existing primary /leader
else if stopped leader is removed as above, then other node reinitializes as master and you are good to go.

this ticket helped me understand the error.

I may be wrong in my simulation (my first time), but in that case you will have to describe how did you setup your cluster, did you use any reference etc?
maybe that might help me understand this more.

--
Thanks,
Vijay
Mumbai, India
Attachment

pgsql-admin by date:

Previous
From: sm Linux
Date:
Subject: Re: Patroni configuration issue
Next
From: abbas alizadeh
Date:
Subject: Upgrade postgresql