Re: file-locking and postmaster.pid - Mailing list pgsql-hackers

From korry
Subject Re: file-locking and postmaster.pid
Date
Msg-id 1148511191.16791.1.camel@sakai.localdomain
Whole thread Raw
In response to Re: file-locking and postmaster.pid  (Alvaro Herrera <alvherre@commandprompt.com>)
List pgsql-hackers
<blockquote type="CITE"><pre>
<font color="#000000">> > > You never need to reduce it to a shared lock.  On postmaster startup,</font>
<font color="#000000">> > > try to lock the sentinel byte (one byte past the end-of-file).  If you</font>
<font color="#000000">> > > can lock it, you know that no other postmaster has that byte locked.  If</font>
<font color="#000000">> > > you can't lock it, another postmaster is running. It is an atomic</font>
<font color="#000000">> > > operation. </font>
<font color="#000000">> > </font>
<font color="#000000">> > This doesn't work if the postmaster dies but a backend continues to run,</font>
<font color="#000000">> > which is arguably the most important case we need to protect against.</font>
<font color="#000000">> </font>
<font color="#000000">> I may be confused here, but I don't see the problem - byte-range locks</font>
<font color="#000000">> are not inherited across a fork.  A backend would never hold the lock, a</font>
<font color="#000000">> backend would never even look for the lock.</font>

<font color="#000000">Well, you are wrong here.  We _want_ every backend to hold a shared</font>
<font color="#000000">lock.  We need to stop a postmaster from starting if there is a backend</font>
<font color="#000000">running that was started by a no-longer-running postmaster.</font>
</pre></blockquote><pre>

</pre> Oh... didn't know that.  How is that accomplished now? There must be some code beside the pid file check.<br
/><br/>             -- Korry<br /><br /> 

pgsql-hackers by date:

Previous
From: korry
Date:
Subject: Re: file-locking and postmaster.pid
Next
From: Richard
Date:
Subject: v814 + OSX10.4.6 builds OK, but fails launch ...