aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>2010-01-27 16:41:09 +0000
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>2010-01-27 16:41:09 +0000
commit83cb7da7dcd11f658a7fc4aff198923bf76ff8f5 (patch)
tree7b1bcffc28dc0b977c950ee6a0d021c38ceb7c04 /src
parent1bb2558046cc8b8cb0c8f5563e8d32b3b120c9ec (diff)
downloadpostgresql-83cb7da7dcd11f658a7fc4aff198923bf76ff8f5.tar.gz
postgresql-83cb7da7dcd11f658a7fc4aff198923bf76ff8f5.zip
Fix bug in wasender's xlogid boundary handling, reported by Erik Rijkers.
LogwrtRqst.Write can be set to non-existent FF log segment, we mustn't try to send that in XLogSend(). Also fix similar bug in ReadRecord(), which I just introduced in the ReadRecord() refactoring patch.
Diffstat (limited to 'src')
-rw-r--r--src/backend/access/transam/xlog.c8
-rw-r--r--src/backend/replication/walsender.c18
2 files changed, 21 insertions, 5 deletions
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index 60d40d4505b..e8e79b380ee 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.362 2010/01/27 15:27:50 heikki Exp $
+ * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.363 2010/01/27 16:41:09 heikki Exp $
*
*-------------------------------------------------------------------------
*/
@@ -3574,6 +3574,12 @@ ReadRecord(XLogRecPtr *RecPtr, int emode_arg, bool fetching_ckpt)
NextLogPage(tmpRecPtr);
/* We will account for page header size below */
}
+
+ if (tmpRecPtr.xrecoff >= XLogFileSize)
+ {
+ (tmpRecPtr.xlogid)++;
+ tmpRecPtr.xrecoff = 0;
+ }
}
else
{
diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c
index a10dc3d8b2c..0eb074ffe73 100644
--- a/src/backend/replication/walsender.c
+++ b/src/backend/replication/walsender.c
@@ -30,7 +30,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/replication/walsender.c,v 1.3 2010/01/21 08:19:57 heikki Exp $
+ * $PostgreSQL: pgsql/src/backend/replication/walsender.c,v 1.4 2010/01/27 16:41:09 heikki Exp $
*
*-------------------------------------------------------------------------
*/
@@ -610,8 +610,8 @@ XLogSend(StringInfo outMsg)
return true;
/*
- * We gather multiple records together by issuing just one read() of
- * a suitable size, and send them as one CopyData message. Repeat
+ * We gather multiple records together by issuing just one XLogRead()
+ * of a suitable size, and send them as one CopyData message. Repeat
* until we've sent everything we can.
*/
while (XLByteLT(sentPtr, SendRqstPtr))
@@ -628,11 +628,21 @@ XLogSend(StringInfo outMsg)
* The rounding is not only for performance reasons. Walreceiver
* relies on the fact that we never split a WAL record across two
* messages. Since a long WAL record is split at page boundary into
- * continuation records, page boundary is alwayssafe cut-off point.
+ * continuation records, page boundary is always a safe cut-off point.
* We also assume that SendRqstPtr never points in the middle of a
* WAL record.
*/
startptr = sentPtr;
+ if (startptr.xrecoff >= XLogFileSize)
+ {
+ /*
+ * crossing a logid boundary, skip the non-existent last log
+ * segment in previous logical log file.
+ */
+ startptr.xlogid += 1;
+ startptr.xrecoff = 0;
+ }
+
endptr = startptr;
XLByteAdvance(endptr, MAX_SEND_SIZE);
/* round down to page boundary. */