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

Commit 9d92582

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 dfdb2f3 commit 9d92582

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/backend/access/transam/xlogrecovery.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1948,6 +1948,10 @@ xlogrecovery_redo(XLogReaderState *record, TimeLineID replayTLI)
19481948
LSN_FORMAT_ARGS(xlrec.overwritten_lsn),
19491949
LSN_FORMAT_ARGS(record->overwrittenRecPtr));
19501950

1951+
/* We have safely skipped the aborted record */
1952+
abortedRecPtr = InvalidXLogRecPtr;
1953+
missingContrecPtr = InvalidXLogRecPtr;
1954+
19511955
ereport(LOG,
19521956
(errmsg("successfully skipped missing contrecord at %X/%X, overwritten at %s",
19531957
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
@@ -13,7 +13,7 @@
1313
# Test: Create a physical replica that's missing the last WAL file,
1414
# then restart the primary to create a divergent WAL file and observe
1515
# that the replica replays the "overwrite contrecord" from that new
16-
# file.
16+
# file and the standby promotes successfully.
1717

1818
my $node = PostgreSQL::Test::Cluster->new('primary');
1919
$node->init(allows_streaming => 1);
@@ -100,6 +100,9 @@ END
100100
qr[successfully skipped missing contrecord at],
101101
"found log line in standby");
102102

103+
# Verify promotion is successful
104+
$node_standby->promote;
105+
103106
$node->stop;
104107
$node_standby->stop;
105108

0 commit comments

Comments
 (0)