Hi team,
I am using PG 9.1.2 and I am promoting a slave to master with the
following command.
pg_ctl promote -D /pat/to/data
Command does return back faster with code 0 ( = success). I assumed the
slave is now the master and issued write operations. But the statement
failed as the DB complained that it can do only read operation.
Postgres.log showed "ready to accept connection" a second later after I
issued the statement. So, my understanding is "pg_ctl promote" is
triggering a slave promote and is "asynchornous".
-- Anyway I can query the state of DB to know its status slave or master
?? So, that i can issue write statements only after I know that the DB
is the new master now
-- Or anyway to make pg_ctl promote to wait till the slave is completely
promoted ?
Any help is appreciated.
Comments
Re: Pg_ctl promote -- wait for slave to be promoted fu
By Chris Angelico at 07/20/2012 - 21:57On Sat, Jul 21, 2012 at 5:28 AM, Manoj Govindassamy
< ... at nimblestorage dot com> wrote:
Yep. Use pg_is_in_recovery() - it's false on the master, true on slaves.
<a href="http://www.postgresql.org/docs/9.1/static/functions-admin.html#FUNCTIONS-RECOVERY-INFO-TABLE" title="http://www.postgresql.org/docs/9.1/static/functions-admin.html#FUNCTIONS-RECOVERY-INFO-TABLE">http://www.postgresql.org/docs/9.1/static/functions-admin.html#FUNCTIONS...</a>
ChrisA
Re: Pg_ctl promote -- wait for slave to be promoted fu
By Manoj Govindassamy at 07/23/2012 - 13:54awesome. thanks for the help. Will test it out.
thanks,
Manoj
On 07/20/2012 06:57 PM, Chris Angelico wrote: