summaryrefslogtreecommitdiff
path: root/src/backend/replication
diff options
context:
space:
mode:
authorSimon Riggs2012-08-08 22:58:49 +0000
committerHeikki Linnakangas2013-02-15 17:28:06 +0000
commitc2f79ba2691a4863db53003f25538f8806ebd2db (patch)
treebd803ee71caa4dd0dd9773765496ae8b1b3422ad /src/backend/replication
parentc9cc7e05c6d82a9781883a016c70d95aa4923122 (diff)
Force archive_status of .done for xlogs created by dearchival/replication.
This is a forward-patch of commit 6f4b8a4f4f7a2d683ff79ab59d3693714b965e3d, applied to 9.2 back in August. The plan was to do something else in master, but it looks like it's not going to happen, so let's just apply the 9.2 solution to master as well. Fujii Masao
Diffstat (limited to 'src/backend/replication')
-rw-r--r--src/backend/replication/walreceiver.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c
index 37d5e0821e..911a66ba88 100644
--- a/src/backend/replication/walreceiver.c
+++ b/src/backend/replication/walreceiver.c
@@ -83,7 +83,7 @@ walrcv_disconnect_type walrcv_disconnect = NULL;
/*
* These variables are used similarly to openLogFile/SegNo/Off,
* but for walreceiver to write the XLOG. recvFileTLI is the TimeLineID
- * corresponding the filename of recvFile, used for error messages.
+ * corresponding the filename of recvFile.
*/
static int recvFile = -1;
static TimeLineID recvFileTLI = 0;
@@ -528,12 +528,21 @@ WalReceiverMain(void)
*/
if (recvFile >= 0)
{
+ char xlogfname[MAXFNAMELEN];
+
XLogWalRcvFlush(false);
if (close(recvFile) != 0)
ereport(PANIC,
(errcode_for_file_access(),
errmsg("could not close log segment %s: %m",
XLogFileNameP(recvFileTLI, recvSegNo))));
+
+ /*
+ * Create .done file forcibly to prevent the streamed segment from
+ * being archived later.
+ */
+ XLogFileName(xlogfname, recvFileTLI, recvSegNo);
+ XLogArchiveForceDone(xlogfname);
}
recvFile = -1;
@@ -865,6 +874,8 @@ XLogWalRcvWrite(char *buf, Size nbytes, XLogRecPtr recptr)
*/
if (recvFile >= 0)
{
+ char xlogfname[MAXFNAMELEN];
+
XLogWalRcvFlush(false);
/*
@@ -877,6 +888,13 @@ XLogWalRcvWrite(char *buf, Size nbytes, XLogRecPtr recptr)
(errcode_for_file_access(),
errmsg("could not close log segment %s: %m",
XLogFileNameP(recvFileTLI, recvSegNo))));
+
+ /*
+ * Create .done file forcibly to prevent the streamed segment from
+ * being archived later.
+ */
+ XLogFileName(xlogfname, recvFileTLI, recvSegNo);
+ XLogArchiveForceDone(xlogfname);
}
recvFile = -1;