1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-27 12:41:57 +03:00

Read WAL directly from WAL buffers.

If available, read directly from WAL buffers, avoiding the need to go
through the filesystem. Only for physical replication for now, but can
be expanded to other callers.

In preparation for replicating unflushed WAL data.

Author: Bharath Rupireddy
Discussion: https://postgr.es/m/CALj2ACXKKK%3DwbiG5_t6dGao5GoecMwRkhr7GjVBM_jg54%2BNa%3DQ%40mail.gmail.com
Reviewed-by: Andres Freund, Alvaro Herrera, Nathan Bossart, Dilip Kumar, Nitin Jadhav, Melih Mutlu, Kyotaro Horiguchi
This commit is contained in:
Jeff Davis
2024-02-12 10:36:18 -08:00
parent 09eb633e1b
commit 91f2cae7a4
4 changed files with 134 additions and 4 deletions

View File

@ -2966,6 +2966,7 @@ XLogSendPhysical(void)
Size nbytes;
XLogSegNo segno;
WALReadError errinfo;
Size rbytes;
/* If requested switch the WAL sender to the stopping state. */
if (got_STOPPING)
@ -3181,7 +3182,16 @@ XLogSendPhysical(void)
enlargeStringInfo(&output_message, nbytes);
retry:
if (!WALRead(xlogreader,
/* attempt to read WAL from WAL buffers first */
rbytes = WALReadFromBuffers(&output_message.data[output_message.len],
startptr, nbytes, xlogreader->seg.ws_tli);
output_message.len += rbytes;
startptr += rbytes;
nbytes -= rbytes;
/* now read the remaining WAL from WAL file */
if (nbytes > 0 &&
!WALRead(xlogreader,
&output_message.data[output_message.len],
startptr,
nbytes,