Fixing the issue with the watchdog process restart.
authorMuhammad Usama <m.usama@gmail.com>
Thu, 19 Jan 2017 15:58:24 +0000 (20:58 +0500)
committerMuhammad Usama <m.usama@gmail.com>
Thu, 19 Jan 2017 15:58:24 +0000 (20:58 +0500)
commitd3a619152107117dd9c1fd7dcec859e19a89b768
treef76138563581d9a7d608296b492fa757cf701221
parent170ee46ffe46b78af613a2c14cf692f52571e81a
Fixing the issue with the watchdog process restart.

When the watchdog process gets abnormally terminated because of some problem
(e.g. Segmentation fault) the new spawned watchdog process fails to start and
produces an error "bind on ... failed with reason: Address already in use".

Reason is the abnormally terminating watchdog process never gets the time to
clean-up the socket it uses for IPC and the new process gets an error because
the socket address is already occupied

Fix is, the Pgpool main process sets the flag in shared memory to mark the
watchdog process was abnormally terminated and at startup when the watchdog
process see that the flag is set, it performs the clean up of the socket file and
also performs the de-escalation (If the watchdog process was crashed when it
was master/coordinator node) if required before initializing itself.
src/include/watchdog/wd_ipc_commands.h
src/main/pgpool_main.c
src/watchdog/watchdog.c
src/watchdog/wd_commands.c