Re: [HACKERS] Re: [HACKERS] Re: [HACKERS] Re: [HACKERS] Windows service is not starting so there’s message in log: FATAL: "could not create shared memory segment “Global/PostgreSQL.851401618”: Permission denied”

From: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
To: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Haribabu Kommi <kommi(dot)haribabu(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Dmitry Vasilyev <d(dot)vasilyev(at)postgrespro(dot)ru>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [HACKERS] Re: [HACKERS] Re: [HACKERS] Re: [HACKERS] Windows service is not starting so there’s message in log: FATAL: "could not create shared memory segment “Global/PostgreSQL.851401618”: Permission denied”
Date: 2016-05-25 07:11:18
Message-ID: CAA4eK1JyNdMeF-dgrpHozDecpDfsRZUtpCi+1AbtuEkfG3YooQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, May 17, 2016 at 2:31 AM, Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
wrote:
>
> On Tue, May 17, 2016 at 4:16 AM, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
wrote:
> > On Mon, May 16, 2016 at 9:45 AM, Michael Paquier <
michael(dot)paquier(at)gmail(dot)com>
> > wrote:
> >>
> >> On Sun, May 15, 2016 at 3:34 PM, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
> >> wrote:
> >> > Sounds sensible, but if we want to that route, shall we have some
> >> > mechanism
> >> > such that if retrying it for 10 times (10 is somewhat arbitrary, but
we
> >> > retry 10 times in PGSharedMemoryCreate, so may be there is some
> >> > consistency)
> >> > doesn't give us unique name and we are getting EACCES error, then
just
> >> > throw
> >> > the error instead of more retries. This is to ensure that if the
API is
> >> > returning EACCES due to reason other than duplicate handle, then we
> >> > won't
> >> > retry indefinitely.
> >>
> >> The logic in win32_shmem.c relies on the fact that a segment will be
> >> recycled, and the retry is here because it may take time at OS level.
> >> On top of that it relies on the segment names being unique across
> >> systems. So it seems to me that it is not worth the complication to
> >> duplicate that logic in the dsm implementation.
> >
> > If we don't do retry for fixed number of times, then how will we handle
the
> > case if EACCES is due to the reason other than duplicate handle?
>
> EACCES is a bit too low-level... I had in mind to check GetLastError
> with only ERROR_ACCESS_DENIED, and retry only in this case, which is
> the case where one postmaster is trying to access the segment of
> another.
>

Okay, attached patch just does that and I have verified that it allows to
start multiple services in windows. In off list discussion with Robert, he
suggested not to complicate the patch by retrying for fixed number of times
as there is no proof that ERROR_ACCESS_DENIED can occur due to any other
reason in this code path. This patch is based on Kyotaro san's patch
posted upthread with just minor changes in comments and indentation.

With Regards,
Amit Kapila.
EnterpriseDB: http://www.enterprisedb.com

Attachment Content-Type Size
dsm_win_segment_access_v1.patch application/octet-stream 1.7 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Simon Riggs 2016-05-25 07:38:58 Re: Does people favor to have matrix data type?
Previous Message Andreas Seltenreich 2016-05-25 06:24:08 Re: [sqlsmith] PANIC: failed to add BRIN tuple