aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Riggs <simon@2ndQuadrant.com>2016-08-12 12:49:38 +0100
committerSimon Riggs <simon@2ndQuadrant.com>2016-08-12 12:49:38 +0100
commit4fc8e2315da3ee67538f55ce0c6aee3eee07e026 (patch)
tree916eb6de65b3ea75e5c60e3d69e0f4f222db1a99 /src
parent270c29f125f5b5d2a199fb98fdf9c289640093a3 (diff)
downloadpostgresql-4fc8e2315da3ee67538f55ce0c6aee3eee07e026.tar.gz
postgresql-4fc8e2315da3ee67538f55ce0c6aee3eee07e026.zip
Code cleanup in SyncRepWaitForLSN()
Commit 14e8803f1 removed LWLocks when accessing MyProc->syncRepState but didn't clean up the surrounding code and comments. Cleanup and backpatch to 9.5, to keep code similar. Julien Rouhaud, improved by suggestion from Michael Paquier, implemented trivially by myself.
Diffstat (limited to 'src')
-rw-r--r--src/backend/replication/syncrep.c18
1 files changed, 5 insertions, 13 deletions
diff --git a/src/backend/replication/syncrep.c b/src/backend/replication/syncrep.c
index 3fa08567e72..132212a451b 100644
--- a/src/backend/replication/syncrep.c
+++ b/src/backend/replication/syncrep.c
@@ -160,24 +160,16 @@ SyncRepWaitForLSN(XLogRecPtr XactCommitLSN)
*/
for (;;)
{
- int syncRepState;
-
/* Must reset the latch before testing state. */
ResetLatch(MyLatch);
/*
- * Try checking the state without the lock first. There's no
- * guarantee that we'll read the most up-to-date value, so if it looks
- * like we're still waiting, recheck while holding the lock. But if
- * it looks like we're done, we must really be done, because once
- * 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.
+ * Acquiring the lock is not needed, the latch ensures proper barriers.
+ * If it looks like we're done, we must really be done, because once
+ * 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.
*/
- syncRepState = MyProc->syncRepState;
- if (syncRepState == SYNC_REP_WAITING)
- syncRepState = MyProc->syncRepState;
- if (syncRepState == SYNC_REP_WAIT_COMPLETE)
+ if (MyProc->syncRepState == SYNC_REP_WAIT_COMPLETE)
break;
/*