diff options
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/replication/syncrep.h | 21 | ||||
| -rw-r--r-- | src/include/replication/walsender_private.h | 8 |
2 files changed, 24 insertions, 5 deletions
diff --git a/src/include/replication/syncrep.h b/src/include/replication/syncrep.h index bc43b4e1090..5b022ccb36d 100644 --- a/src/include/replication/syncrep.h +++ b/src/include/replication/syncrep.h @@ -37,6 +37,24 @@ #define SYNC_REP_QUORUM 1 /* + * SyncRepGetCandidateStandbys returns an array of these structs, + * one per candidate synchronous walsender. + */ +typedef struct SyncRepStandbyData +{ + /* Copies of relevant fields from WalSnd shared-memory struct */ + pid_t pid; + XLogRecPtr write; + XLogRecPtr flush; + XLogRecPtr apply; + int sync_standby_priority; + /* Index of this walsender in the WalSnd shared-memory array */ + int walsnd_index; + /* This flag indicates whether this struct is about our own process */ + bool is_me; +} SyncRepStandbyData; + +/* * Struct for the configuration of synchronous replication. * * Note: this must be a flat representation that can be held in a single @@ -74,6 +92,9 @@ extern void SyncRepInitConfig(void); extern void SyncRepReleaseWaiters(void); /* called by wal sender and user backend */ +extern int SyncRepGetCandidateStandbys(SyncRepStandbyData **standbys); + +/* obsolete, do not use in new code */ extern List *SyncRepGetSyncStandbys(bool *am_sync); /* called by checkpointer */ diff --git a/src/include/replication/walsender_private.h b/src/include/replication/walsender_private.h index 4b904779361..07b01ca17eb 100644 --- a/src/include/replication/walsender_private.h +++ b/src/include/replication/walsender_private.h @@ -31,8 +31,7 @@ typedef enum WalSndState /* * Each walsender has a WalSnd struct in shared memory. * - * This struct is protected by 'mutex', with two exceptions: one is - * sync_standby_priority as noted below. The other exception is that some + * This struct is protected by its 'mutex' spinlock field, except that some * members are only written by the walsender process itself, and thus that * process is free to read those members without holding spinlock. pid and * needreload always require the spinlock to be held for all accesses. @@ -60,7 +59,7 @@ typedef struct WalSnd TimeOffset flushLag; TimeOffset applyLag; - /* Protects shared variables shown above. */ + /* Protects shared variables shown above (and sync_standby_priority). */ slock_t mutex; /* @@ -71,8 +70,7 @@ typedef struct WalSnd /* * The priority order of the standby managed by this WALSender, as listed - * in synchronous_standby_names, or 0 if not-listed. Protected by - * SyncRepLock. + * in synchronous_standby_names, or 0 if not-listed. */ int sync_standby_priority; } WalSnd; |
