Re: semaphore usage "port based"? - Mailing list pgsql-hackers

From Tom Lane
Subject Re: semaphore usage "port based"?
Date
Msg-id 25422.1144016604@sss.pgh.pa.us
Whole thread Raw
In response to semaphore usage "port based"?  ("Marc G. Fournier" <scrappy@postgresql.org>)
Responses Re: semaphore usage "port based"?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
"Marc G. Fournier" <scrappy@postgresql.org> writes:
> Or, more simply, I think ... is there somewhere in the Semaphore code that 
> is using the port # as a 'seed'?

We use the port number as a basis for selecting the semaphore key (see
semget(2)).  There is code in there to pick a different key value if the
one we first selected appears to be in use; that has to work correctly
if you're going to run multi postmasters on the same port number.  It
sounds like FBSD 6 has done something that broke the key-in-use check.

Look at IpcSemaphoreCreate and InternalIpcSemaphoreCreate in
src/backend/port/sysv_sema.c.  It may be worth stepping through them
with gdb to see what the semget calls are returning.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: pg_class catalog question...
Next
From: Tom Lane
Date:
Subject: Re: semaphore usage "port based"?