Add configuration options to disable prevlink checks (#11138)

This allows for improved decoding of otherwise broken WAL.

## Problem

Currently, if (or when) a WAL record has a wrong prevptr, that breaks
decoding. With this, we don't have to break on that if we decide it's OK
to proceed after that.

## Summary of changes

Use a Neon GUC to allow the system to enable the NEON-specific
skip_lsn_checks option in XLogReader.
This commit is contained in:
Matthias van de Meent
2025-03-10 18:02:30 +01:00
committed by GitHub
parent 8c553297cb
commit bc052fd0fc
3 changed files with 14 additions and 0 deletions

View File

@@ -457,6 +457,15 @@ _PG_init(void)
PGC_SIGHUP,
0,
NULL, NULL, NULL);
DefineCustomBoolVariable(
"neon.disable_wal_prevlink_checks",
"Disable validation of prev link in WAL records",
NULL,
&disable_wal_prev_lsn_checks,
false,
PGC_SIGHUP,
0,
NULL, NULL, NULL);
DefineCustomBoolVariable(
"neon.allow_replica_misconfig",

View File

@@ -23,6 +23,7 @@ extern char *wal_acceptors_list;
extern int wal_acceptor_reconnect_timeout;
extern int wal_acceptor_connection_timeout;
extern int readahead_getpage_pull_timeout_ms;
extern bool disable_wal_prev_lsn_checks;
#if PG_MAJORVERSION_NUM >= 17
extern uint32 WAIT_EVENT_NEON_LFC_MAINTENANCE;

View File

@@ -32,6 +32,8 @@ extern XLogRecPtr WalSndWaitForWal(XLogRecPtr loc);
extern bool GetDonorShmem(XLogRecPtr *donor_lsn);
extern XLogRecPtr GetXLogReplayRecPtr(TimeLineID *replayTLI);
bool disable_wal_prev_lsn_checks = false;
static XLogRecPtr
NeonWALReadWaitForWAL(XLogRecPtr loc)
{
@@ -82,6 +84,8 @@ NeonWALPageRead(
if (flushptr < targetPagePtr + reqLen)
return -1;
xlogreader->skip_lsn_checks = disable_wal_prev_lsn_checks;
/* Read at most XLOG_BLCKSZ bytes */
if (targetPagePtr + XLOG_BLCKSZ <= flushptr)
count = XLOG_BLCKSZ;