mirror of
https://github.com/postgres/postgres.git
synced 2025-09-02 04:21:28 +03:00
Revert recovery prefetching feature.
This set of commits has some bugs with known fixes, but at this late stage in the release cycle it seems best to revert and resubmit next time, along with some new automated test coverage for this whole area. Commits reverted:dc88460c
: Doc: Review for "Optionally prefetch referenced data in recovery."1d257577
: Optionally prefetch referenced data in recovery.f003d9f8
: Add circular WAL decoding buffer.323cbe7c
: Remove read_page callback from XLogReader. Remove the new GUC group WAL_RECOVERY recently added bya55a9847
, as the corresponding section of config.sgml is now reverted. Discussion: https://postgr.es/m/CAOuzzgrn7iKnFRsB4MHp3UisEQAGgZMbk_ViTN4HV4-Ksq8zCg%40mail.gmail.com
This commit is contained in:
@@ -580,7 +580,10 @@ StartReplication(StartReplicationCmd *cmd)
|
||||
|
||||
/* create xlogreader for physical replication */
|
||||
xlogreader =
|
||||
XLogReaderAllocate(wal_segment_size, NULL, wal_segment_close);
|
||||
XLogReaderAllocate(wal_segment_size, NULL,
|
||||
XL_ROUTINE(.segment_open = WalSndSegmentOpen,
|
||||
.segment_close = wal_segment_close),
|
||||
NULL);
|
||||
|
||||
if (!xlogreader)
|
||||
ereport(ERROR,
|
||||
@@ -803,12 +806,10 @@ StartReplication(StartReplicationCmd *cmd)
|
||||
* which has to do a plain sleep/busy loop, because the walsender's latch gets
|
||||
* set every time WAL is flushed.
|
||||
*/
|
||||
static bool
|
||||
logical_read_xlog_page(XLogReaderState *state)
|
||||
static int
|
||||
logical_read_xlog_page(XLogReaderState *state, XLogRecPtr targetPagePtr, int reqLen,
|
||||
XLogRecPtr targetRecPtr, char *cur_page)
|
||||
{
|
||||
XLogRecPtr targetPagePtr = state->readPagePtr;
|
||||
int reqLen = state->reqLen;
|
||||
char *cur_page = state->readBuf;
|
||||
XLogRecPtr flushptr;
|
||||
int count;
|
||||
WALReadError errinfo;
|
||||
@@ -825,10 +826,7 @@ logical_read_xlog_page(XLogReaderState *state)
|
||||
|
||||
/* fail if not (implies we are going to shut down) */
|
||||
if (flushptr < targetPagePtr + reqLen)
|
||||
{
|
||||
XLogReaderSetInputData(state, -1);
|
||||
return false;
|
||||
}
|
||||
return -1;
|
||||
|
||||
if (targetPagePtr + XLOG_BLCKSZ <= flushptr)
|
||||
count = XLOG_BLCKSZ; /* more than one block available */
|
||||
@@ -836,7 +834,7 @@ logical_read_xlog_page(XLogReaderState *state)
|
||||
count = flushptr - targetPagePtr; /* part of the page available */
|
||||
|
||||
/* now actually read the data, we know it's there */
|
||||
if (!WALRead(state, WalSndSegmentOpen, wal_segment_close,
|
||||
if (!WALRead(state,
|
||||
cur_page,
|
||||
targetPagePtr,
|
||||
XLOG_BLCKSZ,
|
||||
@@ -856,8 +854,7 @@ logical_read_xlog_page(XLogReaderState *state)
|
||||
XLByteToSeg(targetPagePtr, segno, state->segcxt.ws_segsize);
|
||||
CheckXLogRemoved(segno, state->seg.ws_tli);
|
||||
|
||||
XLogReaderSetInputData(state, count);
|
||||
return true;
|
||||
return count;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1010,8 +1007,9 @@ CreateReplicationSlot(CreateReplicationSlotCmd *cmd)
|
||||
|
||||
ctx = CreateInitDecodingContext(cmd->plugin, NIL, need_full_snapshot,
|
||||
InvalidXLogRecPtr,
|
||||
logical_read_xlog_page,
|
||||
wal_segment_close,
|
||||
XL_ROUTINE(.page_read = logical_read_xlog_page,
|
||||
.segment_open = WalSndSegmentOpen,
|
||||
.segment_close = wal_segment_close),
|
||||
WalSndPrepareWrite, WalSndWriteData,
|
||||
WalSndUpdateProgress);
|
||||
|
||||
@@ -1169,8 +1167,9 @@ StartLogicalReplication(StartReplicationCmd *cmd)
|
||||
*/
|
||||
logical_decoding_ctx =
|
||||
CreateDecodingContext(cmd->startpoint, cmd->options, false,
|
||||
logical_read_xlog_page,
|
||||
wal_segment_close,
|
||||
XL_ROUTINE(.page_read = logical_read_xlog_page,
|
||||
.segment_open = WalSndSegmentOpen,
|
||||
.segment_close = wal_segment_close),
|
||||
WalSndPrepareWrite, WalSndWriteData,
|
||||
WalSndUpdateProgress);
|
||||
xlogreader = logical_decoding_ctx->reader;
|
||||
@@ -2763,7 +2762,7 @@ XLogSendPhysical(void)
|
||||
enlargeStringInfo(&output_message, nbytes);
|
||||
|
||||
retry:
|
||||
if (!WALRead(xlogreader, WalSndSegmentOpen, wal_segment_close,
|
||||
if (!WALRead(xlogreader,
|
||||
&output_message.data[output_message.len],
|
||||
startptr,
|
||||
nbytes,
|
||||
@@ -2861,12 +2860,7 @@ XLogSendLogical(void)
|
||||
*/
|
||||
WalSndCaughtUp = false;
|
||||
|
||||
while (XLogReadRecord(logical_decoding_ctx->reader, &record, &errm) ==
|
||||
XLREAD_NEED_DATA)
|
||||
{
|
||||
if (!logical_decoding_ctx->page_read(logical_decoding_ctx->reader))
|
||||
break;
|
||||
}
|
||||
record = XLogReadRecord(logical_decoding_ctx->reader, &errm);
|
||||
|
||||
/* xlog record was invalid */
|
||||
if (errm != NULL)
|
||||
|
Reference in New Issue
Block a user