Re: Postgres service stops when I kill client backend on Windows

From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: Andres Freund <andres(at)anarazel(dot)de>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Ali Akbar <the(dot)apaan(at)gmail(dot)com>, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, Dmitry Vasilyev <d(dot)vasilyev(at)postgrespro(dot)ru>, Robert Haas <robertmhaas(at)gmail(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Postgres service stops when I kill client backend on Windows
Date: 2015-10-12 12:38:12
Message-ID: CAB7nPqREgeXhxPT-S8DMon0hwFG6Du2r47aBfqFc4cS2Wve8XQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Oct 12, 2015 at 7:26 PM, Magnus Hagander <magnus(at)hagander(dot)net> wrote:
>
>
> On Mon, Oct 12, 2015 at 12:25 PM, Andres Freund <andres(at)anarazel(dot)de> wrote:
>>
>> On 2015-10-12 11:25:35 +0530, Amit Kapila wrote:
>> > /*
>> > + * Close the shared memory handle as the syslogger doesn't need to
>> > + * attach to it. For EXEC_BACKEND case, the shared memory handle
>> > + * is inherited by all postmaster child processes irrespective of
>> > + * whether they need it or not.
>> > + */
>> > +#ifdef EXEC_BACKEND
>> > + if (!CloseHandle(UsedShmemSegID))
>> > + elog(LOG, "could not close handle to shared memory: error
>> > code %lu", GetLastError());
>> > +#endif
>> > +
>>
>> It feels wrong to do this in syslogger.c - I mean it's not the only
>> process that's not attached to shared memory. Sure, the others get
>> killed, but nonetheless...
>
>
> +1. It feels like we're setting our selves up for repeating this mistake at
> some later time :)

Actually, doesn't this apply as well to the archiver and the pgstat
collector? So perhaps we may want to do that in SubPostmasterMain with
PGSharedMemoryDetach. See for example the attached as an idea (patch
completely untested).
--
Michael

Attachment Content-Type Size
20151012_detach_shmem.patch application/x-patch 830 bytes

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2015-10-12 12:45:50 Re: Postgres service stops when I kill client backend on Windows
Previous Message Alexander Korotkov 2015-10-12 12:32:43 Re: WIP: Rework access method interface