mirror of
https://github.com/postgres/postgres.git
synced 2025-08-28 18:48:04 +03:00
Efficient transaction-controlled synchronous replication.
If a standby is broadcasting reply messages and we have named one or more standbys in synchronous_standby_names then allow users who set synchronous_replication to wait for commit, which then provides strict data integrity guarantees. Design avoids sending and receiving transaction state information so minimises bookkeeping overheads. We synchronize with the highest priority standby that is connected and ready to synchronize. Other standbys can be defined to takeover in case of standby failure. This version has very strict behaviour; more relaxed options may be added at a later date. Simon Riggs and Fujii Masao, with reviews by Yeb Havinga, Jaime Casanova, Heikki Linnakangas and Robert Haas, plus the assistance of many other design reviewers.
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
#include "access/xlog.h"
|
||||
#include "nodes/nodes.h"
|
||||
#include "storage/latch.h"
|
||||
#include "replication/syncrep.h"
|
||||
#include "storage/spin.h"
|
||||
|
||||
|
||||
@@ -52,11 +53,32 @@ typedef struct WalSnd
|
||||
* to do.
|
||||
*/
|
||||
Latch latch;
|
||||
|
||||
/*
|
||||
* The priority order of the standby managed by this WALSender, as
|
||||
* listed in synchronous_standby_names, or 0 if not-listed.
|
||||
* Protected by SyncRepLock.
|
||||
*/
|
||||
int sync_standby_priority;
|
||||
} WalSnd;
|
||||
|
||||
extern WalSnd *MyWalSnd;
|
||||
|
||||
/* There is one WalSndCtl struct for the whole database cluster */
|
||||
typedef struct
|
||||
{
|
||||
/*
|
||||
* Synchronous replication queue. Protected by SyncRepLock.
|
||||
*/
|
||||
SHM_QUEUE SyncRepQueue;
|
||||
|
||||
/*
|
||||
* Current location of the head of the queue. All waiters should have
|
||||
* a waitLSN that follows this value, or they are currently being woken
|
||||
* to remove themselves from the queue. Protected by SyncRepLock.
|
||||
*/
|
||||
XLogRecPtr lsn;
|
||||
|
||||
WalSnd walsnds[1]; /* VARIABLE LENGTH ARRAY */
|
||||
} WalSndCtlData;
|
||||
|
||||
|
Reference in New Issue
Block a user