Fix race condition when changing synchronous_standby_names
authorSimon Riggs <simon@2ndQuadrant.com>
Fri, 29 Dec 2017 14:30:33 +0000 (14:30 +0000)
committerSimon Riggs <simon@2ndQuadrant.com>
Fri, 29 Dec 2017 14:30:33 +0000 (14:30 +0000)
A momentary window exists when synchronous_standby_names
changes that allows commands issued after the change to
continue to act as async until the change becomes visible.
Remove the race by using more appropriate test in syncrep.c

Author: Asim Rama Praveen and Ashwin Agrawal
Reported-by: Xin Zhang, Ashwin Agrawal, and Asim Rama Praveen
Reviewed-by: Michael Paquier, Masahiko Sawada
src/backend/replication/syncrep.c

index 8677235411cf52a6786a00d219c381e36409488f..962772ef8f617f9d7470f5ba1946c528d05221de 100644 (file)
@@ -156,11 +156,9 @@ SyncRepWaitForLSN(XLogRecPtr lsn, bool commit)
        mode = Min(SyncRepWaitMode, SYNC_REP_WAIT_FLUSH);
 
    /*
-    * Fast exit if user has not requested sync replication, or there are no
-    * sync replication standby names defined. Note that those standbys don't
-    * need to be connected.
+    * Fast exit if user has not requested sync replication.
     */
-   if (!SyncRepRequested() || !SyncStandbysDefined())
+   if (!SyncRepRequested())
        return;
 
    Assert(SHMQueueIsDetached(&(MyProc->syncRepLinks)));