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” - Mailing list pgsql-hackers

On Tue, Mar 22, 2016 at 9:13 AM, Haribabu Kommi <kommi.haribabu@gmail.com> wrote:
>
> On Tue, Mar 22, 2016 at 2:19 PM, Amit Kapila <amit.kapila16@gmail.com> wrote:
> > On Mon, Mar 21, 2016 at 6:16 PM, Haribabu Kommi <kommi.haribabu@gmail.com>
> > wrote:
> >>
> >> On Mon, Mar 14, 2016 at 4:51 PM, Amit Kapila <amit.kapila16@gmail.com>
> >> wrote:
> >> >> Operating system - windows 7
> >> >> Binary - PostgreSQL 9.5 (This doesn't matter, 9.4+ can produce the
> >> >> problem)
> >> >>
> >> >> 1. Create two standard users in the system (test_user1 and test_user2)
> >> >> 2. Create two databases belongs each user listed above.
> >> >> 3. Now using pg_ctl register the services for the two users.
> >> >> 4. Provide logon permissions to these users to run the services by
> >> >> changing
> >> >> service properties.
> >> >
> >> > Did you mean to say that you changed Log on as: Local System Account in
> >> > service properties or something else?
> >>
> >> No. Not as local service. The user should be the new standard user
> >> that is created
> >> in the system.
> >>
> >
> > So what do you exactly mean by "Provide logon permissions to these users",
> > can you describe in detail what exactly you have done to give those
> > permissions.  If I try to do with a new user, it gives me error "could not
> > open service manager"  at start of service.
>
> 1. Start the cmd with administrator user and add the new postgresql service
> with a standard user that is created.
> 2. Start the services window with the user having administrator privileges and
> go to the corresponding added service.
> 3. Right click on the service provides an properties option.
> 4. In the properties, there is an logon tab. Click it
> 5. Provide the password for the new user that is used for creating the service.
> 6. This adds the user to log on permissions.
>

I am also able to reproduce the issue with these steps.
 
> >>
> >> Yes, same random number generation is not the problem. In windows apart
> >> from EEXIST error, EACCES also needs to be validated and returned for
> >> new random number generation, instead of throwing an error.
> >>
> >
> > Doing the same handling for EACCES doesn't seem to be sane because if EACCES
> > came for reason other than duplicate dsm name, then we want to report the
> > error instead of trying to regenerate the name.  I think here fix should be
> > to append data_dir path as we do for main shared memory.
>
> Yes, EACCES may be possible other than duplicate dsm name.
>

So as far as I can see there are two ways to resolve this issue, one is to retry generation of dsm name if CreateFileMapping returns EACCES and second is to append data_dir name to dsm name as the same is done for main shared memory, that will avoid the error to occur.  First approach has minor flaw that if CreateFileMapping returns EACCES due to reason other then duplicate dsm name which I am not sure is possible to identify, then we should report error instead try to regenerate the name

Robert and or others, can you share your opinion on what is the best way to proceed for this issue.

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

pgsql-hackers by date:

Previous
From: Craig Ringer
Date:
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”
Next
From: Dilip Kumar
Date:
Subject: Re: Move PinBuffer and UnpinBuffer to atomics