Re: file-locking and postmaster.pid
От | Alvaro Herrera |
---|---|
Тема | Re: file-locking and postmaster.pid |
Дата | |
Msg-id | 20060524213502.GC7412@surnet.cl обсуждение исходный текст |
Ответ на | Re: file-locking and postmaster.pid (korry <korry@appx.com>) |
Ответы |
Re: file-locking and postmaster.pid
|
Список | pgsql-hackers |
korry wrote: > > I think the next question is -- how would the lock interface be used? > > We could acquire an exclusive lock on postmaster start (to make sure no > > backend is running), then reduce it to a shared lock. Every backend > > would inherit the shared lock. But the lock exchange is not guaranteed > > to be atomic so a new postmaster could start just after we acquire the > > lock and acquire the shared lock. It'd need to be complemented with > > another lock. > > You never need to reduce it to a shared lock. On postmaster startup, > try to lock the sentinel byte (one byte past the end-of-file). If you > can lock it, you know that no other postmaster has that byte locked. If > you can't lock it, another postmaster is running. It is an atomic > operation. This doesn't work if the postmaster dies but a backend continues to run, which is arguably the most important case we need to protect against. > However, Tom may be correct about NFS locking, but I guess I'm surprised > that anyone would care :-) Quite a lot of people run NFS-mounted data directories ... -- Alvaro Herrera http://www.CommandPrompt.com/ The PostgreSQL Company - Command Prompt, Inc.
В списке pgsql-hackers по дате отправления: