Re: POSIX shared memory redux

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: POSIX shared memory redux
Дата
Msg-id 11177.1302564306@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: POSIX shared memory redux  (Robert Haas <robertmhaas@gmail.com>)
Ответы Re: POSIX shared memory redux  ("A.M." <agentm@themactionfaction.com>)
Список pgsql-hackers
Robert Haas <robertmhaas@gmail.com> writes:
> On Sun, Apr 10, 2011 at 5:03 PM, A.M. <agentm@themactionfaction.com> wrote:
>> To ensure that no two postmasters can startup in the same data directory, I use fcntl range locking on the data
directorylock file, which also works properly on (properly configured) NFS volumes. Whenever a postmaster or postmaster
childstarts, it acquires a read (non-exclusive) lock on the data directory's lock file. When a new postmaster starts,
itqueries if anything would block a write (exclusive) lock on the lock file which returns a lock-holding PID in the
casewhen other postgresql processes are running.
 

> This seems a lot leakier than what we do now (imagine, for example,
> shared storage) and I'm not sure what the advantage is.

BTW, the above-described solution flat out doesn't work anyway, because
it has a race condition.  Postmaster children have to reacquire the lock
after forking, because fcntl locks aren't inherited during fork().  And
that means you can't tell whether there's a just-started backend that
hasn't yet acquired the lock.  It's really critical for our purposes
that SysV shmem segments are inherited at fork() and so there's no
window where a just-forked backend isn't visible to somebody checking
the state of the shmem segment.
        regards, tom lane


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: POSIX shared memory redux
Следующее
От: "A.M."
Дата:
Сообщение: Re: POSIX shared memory redux