Skip to content

Commit 83cb7da

Browse files
committed
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.
1 parent 1bb2558 commit 83cb7da

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

src/backend/access/transam/xlog.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.362 2010/01/27 15:27:50 heikki Exp $
10+
* $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.363 2010/01/27 16:41:09 heikki Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -3574,6 +3574,12 @@ ReadRecord(XLogRecPtr *RecPtr, int emode_arg, bool fetching_ckpt)
35743574
NextLogPage(tmpRecPtr);
35753575
/* We will account for page header size below */
35763576
}
3577+
3578+
if (tmpRecPtr.xrecoff >= XLogFileSize)
3579+
{
3580+
(tmpRecPtr.xlogid)++;
3581+
tmpRecPtr.xrecoff = 0;
3582+
}
35773583
}
35783584
else
35793585
{

src/backend/replication/walsender.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
*
3131
*
3232
* IDENTIFICATION
33-
* $PostgreSQL: pgsql/src/backend/replication/walsender.c,v 1.3 2010/01/21 08:19:57 heikki Exp $
33+
* $PostgreSQL: pgsql/src/backend/replication/walsender.c,v 1.4 2010/01/27 16:41:09 heikki Exp $
3434
*
3535
*-------------------------------------------------------------------------
3636
*/
@@ -610,8 +610,8 @@ XLogSend(StringInfo outMsg)
610610
return true;
611611

612612
/*
613-
* We gather multiple records together by issuing just one read() of
614-
* a suitable size, and send them as one CopyData message. Repeat
613+
* We gather multiple records together by issuing just one XLogRead()
614+
* of a suitable size, and send them as one CopyData message. Repeat
615615
* until we've sent everything we can.
616616
*/
617617
while (XLByteLT(sentPtr, SendRqstPtr))
@@ -628,11 +628,21 @@ XLogSend(StringInfo outMsg)
628628
* The rounding is not only for performance reasons. Walreceiver
629629
* relies on the fact that we never split a WAL record across two
630630
* messages. Since a long WAL record is split at page boundary into
631-
* continuation records, page boundary is alwayssafe cut-off point.
631+
* continuation records, page boundary is always a safe cut-off point.
632632
* We also assume that SendRqstPtr never points in the middle of a
633633
* WAL record.
634634
*/
635635
startptr = sentPtr;
636+
if (startptr.xrecoff >= XLogFileSize)
637+
{
638+
/*
639+
* crossing a logid boundary, skip the non-existent last log
640+
* segment in previous logical log file.
641+
*/
642+
startptr.xlogid += 1;
643+
startptr.xrecoff = 0;
644+
}
645+
636646
endptr = startptr;
637647
XLByteAdvance(endptr, MAX_SEND_SIZE);
638648
/* round down to page boundary. */

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy