diff options
| author | Jeff Davis <jdavis@postgresql.org> | 2024-02-12 10:36:18 -0800 |
|---|---|---|
| committer | Jeff Davis <jdavis@postgresql.org> | 2024-02-12 11:11:22 -0800 |
| commit | 91f2cae7a4e664e9c0472b364c7db29d755ab151 (patch) | |
| tree | a39e90a07d21b18bf85a6b83e954638631b4d9b5 /src/backend/replication/walsender.c | |
| parent | 09eb633e1baa3b7cd7929f3cc77f9c46f63c20b1 (diff) | |
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
Diffstat (limited to 'src/backend/replication/walsender.c')
| -rw-r--r-- | src/backend/replication/walsender.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c index 77c8baa32a4..146826d5db9 100644 --- a/src/backend/replication/walsender.c +++ b/src/backend/replication/walsender.c @@ -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, |
