Re: file-locking and postmaster.pid

From: korry <korry(at)appx(dot)com>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: file-locking and postmaster.pid
Date: 2006-05-24 22:53:11
Message-ID: 1148511191.16791.1.camel@sakai.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> > > > 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.
> >
> > I may be confused here, but I don't see the problem - byte-range locks
> > are not inherited across a fork. A backend would never hold the lock, a
> > backend would never even look for the lock.
>
> Well, you are wrong here. We _want_ every backend to hold a shared
> lock. We need to stop a postmaster from starting if there is a backend
> running that was started by a no-longer-running postmaster.

Oh... didn't know that. How is that accomplished now? There must be
some code beside the pid file check.

-- Korry

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2006-05-24 22:53:34 Re: file-locking and postmaster.pid
Previous Message Alvaro Herrera 2006-05-24 22:38:57 Re: file-locking and postmaster.pid