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:53:23 +0000 (19:53 +0900)
commit59d7431620006f6c34fd2e8b66d2840d05d89b9d
tree3713861b8ecbab90b0a1e7dba2d502f05240abd3
parentebd33af5b6fcee2363c723ecf953d352eb6a0106
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