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

Commit caaeb88

Browse files
committed
Fix "missing continuation record" after standby promotion
Invalidate abortedRecPtr and missingContrecPtr after a missing continuation record is successfully skipped on a standby. This fixes a PANIC caused when a recently promoted standby attempts to write an OVERWRITE_RECORD with an LSN of the previously read aborted record. Backpatch to 10 (all stable versions). Author: Sami Imseih <simseih@amazon.com> Reviewed-by: Kyotaro Horiguchi <horikyota.ntt@gmail.com> Reviewed-by: Álvaro Herrera <alvherre@alvh.no-ip.org> Discussion: https://postgr.es/m/44D259DE-7542-49C4-8A52-2AB01534DCA9@amazon.com
1 parent cd3a505 commit caaeb88

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/backend/access/transam/xlog.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10592,6 +10592,10 @@ VerifyOverwriteContrecord(xl_overwrite_contrecord *xlrec, XLogReaderState *state
1059210592
LSN_FORMAT_ARGS(xlrec->overwritten_lsn),
1059310593
LSN_FORMAT_ARGS(state->overwrittenRecPtr));
1059410594

10595+
/* We have safely skipped the aborted record */
10596+
abortedRecPtr = InvalidXLogRecPtr;
10597+
missingContrecPtr = InvalidXLogRecPtr;
10598+
1059510599
ereport(LOG,
1059610600
(errmsg("successfully skipped missing contrecord at %X/%X, overwritten at %s",
1059710601
LSN_FORMAT_ARGS(xlrec->overwritten_lsn),

src/test/recovery/t/026_overwrite_contrecord.pl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# Test: Create a physical replica that's missing the last WAL file,
1616
# then restart the primary to create a divergent WAL file and observe
1717
# that the replica replays the "overwrite contrecord" from that new
18-
# file.
18+
# file and the standby promotes successfully.
1919

2020
my $node = PostgresNode->get_new_node('primary');
2121
$node->init(allows_streaming => 1);
@@ -102,5 +102,8 @@ END
102102
qr[successfully skipped missing contrecord at],
103103
"found log line in standby");
104104

105+
# Verify promotion is successful
106+
$node_standby->promote;
107+
105108
$node->stop;
106109
$node_standby->stop;

0 commit comments

Comments
 (0)