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

Commit 73f0a13

Browse files
committed
Pass correct count to WALRead().
Previously, some callers requested XLOG_BLCKSZ bytes unconditionally. While this did not cause a problem, because the extra bytes are ignored, it's confusing and makes it harder to add safety checks. Additionally, the comment about zero padding was incorrect. With this commit, all callers request the number of bytes they actually need. Author: Bharath Rupireddy Reviewed-by: Kyotaro Horiguchi Discussion: https://postgr.es/m/CALj2ACWBRFac2TingD3PE3w2EBHXUHY3=AEEZPJmqhpEOBGExg@mail.gmail.com
1 parent 9ecbf54 commit 73f0a13

File tree

3 files changed

+3
-13
lines changed

3 files changed

+3
-13
lines changed

src/backend/access/transam/xlogutils.c

+1-6
Original file line numberDiff line numberDiff line change
@@ -1007,12 +1007,7 @@ read_local_xlog_page_guts(XLogReaderState *state, XLogRecPtr targetPagePtr,
10071007
count = read_upto - targetPagePtr;
10081008
}
10091009

1010-
/*
1011-
* Even though we just determined how much of the page can be validly read
1012-
* as 'count', read the whole page anyway. It's guaranteed to be
1013-
* zero-padded up to the page boundary if it's incomplete.
1014-
*/
1015-
if (!WALRead(state, cur_page, targetPagePtr, XLOG_BLCKSZ, tli,
1010+
if (!WALRead(state, cur_page, targetPagePtr, count, tli,
10161011
&errinfo))
10171012
WALReadRaiseError(&errinfo);
10181013

src/backend/postmaster/walsummarizer.c

+1-6
Original file line numberDiff line numberDiff line change
@@ -1318,12 +1318,7 @@ summarizer_read_local_xlog_page(XLogReaderState *state,
13181318
}
13191319
}
13201320

1321-
/*
1322-
* Even though we just determined how much of the page can be validly read
1323-
* as 'count', read the whole page anyway. It's guaranteed to be
1324-
* zero-padded up to the page boundary if it's incomplete.
1325-
*/
1326-
if (!WALRead(state, cur_page, targetPagePtr, XLOG_BLCKSZ,
1321+
if (!WALRead(state, cur_page, targetPagePtr, count,
13271322
private_data->tli, &errinfo))
13281323
WALReadRaiseError(&errinfo);
13291324

src/backend/replication/walsender.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1099,7 +1099,7 @@ logical_read_xlog_page(XLogReaderState *state, XLogRecPtr targetPagePtr, int req
10991099
if (!WALRead(state,
11001100
cur_page,
11011101
targetPagePtr,
1102-
XLOG_BLCKSZ,
1102+
count,
11031103
currTLI, /* Pass the current TLI because only
11041104
* WalSndSegmentOpen controls whether new TLI
11051105
* is needed. */

0 commit comments

Comments
 (0)