[pgpool-committers: 2849] pgpool: Consider the situation when the pgpool-II is started and the Po

Muhammad Usama m.usama at gmail.com
Mon Dec 7 04:35:48 JST 2015

Consider the situation when the pgpool-II is started and the PostgreSQL backend
is already down. Now, as soon as the pgpool-II starts-up it will go on to
process the failover on the down backend node. But the watchdog process may
still be in the startup mode and is not fully connected to the watchdog cluster
(watchdog cluster is the logical set of all the pgpool-II nodes connected through
pgpool-II watchdog). So at that time the failover process of pgpool-II will try
to go in interlocking state so that the failover and/or follow master scripts
should only gets executed by a single pgpool-II node, but as the watchdog is
still in startup state, so it will decline the request of pgpool-II failover
process to acquire the command lock that ensures the
"failover"/"failback"/"follow master" command only gets to execute
on single pgpool-II node.
So upon the request of interlocking being declined by watchdog (note that the
decline to process an interlocking request by a watchdog is different from
failed to acquire the lock) the failover process will go on and execute the
respective failover command. And at the same time another pgpool-II node,
started at the same instance in time will do the very same steps.
Eventually we will end up with multiple pgpool-II nodes calling the failover
commands and that will lead to an undesired behavior.

So this commit make the change that when the watchdog is enabled, pgpool-II
pause itself while starting up and waits until the watchdog process gets into a
stable state (MASTER or STANDBY). And once after the watchdog is in stable state,
pgpool-II main process resumes its normal startup routine.

The commit also contains few minor code cleanups



Modified Files
src/include/watchdog/watchdog.h |    2 --
src/main/pgpool_main.c          |   66 +++++++++++++++++++++--------------
src/watchdog/watchdog.c         |   73 ++++++++++++++++++++++++++++-----------
3 files changed, 94 insertions(+), 47 deletions(-)

More information about the pgpool-committers mailing list