From 14e8803f101a54d99600683543b0f893a2e3f529 Mon Sep 17 00:00:00 2001 From: Andres Freund Date: Tue, 13 Jan 2015 12:58:43 +0100 Subject: Add barriers to the latch code. Since their introduction latches have required barriers in SetLatch and ResetLatch - but when they were introduced there wasn't any barrier abstraction. Instead latches were documented to rely on the callsites to provide barrier semantics. Now that the barrier support looks halfway complete, add the necessary barriers to both latch implementations. Also remove a now superflous lock acquisition from syncrep.c and a superflous (and insufficient) barrier from freelist.c. There might be other cases that can now be simplified, but those are the only ones I've seen on a quick scan. We might want to backpatch this at some later point, but right now the barrier infrastructure in the backbranches isn't totally on par with master. Discussion: 20150112154026.GB2092@awork2.anarazel.de --- src/backend/replication/syncrep.c | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'src/backend/replication') diff --git a/src/backend/replication/syncrep.c b/src/backend/replication/syncrep.c index c99c270a7ca..b2b3a81f54c 100644 --- a/src/backend/replication/syncrep.c +++ b/src/backend/replication/syncrep.c @@ -172,20 +172,10 @@ SyncRepWaitForLSN(XLogRecPtr XactCommitLSN) * walsender changes the state to SYNC_REP_WAIT_COMPLETE, it will * never update it again, so we can't be seeing a stale value in that * case. - * - * Note: on machines with weak memory ordering, the acquisition of the - * lock is essential to avoid race conditions: we cannot be sure the - * sender's state update has reached main memory until we acquire the - * lock. We could get rid of this dance if SetLatch/ResetLatch - * contained memory barriers. */ syncRepState = MyProc->syncRepState; if (syncRepState == SYNC_REP_WAITING) - { - LWLockAcquire(SyncRepLock, LW_SHARED); syncRepState = MyProc->syncRepState; - LWLockRelease(SyncRepLock); - } if (syncRepState == SYNC_REP_WAIT_COMPLETE) break; -- cgit v1.2.3