Re: Latches and barriers - Mailing list pgsql-hackers

From Robert Haas
Subject Re: Latches and barriers
Date
Msg-id CA+TgmoYVcdCsPKW3hoE8bpeJk8+Gx2vFHuRQCdWLYqj7nCQmPA@mail.gmail.com
Whole thread Raw
In response to Re: Latches and barriers  (Andres Freund <andres@2ndquadrant.com>)
Responses Re: Latches and barriers
List pgsql-hackers
On Mon, Jan 12, 2015 at 11:27 AM, Andres Freund <andres@2ndquadrant.com> wrote:
> On 2015-01-12 11:03:42 -0500, Tom Lane wrote:
>> Andres Freund <andres@2ndquadrant.com> writes:
>> > While it might not be required for existing latch uses (I'm *not* sure
>> > that's true)
>
> I think at least syncrep.c might not be correct. In SyncRepWakeQueue()
> it sets PGPROC->syncRepState without the necessary barriers (via locks),
> although it does use them in SyncRepWaitForLSN().
>
> It is, perhaps surprisingly to many, not sufficient to take a spinlock,
> change the flag, release it and then set the latch - the release alone
> doesn't guarantee a sufficient barrier unless looking at the flag is
> also protected by the spinlock.

I thought we decided that a spinlock acquire or release should be a
full barrier.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: Latches and barriers
Next
From: Tom Lane
Date:
Subject: Re: Latches and barriers