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

From Amit Kapila
Subject 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
Msg-id CAA4eK1K+c3Scr4WPcnt6=UQX6ZttJkHOe5+UQ3mMtjAnq2xGdQ@mail.gmail.com
Whole thread Raw
In response to 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”  (Haribabu Kommi <kommi.haribabu@gmail.com>)
Responses 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”
List pgsql-hackers
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.

>
> >> 5. Now try to start the services, the second service fails with the
> >> error message.
> >> 6. Error details can be found out in Event log viewer.
> >>
> >
> > If I follow above steps and do as I mentioned for step-4, I am not able to
> > reproduce the issue on Windows-7 m/c using code of HEAD.
>
> I am not able to start a service with HEAD code in the same machine, where
> as it is working for 9.5. I will look into it later and update it.
>

Okay.  But it is confusing for me because you told earlier that you are able to reproduce problem in 9.5.

> >> Yes, it is working as same user services. The main problem is, PostgreSQL
> >> as a service for two different users in the same system is not working
> >> because
> >> of same random getting generated for two services.
> >>
> >
> > I am not sure why you think same random number is problem, as mentioned
> > above, even if the dsm name is same due to same random number, the code has
> > logic to process it appropriately (regenerate the name of dsm).  Having said
> > that, I don't mean to say that we shouldn't have logic to generate unique
> > name and I think we might want to add data dir path to name generation as we
> > do for main shared memory, however it is better to first completely
> > understand the underneath issue.
>
> 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. 

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

pgsql-hackers by date:

Previous
From: Etsuro Fujita
Date:
Subject: Re: Odd system-column handling in postgres_fdw join pushdown patch
Next
From: Haribabu Kommi
Date:
Subject: 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”