From: Tatsuo Ishii Date: Mon, 22 Jul 2024 10:32:41 +0000 (+0900) Subject: Fix another segmentation fault. X-Git-Tag: V4_4_8~12 X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=c1dd550d38c89f4e67d2a1f9ca1e1fd169cee7b9;p=pgpool2.git Fix another segmentation fault. It is reported that pgpool child segfaulted in pool_do_auth. The cause was MAIN_CONNECTION() returns NULL. It seems my_main_node_id was set to incorrect node id 0, which was actually in down status. thus there was no connection in cp->slots[0]. In this particular case a client connected to pgpool while failover occurred in another pgpool node, and it was propagated by watchdog, which changed backend_status in shared memory. new_connection() properly updates my_backend_status but it forgot to update my_main_node_id, and MAIN_CONNECTION returned incorrect backend id. Problem reported by: Emond Papegaaij Discussion: [pgpool-general: 9175] Segmentation fault https://www.pgpool.net/pipermail/pgpool-general/2024-July/001852.html Backpatch-through: V4.1. --- diff --git a/src/protocol/pool_connection_pool.c b/src/protocol/pool_connection_pool.c index 3adbc0eab..a3bfc5f11 100644 --- a/src/protocol/pool_connection_pool.c +++ b/src/protocol/pool_connection_pool.c @@ -5,7 +5,7 @@ * pgpool: a language independent connection pool server for PostgreSQL * written by Tatsuo Ishii * - * Copyright (c) 2003-2020 PgPool Global Development Group + * Copyright (c) 2003-2024 PgPool Global Development Group * * Permission to use, copy, modify, and distribute this software and * its documentation for any purpose and without fee is hereby @@ -911,6 +911,7 @@ static POOL_CONNECTION_POOL * new_connection(POOL_CONNECTION_POOL * p) /* sync local status with global status */ *(my_backend_status[i]) = status; + my_main_node_id = Req_info->main_node_id; continue; }