| From: | Andres Freund <andres(at)anarazel(dot)de> | 
|---|---|
| To: | Bryan Green <dbryan(dot)green(at)gmail(dot)com> | 
| Cc: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> | 
| Subject: | Re: [PATCH] Fix orphaned backend processes on Windows using Job Objects | 
| Date: | 2025-11-03 15:19:18 | 
| Message-ID: | f2ly24rn4vt62u44a36qzbysiwzl2uzkrmiw36bompi2tmfosb@2ccvujasj4up | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-hackers | 
Hi,
On 2025-11-03 09:12:03 -0600, Bryan Green wrote:
> We just need to call CreateJobObject() in PostmasterMain(), configure
> with JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE, and assign the postmaster.
> Children inherit membership automatically. When the job handle closes on
> postmaster exit, the kernel terminates all children atomically. This is
> kernel-enforced with no polling and no race conditions.
What happens if a postmaster child exits irregularly? Is postmaster terminated
as well?
> The patch has been tested on Windows 10/11 with both MSVC and MinGW
> builds. Nested jobs fail gracefully as expected. Clean shutdown is
> unaffected. Crash tests with taskkill /F, debugger abort, and access
> violations all correctly terminate children immediately with zero orphans.
> 
> This patch does not include automated tests because the core
> functionality (orphan prevention on crash) requires simulating process
> termination, which is difficult to test reliably in CI.
Why is it difficult to test in CI? We do some related tests in
013_crash_restart.pl, it doesn't seem like it ought to be hard to also add
tests for postmaster?
Greetings,
Andres Freund
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Andres Freund | 2025-11-03 15:20:57 | Re: Report bytes and transactions actually sent downtream | 
| Previous Message | vignesh C | 2025-11-03 15:16:10 | Re: Logical Replication of sequences |