Fix possible deadlock during failover with watchdog enabled
authorYugo Nagata <nagata@sraoss.co.jp>
Fri, 17 May 2013 02:56:07 +0000 (11:56 +0900)
committerYugo Nagata <nagata@sraoss.co.jp>
Fri, 17 May 2013 03:10:27 +0000 (12:10 +0900)
commit881b3467ff2f6e5d256ee1ae8299c7b0b5e51094
tree4d9b32bb3a6531d7b2e38737ad60ec7970ae0d89
parent7f35c23fb532905ec0452404fc7f3310fe2fd604
Fix possible deadlock during failover with watchdog enabled

After backend DB failure is detected, degenerate_backend_set() sends a failover
request signal within a semaphore lock. In addition, when watchdog enabled, this
function also sends packets to other pgpools to propagate the failover request.
However, if the other pgpool does the same simultaneously , a deadlock occurs,
because the failover request have to wait for the lock of each other . Responses
of the packets never return, so both pgpools are blocked.

If there are lots of client, the deadlock will occur more frequently because a
lots of simultaneous failover requests and locks will occur.

To resolve it, return the response packet before the failover request is signaled.
Once the response is returned the semaphore is unlocked soon, and deadlock can be
avoided.

This is reported in Bug track #54 by arshu arora
ttp://www.pgpool.net/mantisbt/view.php?id=54
watchdog/wd_child.c