On Wed, Oct 8, 2014 at 6:54 PM, Heikki Linnakangas
<hlinnakan...@vmware.com> wrote:
> 1. Where do the FF files come from? In 9.2, FF-segments are not supposed to
> created, ever.
>
> I think we should add a check in walreceiver, to throw an error if the
> master sends an invalid WAL pointer, pointing to an FF segment.
Attached is a patch for that. This would be needed for PG < 9.3 if applied.
Regards,
-- 
Michael
diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c
index 753316e..4f4d019 100644
--- a/src/backend/replication/walreceiver.c
+++ b/src/backend/replication/walreceiver.c
@@ -789,6 +789,24 @@ ProcessWalSndrMessage(XLogRecPtr walEnd, TimestampTz sendTime)
 	walrcv->lastMsgReceiptTime = lastMsgReceiptTime;
 	SpinLockRelease(&walrcv->mutex);
 
+	/*
+	 * Check that the WAL position received from sender is valid and does
+	 * refer to a segment file whose name finishes by FF.
+	 */
+	if ((walEnd.xlogid & 0xff) == 0xff)
+	{
+		char		xlogfilename[MAXFNAMELEN];
+		uint32		xlogseg;
+		uint32		xlogid;
+
+		XLByteToPrevSeg(walEnd, xlogid, xlogseg);
+		XLogFileName(xlogfilename, ThisTimeLineID, xlogid, xlogseg);
+		ereport(ERROR,
+				(errcode(ERRCODE_PROTOCOL_VIOLATION),
+				 errmsg_internal("invalid WAL position %X/%X referring to segment %s",
+								 walEnd.xlogid, walEnd.xrecoff, xlogfilename)));
+	}
+
 	if (log_min_messages <= DEBUG2)
 	{
 		char	   *sendtime;
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to