[pgpool-general: 7479] Re: Promote specific backend to primary in streaming replication

Tatsuo Ishii ishii at sraoss.co.jp
Mon Apr 5 16:23:39 JST 2021

>> No. Actually failover_command always decides what the new primary will
>> be.
>> "New main node" means the live node (not in down status) which has the
>> youngest node id. Usually (and our sample script) just chooses the new
>> main node as the candidate of new primary because it's the easiest
>> way. (otherwise the script must check whether new primary candidate is
>> actually up or not).
> Oh! I see! So, does this mean that pgpool checks pg_is_in_recovery() to
> find out which node is primary after failover_command has run?

Yes, exactly. See find_primary_node() and
find_primary_node_repeatedly() for more details.

>> Wrapping pcp_set_next_primary or something, and pcp_detach_node looks
>> nice idea because it's flexible. Even you could look for a node which
>> has the least replication delay and let the node be the next primary.
> OK - this sounds great. I can have a stab at getting something like that
> written.
> So, in terms of implementation this sounds like:
> 1) New pcp command to set a next primary backend ID. I'm not sure how this
> would be stored, perhaps update the parsed configuration state (is this
> pool_config), so it could also be in the configuration file? Or, it could
> update a new flag on bkinfo?
> 2) Modify get_next_main_node to include a check for the above, and check
> that it is a valid backend and not the current (failed/detached) primary
> backend.
> Is modifying get_next_main_node() appropriate here? My thinking is that
> doing this means we can continue to use the existing scripts, which use %m
> and %H and so on.
> Perhaps this is best implemented as a backend "primary-ship" priority -
> i.e. set a priority for each backend (via config and pcp) to become the
> primary, as a uint8 on bkinfo, then in get_next_main_node sort first by
> priority then by node id.

Thank you for the great ideas. I need to think about these. Will be
back tomorrow.

Best regards,
Tatsuo Ishii
SRA OSS, Inc. Japan
English: http://www.sraoss.co.jp/index_en.php

More information about the pgpool-general mailing list