]> granicus.if.org Git - postgresql/commitdiff
Minor but necessary improvements to WAL keepalives
authorSimon Riggs <simon@2ndQuadrant.com>
Fri, 13 Jan 2012 12:59:08 +0000 (12:59 +0000)
committerSimon Riggs <simon@2ndQuadrant.com>
Fri, 13 Jan 2012 12:59:08 +0000 (12:59 +0000)
Fujii Masao

src/backend/replication/walreceiver.c
src/backend/replication/walsender.c

index ee595714e77934e62cc339c85638d0430b66c529..ee8ba5ec21cdba5510a6bca6b7f7fdfbaa00a4ab 100644 (file)
@@ -750,7 +750,8 @@ ProcessWalSndrMessage(XLogRecPtr walEnd, TimestampTz sendTime)
        walrcv->lastMsgReceiptTime = lastMsgReceiptTime;
        SpinLockRelease(&walrcv->mutex);
 
-       elog(DEBUG2, "sendtime %s receipttime %s replication apply delay %d transfer latency %d",
+       if (log_min_mesages <= DEBUG2)
+               elog(DEBUG2, "sendtime %s receipttime %s replication apply delay %d ms transfer latency %d ms",
                                        timestamptz_to_str(sendTime),
                                        timestamptz_to_str(lastMsgReceiptTime),
                                        GetReplicationApplyDelay(),
index 3598e56f9d24c1aa11f45369811e6ed4c5fdc073..3611713434a439bfb7d3d3481d561274498944f5 100644 (file)
@@ -834,7 +834,12 @@ WalSndLoop(void)
                        if (pq_is_send_pending())
                                wakeEvents |= WL_SOCKET_WRITEABLE;
                        else
+                       {
                                WalSndKeepalive(output_message);
+                               /* Try to flush pending output to the client */
+                               if (pq_flush_if_writable() != 0)
+                                       break;
+                       }
 
                        /* Determine time until replication timeout */
                        if (replication_timeout > 0)