Re: Shared locking in slru.c - Mailing list pgsql-hackers

From Kenneth Marshall
Subject Re: Shared locking in slru.c
Date
Msg-id 20051130210634.GA27311@it.is.rice.edu
Whole thread Raw
In response to Shared locking in slru.c  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On Wed, Nov 30, 2005 at 03:23:55PM -0500, Tom Lane wrote:
> Kenneth Marshall <ktm@is.rice.edu> writes:
> > ... In pseudo-code, the operations to
> > read the control information are:
> 
> > WriteControl:
> > 1. Set latch.
> > 2. Update control information
> > 3. Increment latch version number.
> > 4. Unset latch.
> 
> > ReadControl:
> > 1. Read latch version number.
> > 2. Read control information.
> > 3. Check latch. If locked go to step 1.
> > 4. Read latch version number. If the value is different from the
> >    value read in step 1, go to step 1.
> 
> Hm, I don't see how that's safe in the presence of concurrent would-be
> writers?  (Or is that what you meant by "queuing up lock requests"?)
> 
>             regards, tom lane

The latch is definitely safe for readers and writers concurrently
accessing the information. It does not provide the ordered waiting
for a lock that the LWLock will. It is also so light-weight that
for the types of reads and updates to the shared areas that it may
outperform the existing LWLock even during contention.

Ken


pgsql-hackers by date:

Previous
From: "Dave Page"
Date:
Subject: Re: [pgsql-www] Upcoming PG re-releases
Next
From: "Kevin Grittner"
Date:
Subject: Re: [ADMIN] ERROR: could not read block