[pgpool-general: 9237] Re: Sporadic health check failures due to authentication failure

Tatsuo Ishii ishii at postgresql.org
Thu Oct 24 14:52:53 JST 2024


Hi Emond,

> Hi all,
> 
> Every now and then we see sporadic failures of health checks (see config
> below) due to authentication failures. As these checks run every 5 seconds,
> and the authentication does not change at all, these should either fail all
> the time or never at all, so I suspect a race condition. I've checked the
> code, and may have found the potential issue, but not being a very good c
> programmer, I might be wrong.
> 
> In pool_get_user_credentials in pool_passwd.c (which it must reach because
> health_check_password is empty), the password file is read via passwd_fd.
> This file descriptor is rewound at line 362 (in 4.5.4). However, I wonder
> what would happen if another process uses this same descriptor at the same
> time. I suspect this might lead to one of the two processes (or maybe even
> both) to get incorrect results.

I think your analythis is correct.  Yes, if multiple process are
reading from the same file descriptor, it could lead to confusing
results. Currently pgpool main process opens the pool_passwd file,
then health check process inherit the file descriptor. This is not
good. Attached is a patch to let the health check process to reopen
the pool_passwd file so that it has it's own file descriptor.

Note that pgpool child process (responsible for user sessions) already
opens pool_passwd, therefore the file descriptor contention does not
happen.

Best reagards,
--
Tatsuo Ishii
SRA OSS K.K.
English: http://www.sraoss.co.jp/index_en/
Japanese:http://www.sraoss.co.jp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pool_passwd_fd_fix.patch
Type: text/x-patch
Size: 485 bytes
Desc: not available
URL: <http://www.pgpool.net/pipermail/pgpool-general/attachments/20241024/bd20758d/attachment.bin>


More information about the pgpool-general mailing list