[pgpool-committers: 4507] pgpool: Fix pgpool child process segfault when ALWAYS_MASTER is on.

Tatsuo Ishii ishii at postgresql.org
Mon Jan 29 13:12:24 JST 2018


Fix pgpool child process segfault when ALWAYS_MASTER is on.

If following conditions are all met pgpool child segfaults:

1) Streaming replication mode.

2) fail_over_on_backend_error is off.

3) ALWAYS_MASTER flags is set to the master (writer) node.

4) pgpool_status file indicates that the node mentioned in #3 is in
   down status.

What happens here is,

1) find_primary_node() returns node id 0 without checking the status
   of node 0 since ALWAYS_MASTER is set. It's remembered as the
   primary node id. The node id is stored in Req_info->primary_node_id.

2) The connection to backend 0 is not created since pgpool_status says
   it's in down status.

3) upon starting of session, select_load_balancing_node () is called
   and it tries to determine the database name from client's start up
   packet.

4) Since MASTER_CONNECTION macro points to the PRIMARY_NODE,
   MASTER_CONNECTION(ses->backend) is NULL and it results in a segfault.

The fix I propose is, to change PRIMARY_NODE_ID macro so that it
returns REAL_MASTER_NODE_ID (that is the youngest node id which is
alive) if the node id in Req_info->primary_node_id is in down status.
So we have the "true" primary node id in Req_info->primary_node_id,
and "fake" primary node id returned by PRIMARY_NODE_ID macro.

See [pgpool-hackers: 2687] and [pgpool-general: 5881] Pgpool-3.7.1
segmentation fault for more details.

Since ALWAYS_MASTER flag was introduced in 3.7, back pached to 3.7
only.

Per bug report from Philip Champon.

Branch
------
master

Details
-------
https://git.postgresql.org/gitweb?p=pgpool2.git;a=commitdiff;h=9022ff842fb5dbbe06e2f2f4cf38fadf47b592da

Modified Files
--------------
src/include/pool.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)



More information about the pgpool-committers mailing list