Re: Memory ordering issue in LWLockRelease, WakeupWaiters, WALInsertSlotRelease - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Memory ordering issue in LWLockRelease, WakeupWaiters, WALInsertSlotRelease
Date
Msg-id 11505.1392048688@sss.pgh.pa.us
Whole thread Raw
In response to Memory ordering issue in LWLockRelease, WakeupWaiters, WALInsertSlotRelease  (Andres Freund <andres@2ndquadrant.com>)
Responses Re: Memory ordering issue in LWLockRelease, WakeupWaiters, WALInsertSlotRelease  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: Memory ordering issue in LWLockRelease, WakeupWaiters, WALInsertSlotRelease  (Andres Freund <andres@2ndquadrant.com>)
List pgsql-hackers
Andres Freund <andres@2ndquadrant.com> writes:
> So what we need to do is to acquire a write barrier between the
> assignments to lwWaitLink and lwWaiting, i.e.
>         proc->lwWaitLink = NULL;
>         pg_write_barrier();
>         proc->lwWaiting = false;

You didn't really explain why you think that ordering is necessary?
Each proc being awoken will surely see both fields updated, and other
procs won't be examining these fields at all, since we already delinked
all these procs from the LWLock's queue.

> There is the question what to do about the branches without barriers? I
> guess a SpinLockAcquire()/Release() would do? Or do we decide it's not
> important enough to matter, since it's not an issue on x86?

Given the lack of trouble reports that could be traced to this,
I don't feel a need to worry about it in branches that don't
have any barrier support.  But in any case, I'm not convinced
there's a bug here at all.
        regards, tom lane



pgsql-hackers by date:

Previous
From: Christian Convey
Date:
Subject: Re: Breaking compile-time dependency cycles of Postgres subdirs?
Next
From: Tom Lane
Date:
Subject: Re: Memory ordering issue in LWLockRelease, WakeupWaiters, WALInsertSlotRelease