summaryrefslogtreecommitdiff
path: root/src/backend/replication/walreceiver.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/replication/walreceiver.c')
-rw-r--r--src/backend/replication/walreceiver.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c
index 0e57611da42..3f82693dcea 100644
--- a/src/backend/replication/walreceiver.c
+++ b/src/backend/replication/walreceiver.c
@@ -29,7 +29,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/replication/walreceiver.c,v 1.4 2010/02/17 04:19:39 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/replication/walreceiver.c,v 1.5 2010/02/19 10:51:04 heikki Exp $
*
*-------------------------------------------------------------------------
*/
@@ -50,6 +50,9 @@
#include "utils/ps_status.h"
#include "utils/resowner.h"
+/* Global variable to indicate if this process is a walreceiver process */
+bool am_walreceiver;
+
/* libpqreceiver hooks to these when loaded */
walrcv_connect_type walrcv_connect = NULL;
walrcv_receive_type walrcv_receive = NULL;
@@ -158,6 +161,8 @@ WalReceiverMain(void)
/* use volatile pointer to prevent code rearrangement */
volatile WalRcvData *walrcv = WalRcv;
+ am_walreceiver = true;
+
/*
* WalRcv should be set up already (if we are a backend, we inherit
* this by fork() or EXEC_BACKEND mechanism from the postmaster).
@@ -424,16 +429,18 @@ XLogWalRcvWrite(char *buf, Size nbytes, XLogRecPtr recptr)
bool use_existent;
/*
- * XLOG segment files will be re-read in recovery operation soon,
- * so we don't need to advise the OS to release any cache page.
+ * fsync() and close current file before we switch to next one.
+ * We would otherwise have to reopen this file to fsync it later
*/
if (recvFile >= 0)
{
+ XLogWalRcvFlush();
+
/*
- * fsync() before we switch to next file. We would otherwise
- * have to reopen this file to fsync it later
+ * XLOG segment files will be re-read by recovery in startup
+ * process soon, so we don't advise the OS to release cache
+ * pages associated with the file like XLogFileClose() does.
*/
- XLogWalRcvFlush();
if (close(recvFile) != 0)
ereport(PANIC,
(errcode_for_file_access(),
@@ -445,8 +452,7 @@ XLogWalRcvWrite(char *buf, Size nbytes, XLogRecPtr recptr)
/* Create/use new log file */
XLByteToSeg(recptr, recvId, recvSeg);
use_existent = true;
- recvFile = XLogFileInit(recvId, recvSeg,
- &use_existent, true);
+ recvFile = XLogFileInit(recvId, recvSeg, &use_existent, true);
recvOff = 0;
}