diff options
author | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2011-02-10 21:00:29 +0200 |
---|---|---|
committer | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2011-02-10 21:04:02 +0200 |
commit | b186523fd97ce02ffbb7e21d5385a047deeef4f6 (patch) | |
tree | 00e70beaaa8529b291f85b214ee87fc686083cea /src/include/replication | |
parent | 4c468b37a281941afd3bf61c782b20def8c17047 (diff) | |
download | postgresql-b186523fd97ce02ffbb7e21d5385a047deeef4f6.tar.gz |
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.
Diffstat (limited to 'src/include/replication')
-rw-r--r-- | src/include/replication/walprotocol.h | 21 | ||||
-rw-r--r-- | src/include/replication/walreceiver.h | 1 | ||||
-rw-r--r-- | src/include/replication/walsender.h | 12 |
3 files changed, 33 insertions, 1 deletions
diff --git a/src/include/replication/walprotocol.h b/src/include/replication/walprotocol.h index 199385120a..32c49620c1 100644 --- a/src/include/replication/walprotocol.h +++ b/src/include/replication/walprotocol.h @@ -40,6 +40,27 @@ typedef struct } 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. * * We don't have a good idea of what a good value would be; there's some diff --git a/src/include/replication/walreceiver.h b/src/include/replication/walreceiver.h index 24ad43839f..aa5bfb7aea 100644 --- a/src/include/replication/walreceiver.h +++ b/src/include/replication/walreceiver.h @@ -17,6 +17,7 @@ #include "pgtime.h" extern bool am_walreceiver; +extern int wal_receiver_status_interval; /* * MAXCONNINFO: maximum size of a connection string. diff --git a/src/include/replication/walsender.h b/src/include/replication/walsender.h index 9a196ab1c8..5843307c9d 100644 --- a/src/include/replication/walsender.h +++ b/src/include/replication/walsender.h @@ -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 |