Lists: | pgsql-generalpgsql-hackers |
---|
From: | Manoj Govindassamy <manoj(at)nimblestorage(dot)com> |
---|---|
To: | <pgsql-general(at)postgresql(dot)org> |
Subject: | Pg_ctl promote -- wait for slave to be promoted fully ? |
Date: | 2012-07-20 19:28:33 |
Message-ID: | 5009B161.6060602@nimblestorage.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | Postg메이저 토토 사이트SQL pgsql-hackers |
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.
--
thanks,
Manoj
From: | Chris Angelico <rosuav(at)gmail(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Pg_ctl promote -- wait for slave to be promoted fully ? |
Date: | 2012-07-21 01:57:43 |
Message-ID: | CAPTjJmo7DZ3AbHn0iDbRxSUn6zcmENriBra0ynhyp5VvCmtugw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general pgsql-hackers |
On Sat, Jul 21, 2012 at 5:28 AM, Manoj Govindassamy
<manoj(at)nimblestorage(dot)com> wrote:
> -- 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
Yep. Use pg_is_in_recovery() - it's false on the master, true on slaves.
http://www.postgresql.org/docs/9.1/static/functions-admin.html#FUNCTIONS-RECOVERY-INFO-TABLE
ChrisA
From: | Manoj Govindassamy <manoj(at)nimblestorage(dot)com> |
---|---|
To: | Chris Angelico <rosuav(at)gmail(dot)com> |
Cc: | <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Pg_ctl promote -- wait for slave to be promoted fully ? |
Date: | 2012-07-23 17:54:36 |
Message-ID: | 500D8FDC.8090004@nimblestorage.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general pgsql-hackers |
awesome. thanks for the help. Will test it out.
thanks,
Manoj
On 07/20/2012 06:57 PM, Chris Angelico wrote:
> On Sat, Jul 21, 2012 at 5:28 AM, Manoj Govindassamy
> <manoj(at)nimblestorage(dot)com> wrote:
>> -- 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
> Yep. Use pg_is_in_recovery() - it's false on the master, true on slaves.
>
> http://www.postgresql.org/docs/9.1/static/functions-admin.html#FUNCTIONS-RECOVERY-INFO-TABLE
>
> ChrisA
>
From: | Magnus Hagander <magnus(at)hagander(dot)net> |
---|---|
To: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Pg_ctl promote -- wait for slave to be promoted fully ? |
Date: | 2012-08-07 13:22:16 |
Message-ID: | CABUevEyeSA=U+2XeftMXzuv1-c_yKk6-haKA=hPUpZcsxKxpNw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general pgsql-hackers |
Should we consider if we can make "pg_ctl -w" work for "promote" as well?
The main problem is, I guess, that it can't log in - so wed' need
something like "PQping()" that actually checked if it was master or
slave?
//Magnus
---------- Forwarded message ----------
From: Manoj Govindassamy <manoj(at)nimblestorage(dot)com>
Date: Fri, Jul 20, 2012 at 9:28 PM
Subject: [GENERAL] Pg_ctl promote -- wait for slave to be promoted fully ?
To: pgsql-general(at)postgresql(dot)org
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.
--
thanks,
Manoj
--
Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general
--
Magnus Hagander
Me: http://www.hagander.net/
Work: http://www.redpill-linpro.com/
From: | Fujii Masao <masao(dot)fujii(at)gmail(dot)com> |
---|---|
To: | Magnus Hagander <magnus(at)hagander(dot)net> |
Cc: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Pg_ctl promote -- wait for slave to be promoted fully ? |
Date: | 2012-08-07 17:09:32 |
Message-ID: | CAHGQGwEiZ=Z6om8_=GkEd4PH5mg9jGxM-PY_VtX2Wts=_CDmBA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general pgsql-hackers |
On Tue, Aug 7, 2012 at 10:22 PM, Magnus Hagander <magnus(at)hagander(dot)net> wrote:
> Should we consider if we can make "pg_ctl -w" work for "promote" as well?
+1
> The main problem is, I guess, that it can't log in - so wed' need
> something like "PQping()" that actually checked if it was master or
> slave?
Yes.
Regards,
--
Fujii Masao
From: | Robert Haas <robertmhaas(at)gmail(dot)com> |
---|---|
To: | Fujii Masao <masao(dot)fujii(at)gmail(dot)com> |
Cc: | Magnus Hagander <magnus(at)hagander(dot)net>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Pg_ctl promote -- wait for slave to be promoted fully ? |
Date: | 2012-08-07 20:37:06 |
Message-ID: | CA+TgmobqgGqn2zRaOKXPj_zwskGfwzohqVWd2m4JQe1J7biRWA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | Postg토토 핫SQL : pgsql-hackers |
On Tue, Aug 7, 2012 at 1:09 PM, Fujii Masao <masao(dot)fujii(at)gmail(dot)com> wrote:
> On Tue, Aug 7, 2012 at 10:22 PM, Magnus Hagander <magnus(at)hagander(dot)net> wrote:
>> Should we consider if we can make "pg_ctl -w" work for "promote" as well?
>
> +1
>
>> The main problem is, I guess, that it can't log in - so wed' need
>> something like "PQping()" that actually checked if it was master or
>> slave?
>
> Yes.
Is there a security concern with exposing this information to people
who haven't authenticated?
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company