Fix segfault when ALWAYS_PRIMARY is set but DISALLOW_TO_FAILOVER.
authorTatsuo Ishii <ishii@sraoss.co.jp>
Tue, 15 Dec 2020 10:38:04 +0000 (19:38 +0900)
committerTatsuo Ishii <ishii@sraoss.co.jp>
Tue, 15 Dec 2020 10:54:10 +0000 (19:54 +0900)
commitddfc65b16387e95e2eedf285070d55c58e27663c
treeb5c250fe87b7134f504c47d46c0ff727ed9991b8
parent3435ea78dc56c05e2c3549e7f66bb1b4c8afde51
Fix segfault when ALWAYS_PRIMARY is set but DISALLOW_TO_FAILOVER.

If a primary node (for example node 0) has ALWAYS_PRIMARY but does
have DISALLOW_TO_FAILOVER, segfault happens in following step:

1) node 0 stops

2) failover happens. all children restart. The primary node is still 0
because ALWAYS_PRIMARY is set.

2) node 0 starts and it becomes online by using pcp_attach_node.

3) failback process is executed but child process do not restart.

4) child process accesses node 0 because Req_info->primary_node_id is
0 but connection to node 0 does not exist and this causes segfault.

To fix this, do additional check to make sure that failback node is
not former primary node. If it is, do full restart of child process.

Per bug 672.
src/main/pgpool_main.c