Re: Clarify or fix SIGINT handling in data checksums launcher

From: Srinath Reddy Sadipiralla <srinath2133(at)gmail(dot)com>
To: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Clarify or fix SIGINT handling in data checksums launcher
Date: 2026-07-12 18:18:44
Message-ID: CAFC+b6pVRwPBSpFfzi8+i8zjsGP3XQmrvn8QOgDMo1mWQuFzMg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Fujii-san,

On Sat, Jul 11, 2026 at 11:14 PM Fujii Masao <masao(dot)fujii(at)gmail(dot)com> wrote:

> In datachecksum_state.c, launcher_cancel_handler() currently says:
>
> * Internal routine for reacting to SIGINT and flagging the worker to
> abort.
> * The worker won't be interrupted immediately but will check for
> abort flag
> * between each block in a relation.
> */
>
> This reads to me as if canceling the launcher is expected to cause
> the currently running worker to abort. However, the flag set by
> launcher_cancel_handler() is process-local to the launcher.
> Since the worker has its own process-local flag, it will never
> observe the launcher's flag.
>
> As a result, if the launcher receives SIGINT, the worker is not canceled.
> Moreover, the launcher waits for the worker to exit before it can
> terminate itself. If the worker runs for a long time, for example,
> while processing a large database or waiting for a long-running session
> holding temporary tables, the launcher's cancellation can be delayed
> for a long time as well.

+1

>
> Is this intentional?
>
I think so; it shouldn't be.

>
> If not, I'd like to propose the attached 0001 patch. It updates the
> launcher
> to cancel the current worker by calling TerminateBackgroundWorker()
> when it receives SIGINT. It also adds a data-checksums-specific helper
> for waiting for worker startup or shutdown, to handle the cases where
> SIGINT arrives while the launcher is waiting for a worker to start or exit.
>

I have looked into the 0001 patch; it's LGTM \o/

--
Thanks :)
Srinath Reddy Sadipiralla
EDB: https://www.enterprisedb.com/

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Mario González Troncoso 2026-07-12 18:48:00 Re: [PATCH] Add support for INSERT ... SET syntax
Previous Message Alexander Korotkov 2026-07-12 17:17:20 Re: SQL/JSON json_table plan clause