Обсуждение: Patroni configuration issue

Поиск
Список
Период
Сортировка

Patroni configuration issue

От
Deepak tyagi
Дата:
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?

 Thanks & Regards,
Deepak Tyagi
Вложения

Re: Patroni configuration issue

От
sm Linux
Дата:
RTFM


From: Deepak tyagi <deepaktyagi454@gmail.com>
Sent: Monday, July 5, 2021 11:57:52 PM
To: pgsql-admin@postgresql.org <pgsql-admin@postgresql.org>
Subject: Patroni configuration issue
 
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?

 Thanks & Regards,
Deepak Tyagi
Вложения

Re: Patroni configuration issue

От
Vijaykumar Jain
Дата:
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
Вложения

Re: Patroni configuration issue

От
Vijaykumar Jain
Дата:

On Tue, 6 Jul 2021 at 03:37, Vijaykumar Jain <vijaykumarjain.github@gmail.com> wrote:
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.


just following up on this, I was new to etcd and installed v3.5.x and was not sure how to list all keys etc,
turns out, I had to set ETCDCTL_API=2, and use the old version commands to list and del key. 

export ETCDCTL_API=2 # ls does not work on v3
alias ee='etcdctl --endpoints=http://127.0.0.1:2379 '

# i used default namespace and cluster name, so
postgres@db:~/patroni_demo$ ee ls  --recursive /
/service
/service/batman
/service/batman/members
/service/batman/members/postgresql0
/service/batman/members/postgresql1
/service/batman/initialize   --- this is the key we need to delete to reinit the db
/service/batman/config
/service/batman/leader
/service/batman/optime
/service/batman/optime/leader

postgres@db:~/patroni_demo$ ee get /service/batman/initialize
6981912157875070537

# solve i am not leader, server not starting up
ee rm /service/batman/initialize
PrevNode.Value: 6981912157875070537

and then run patroni <config> again as a fresh setup, and you get your leaders and replica just fine.