Re: Convert pcp_exit_handler and wakeup_handler_parent to flag-only.

From: Koshino Taiki <koshino(at)sraoss(dot)co(dot)jp>
To: Tatsuo Ishii <ishii(at)postgresql(dot)org>
Cc: "pgpool-hackers(at)lists(dot)postgresql(dot)org" <pgpool-hackers(at)lists(dot)postgresql(dot)org>, "emond(dot)papegaaij(at)gmail(dot)com" <emond(dot)papegaaij(at)gmail(dot)com>
Subject: Re: Convert pcp_exit_handler and wakeup_handler_parent to flag-only.
Date: 2026-09-03 05:29:40
Message-ID: OS9P286MB64867C42AD248519E63D211C94B62@OS9P286MB6486.JPNP286.PROD.OUTLOOK.COM
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgpool-hackers

Sorry for the additional update.

I have attached a revised patch with the
Discussion: field filled in.
The implementation itself has not changed

Best Regards,

Taiki Koshino<koshino(at)sraoss(dot)co(dot)jp>
SRA OSS K.K.
TEL: 03-5979-2701 FAX: 03-5979-2702
URL: https://www.sraoss.co.jp/

________________________________
差出人: Koshino Taiki <koshino(at)sraoss(dot)co(dot)jp>
送信日時: 2026年9月1日 16:27
宛先: Tatsuo Ishii <ishii(at)postgresql(dot)org>
CC: pgpool-hackers(at)lists(dot)postgresql(dot)org <pgpool-hackers(at)lists(dot)postgresql(dot)org>; emond(dot)papegaaij(at)gmail(dot)com <emond(dot)papegaaij(at)gmail(dot)com>
件名: Re: Convert pcp_exit_handler and wakeup_handler_parent to flag-only.

> I skimmed related source file (wd_lifecheck.c) and found following
> loop in lifecheck_exit_handler(after patch renamed to
> process_lifecheck_exit_request):
>
> do
> {
> wpid = wait(NULL);
> } while (wpid > 0 || (wpid == -1 && errno == EINTR));
>
> I think this loop could wait forever if one of child process won't
> respond to the kill signal. Is it possible for you to confirm this?

The wait() loop may block indefinitely in general, but it does not seem
to be the cause of this timeout.

The backtrace showed that the lifecheck process had not yet reached the
new process_lifecheck_exit_request() call in the watchdog loop. It was
still sleeping in the readiness loop:

#0 clock_nanosleep()
#1 nanosleep()
#2 sleep()
#3 lifecheck_main() at wd_lifecheck.c:472

Before this patch, the signal handler performed the shutdown immediately,
including exit(), so the process could terminate from inside an
initialization loop. After the handler was changed to only set a flag,
the process continued waiting because the flag was checked only in the
later watchdog loop.

A similar issue could potentially occur in the earlier loop that gets
the list of watchdog nodes. For completeness, I added
process_lifecheck_exit_request() checks to both initialization loops.

I tested the updated 028 patch together with patches 026, 027 and 029,
and confirmed that all regression tests pass.

Regards,

Taiki Koshino<koshino(at)sraoss(dot)co(dot)jp>
SRA OSS K.K.
TEL: 03-5979-2701 FAX: 03-5979-2702
URL: https://www.sraoss.co.jp/

________________________________
差出人: Tatsuo Ishii <ishii(at)postgresql(dot)org>
送信日時: 2026年8月27日 15:59
宛先: Koshino Taiki <koshino(at)sraoss(dot)co(dot)jp>
CC: pgpool-hackers(at)lists(dot)postgresql(dot)org <pgpool-hackers(at)lists(dot)postgresql(dot)org>; emond(dot)papegaaij(at)gmail(dot)com <emond(dot)papegaaij(at)gmail(dot)com>
件名: Re: Convert pcp_exit_handler and wakeup_handler_parent to flag-only.

> However, 028-lifecheck-exit-handler-flag-only is failing due to a timeout
> in the 004 watchdog test case, so 028 has not been posted to this ML yet.

I skimmed related source file (wd_lifecheck.c) and found following
loop in lifecheck_exit_handler(after patch renamed to
process_lifecheck_exit_request):

do
{
wpid = wait(NULL);
} while (wpid > 0 || (wpid == -1 && errno == EINTR));

I think this loop could wait forever if one of child process won't
respond to the kill signal. Is it possible for you to confirm this?

Regards,
--
Tatsuo Ishii
SRA OSS K.K.
English: http://www.sraoss.co.jp/index_en/
Japanese:http://www.sraoss.co.jp

Attachment Content-Type Size
v3-0001-Convert-lifecheck_exit_handler-to-flag-only.patch application/octet-stream 3.8 KB
v2-0001-Convert-pcp_exit_handler-and-wakeup_handler_paren.patch application/octet-stream 4.7 KB

In response to

Browse pgpool-hackers by date

  From Date Subject
Next Message Koshino Taiki 2026-09-03 05:37:03 Re: Convert pcp_worker die handler to flag-only.
Previous Message Koshino Taiki 2026-09-03 04:56:45 Re: Convert close_idle_connection (SIGUSR1) to flag-only handler with main-loop processing.