From: | Tatsuo Ishii <ishii(at)sraoss(dot)co(dot)jp> |
---|---|
To: | pg(at)fastcrypt(dot)com |
Cc: | ishii(at)sraoss(dot)co(dot)jp, tsunakawa(dot)takay(at)jp(dot)fujitsu(dot)com, tgl(at)sss(dot)pgh(dot)pa(dot)us, robertmhaas(at)gmail(dot)com, laurenz(dot)albe(at)cybertec(dot)at, kommi(dot)haribabu(at)gmail(dot)com, jingwangian(at)gmail(dot)com, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: Libpq support to connect to standby server as priority |
Date: | 2019-01-18 06:28:13 |
Message-ID: | 20190118.152813.1590173105330561170.t-ishii@sraoss.co.jp |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
>> If you need some input from me regarding finding a primary node,
>> please say so. While working on Pgpool-II project, I learned the
>> necessity in a hard way.
>>
>>
> I would really like to have a consistent way of doing this, and consistent
> terms for the connection parameters.
>
> that said yes, I would like input from you.
Sure, no problem.
- Upon Pgpool-II starting up or recieving failover event or switch
over event, primary node finding is executed.
- It repeats following until timeout parameter
("search_primary_node_timeout" is expired)
do until the timeout is expired
{
for all_live_backends
{
connect to the backend.
execute "SELECT pg_is_in_recovery()".
if it returns false, the we find the primary node. Assume
other backend as standbys and we are done.
disconnect to the backend
}
sleep 1 second;
}
If no primary node was found, all backends are regarded as standbys.
In addition to above, recent Pgpool-II versions does optional checking
to verify backend status, for example, finding a case where there
are two primary nodes.
- If there are two primaries, check the connectivity between each
primary and standbys using pg_stat_wal_receiver() (so this can not
be executed with PostgreSQL version 9.5 or before)
- If there's a primary (call it "A") which is not connected to any of
standbys while there's a primary (call it "B") which is connected to
all of standbys, then A is regarded as a "false primary" (and
Pgpool-II detaches it from the streaming replication cluster managed
by Pgpool-II if detach_false_primary is enabled).
See Pgpool-II manual "detach_false_primary" section in
http://tatsuo-ishii.github.io/pgpool-II/current/runtime-config-failover.html for more details.
Best regards,
--
Tatsuo Ishii
SRA OSS, Inc. Japan
English: http://www.sraoss.co.jp/index_en.php
Japanese:http://www.sraoss.co.jp
From | Date | Subject | |
---|---|---|---|
Next Message | Surafel Temesgen | 2019-01-18 06:29:11 | Re: pg_dump multi VALUES INSERT |
Previous Message | Tsunakawa, Takayuki | 2019-01-18 06:20:56 | RE: Libpq support to connect to standby server as priority |