[pgpool-committers: 8530] pgpool: Fix pgpool child process to obtain process information.

Tatsuo Ishii ishii at sraoss.co.jp
Sat Apr 9 15:58:18 JST 2022

Fix pgpool child process to obtain process information.

ProcesInfo was obtained by using pool_get_process_info(). But this API
is not suitable for child process because:

- does inefficient linear search over all ProcessInfo slots (there are
  num_init_children slots).

- due to race condition the search key pid might not be set or removed
  in the slot. I think it is possible that by the time when child
  process starts execution, the pid is not yet set in the slot in the
  shared memory. Also when child process is killed by parent process,
  it may set pid to 0 before the child process receive kill signal.

So use pool_get_my_process_info() instead of pool_get_process_info().
which just returns the slot by using global variable my_proc_id as a
key and let child process use it.  my_proc_id was set by the parent
process when the child process was spawn.

The call to pool_get_process_info() in child.c was added in v4.3. So
back patch to V4_3_STABLE.



Modified Files
src/protocol/child.c | 23 +++++++++--------------
1 file changed, 9 insertions(+), 14 deletions(-)

More information about the pgpool-committers mailing list