diff --git a/src/backend/replication/syncrep.c b/src/backend/replication/syncrep.c index 5fd47689dd2..2744170f91b 100644 --- a/src/backend/replication/syncrep.c +++ b/src/backend/replication/syncrep.c @@ -295,6 +295,7 @@ SyncRepWaitForLSN(XLogRecPtr lsn, bool commit) * holding SyncRepLock, because any walsenders will ignore us anyway when * we're not on the queue. */ + pg_read_barrier(); Assert(SHMQueueIsDetached(&(MyProc->syncRepLinks))); MyProc->syncRepState = SYNC_REP_NOT_WAITING; MyProc->waitLSN = 0; @@ -1002,15 +1003,17 @@ SyncRepWakeQueue(bool all, int mode) offsetof(PGPROC, syncRepLinks)); /* - * Set state to complete; see SyncRepWaitForLSN() for discussion of - * the various states. + * Remove thisproc from queue. */ - thisproc->syncRepState = SYNC_REP_WAIT_COMPLETE; + SHMQueueDelete(&(thisproc->syncRepLinks)); + + pg_write_barrier(); /* - * Remove thisproc from queue. + * Set state to complete; see SyncRepWaitForLSN() for discussion of + * the various states. */ - SHMQueueDelete(&(thisproc->syncRepLinks)); + thisproc->syncRepState = SYNC_REP_WAIT_COMPLETE; /* * Wake only when we have set state and removed from queue.