mirror of
https://github.com/postgres/postgres.git
synced 2025-08-28 18:48:04 +03:00
Replace max_standby_delay with two parameters, max_standby_archive_delay and
max_standby_streaming_delay, and revise the implementation to avoid assuming that timestamps found in WAL records can meaningfully be compared to clock time on the standby server. Instead, the delay limits are compared to the elapsed time since we last obtained a new WAL segment from archive or since we were last "caught up" to WAL data arriving via streaming replication. This avoids problems with clock skew between primary and standby, as well as other corner cases that the original coding would misbehave in, such as the primary server having significant idle time between transactions. Per my complaint some time ago and considerable ensuing discussion. Do some desultory editing on the hot standby documentation, too.
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
*
|
||||
* Portions Copyright (c) 2010-2010, PostgreSQL Global Development Group
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/include/replication/walreceiver.h,v 1.9 2010/06/03 22:17:32 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/include/replication/walreceiver.h,v 1.10 2010/07/03 20:43:58 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -41,25 +41,35 @@ typedef enum
|
||||
typedef struct
|
||||
{
|
||||
/*
|
||||
* connection string; is used for walreceiver to connect with the primary.
|
||||
*/
|
||||
char conninfo[MAXCONNINFO];
|
||||
|
||||
/*
|
||||
* PID of currently active walreceiver process, and the current state.
|
||||
* PID of currently active walreceiver process, its current state and
|
||||
* start time (actually, the time at which it was requested to be started).
|
||||
*/
|
||||
pid_t pid;
|
||||
WalRcvState walRcvState;
|
||||
pg_time_t startTime;
|
||||
|
||||
/*
|
||||
* receivedUpto-1 is the last byte position that has been already
|
||||
* received. When startup process starts the walreceiver, it sets this to
|
||||
* the point where it wants the streaming to begin. After that,
|
||||
* walreceiver updates this whenever it flushes the received WAL.
|
||||
* receivedUpto-1 is the last byte position that has already been
|
||||
* received. When startup process starts the walreceiver, it sets
|
||||
* receivedUpto to the point where it wants the streaming to begin.
|
||||
* After that, walreceiver updates this whenever it flushes the received
|
||||
* WAL to disk.
|
||||
*/
|
||||
XLogRecPtr receivedUpto;
|
||||
|
||||
/*
|
||||
* latestChunkStart is the starting byte position of the current "batch"
|
||||
* of received WAL. It's actually the same as the previous value of
|
||||
* receivedUpto before the last flush to disk. Startup process can use
|
||||
* this to detect whether it's keeping up or not.
|
||||
*/
|
||||
XLogRecPtr latestChunkStart;
|
||||
|
||||
/*
|
||||
* connection string; is used for walreceiver to connect with the primary.
|
||||
*/
|
||||
char conninfo[MAXCONNINFO];
|
||||
|
||||
slock_t mutex; /* locks shared variables shown above */
|
||||
} WalRcvData;
|
||||
|
||||
@@ -83,6 +93,6 @@ extern void ShutdownWalRcv(void);
|
||||
extern bool WalRcvInProgress(void);
|
||||
extern XLogRecPtr WaitNextXLogAvailable(XLogRecPtr recptr, bool *finished);
|
||||
extern void RequestXLogStreaming(XLogRecPtr recptr, const char *conninfo);
|
||||
extern XLogRecPtr GetWalRcvWriteRecPtr(void);
|
||||
extern XLogRecPtr GetWalRcvWriteRecPtr(XLogRecPtr *latestChunkStart);
|
||||
|
||||
#endif /* _WALRECEIVER_H */
|
||||
|
Reference in New Issue
Block a user