[pgpool-committers: 9964] pgpool: Fix segfault to not use MAIN_NODE macro.

Tatsuo Ishii ishii at sraoss.co.jp
Fri Jun 21 16:21:30 JST 2024


Fix segfault to not use MAIN_NODE macro.

Some functions (close_idle_connection(), new_connection() and
pool_create_cp()) used MAIN* and VALID_BACKEND where they are not
appropriate. MAIN* and VALID_BACKEND are only useful against current
connections to backend, not for pooled connections since in pooled
connections which backend is the main node or up and running is
necessarily same as the current connections to backend.
The misuses of those macros sometimes leads to segfault.

This patch introduces new in_use_backend_id() which returns the fist
node id in use. This commit replaces some of MAIN* with the return
value from in_use_backend_id(). Also inappropriate calls to
VALID_BACKEND are replaced with CONNECTION_SLOT macro.

Problem reported by Emond Papegaaij
Discussion: https://www.pgpool.net/pipermail/pgpool-general/2024-June/009176.html
[pgpool-general: 9114] Re: Another segmentation fault
Backpatch-through: V4.1

Branch
------
V4_5_STABLE

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

Modified Files
--------------
src/include/protocol/pool_connection_pool.h |  4 ++-
src/protocol/child.c                        | 34 ++++++++------------
src/protocol/pool_connection_pool.c         | 50 ++++++++++++++++++++++-------
3 files changed, 54 insertions(+), 34 deletions(-)



More information about the pgpool-committers mailing list