From: MasaoFujii Date: Fri, 3 Dec 2010 02:53:06 +0000 (+0900) Subject: Introduce replication timeout for synchronous replication. X-Git-Tag: pgrex902-1.0~19 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=df5ae4b9c9d70a833b7f2542feb3e299d51f00aa;p=pg-rex%2Fsyncrep.git Introduce replication timeout for synchronous replication. --- diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c index 5513e53ff2..3b86bd77f1 100644 --- a/src/backend/replication/walsender.c +++ b/src/backend/replication/walsender.c @@ -583,15 +583,24 @@ WalSndLoop(void) */ /* - * Check for replication timeout if it's enabled and we need to - * wait for the socket to be writable to flush pending WAL in - * output buffer. + * Check for replication timeout if it's enabled and we need + * to wait until the socket has become writable to flush + * pending WAL in output buffer or until the Ack message + * from the standby has become available. */ - check_timeout = replication_timeout > 0 && pending; - if (check_timeout) + if (replication_timeout > 0 && + (pending || + (rplMode != REPLICATION_MODE_ASYNC && + XLByteLT(ackdPtr, sentPtr)))) + { sleeptime = replication_timeout; + check_timeout = true; + } else + { sleeptime = WalSndDelay; + check_timeout = false; + } /* Sleep */ res = WaitLatchOrSocket(&MyWalSnd->latch, MyProcPort->sock,