Thomas Munro <thomas.mu...@gmail.com> writes: > On Sun, Aug 7, 2022 at 10:42 AM Tom Lane <t...@sss.pgh.pa.us> wrote: >> * There is a race condition for recently-forked children: they might not >> * have executed setsid() yet. So we signal the child directly as well as >> * the group. We assume such a child will handle the signal before trying >> * to spawn any grandchild processes. We also assume that signaling the >> * child twice will not cause any problems.
> Oof. Fixed. Hmm ... it seems like these other callers have the same race condition. StatementTimeoutHandler and LockTimeoutHandler account for that correctly by issuing two kill()s, so how is it OK for pg_signal_backend and TerminateOtherDBBackends not to? It would likely be a good idea for all these places to mention that they're doing that to avoid a race condition, and cross-reference signal_child for details. Or maybe we should promote signal_child into a more widely used function? regards, tom lane