1
0
mirror of https://github.com/postgres/postgres.git synced 2025-08-28 18:48:04 +03:00

Send status updates back from standby server to master, indicating how far

the standby has written, flushed, and applied the WAL. At the moment, this
is for informational purposes only, the values are only shown in
pg_stat_replication system view, but in the future they will also be needed
for synchronous replication.

Extracted from Simon riggs' synchronous replication patch by Robert Haas, with
some tweaking by me.
This commit is contained in:
Heikki Linnakangas
2011-02-10 21:00:29 +02:00
parent 4c468b37a2
commit b186523fd9
15 changed files with 352 additions and 22 deletions

View File

@@ -39,6 +39,27 @@ typedef struct
TimestampTz sendTime;
} WalDataMessageHeader;
/*
* Reply message from standby (message type 'r'). This is wrapped within
* a CopyData message at the FE/BE protocol level.
*
* Note that the data length is not specified here.
*/
typedef struct
{
/*
* The xlog locations that have been written, flushed, and applied
* by standby-side. These may be invalid if the standby-side is unable
* to or chooses not to report these.
*/
XLogRecPtr write;
XLogRecPtr flush;
XLogRecPtr apply;
/* Sender's system clock at the time of transmission */
TimestampTz sendTime;
} StandbyReplyMessage;
/*
* Maximum data payload in a WAL data message. Must be >= XLOG_BLCKSZ.
*

View File

@@ -17,6 +17,7 @@
#include "pgtime.h"
extern bool am_walreceiver;
extern int wal_receiver_status_interval;
/*
* MAXCONNINFO: maximum size of a connection string.

View File

@@ -35,7 +35,17 @@ typedef struct WalSnd
WalSndState state; /* this walsender's state */
XLogRecPtr sentPtr; /* WAL has been sent up to this point */
slock_t mutex; /* locks shared variables shown above */
/*
* The xlog locations that have been written, flushed, and applied
* by standby-side. These may be invalid if the standby-side has not
* offered values yet.
*/
XLogRecPtr write;
XLogRecPtr flush;
XLogRecPtr apply;
/* Protects shared variables shown above. */
slock_t mutex;
/*
* Latch used by backends to wake up this walsender when it has work