Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 6da07cd

Browse files
committed
If a corrupt WAL record is received by streaming replication, disconnect
and retry. If the record is genuinely corrupt in the master database, there's little hope of recovering, but it's better than simply retrying to apply the corrupt WAL record in a tight loop without even trying to retransmit it, which is what we used to do.
1 parent 38736e2 commit 6da07cd

File tree

1 file changed

+17
-1
lines changed
  • src/backend/access/transam

1 file changed

+17
-1
lines changed

src/backend/access/transam/xlog.c

Lines changed: 17 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.423 2010/06/12 09:14:52 petere Exp $
10+
* $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.424 2010/06/14 06:04:21 heikki Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -9270,6 +9270,22 @@ XLogPageRead(XLogRecPtr *RecPtr, int emode, bool fetching_ckpt,
92709270
{
92719271
if (WalRcvInProgress())
92729272
{
9273+
/*
9274+
* If we find an invalid record in the WAL streamed from
9275+
* master, something is seriously wrong. There's little
9276+
* chance that the problem will just go away, but PANIC
9277+
* is not good for availability either, especially in
9278+
* hot standby mode. Disconnect, and retry from
9279+
* archive/pg_xlog again. The WAL in the archive should
9280+
* be identical to what was streamed, so it's unlikely
9281+
* that it helps, but one can hope...
9282+
*/
9283+
if (failedSources & XLOG_FROM_STREAM)
9284+
{
9285+
ShutdownWalRcv();
9286+
continue;
9287+
}
9288+
92739289
/*
92749290
* While walreceiver is active, wait for new WAL to arrive
92759291
* from primary.

0 commit comments

Comments
 (0)