diff options
Diffstat (limited to 'src/include/replication')
| -rw-r--r-- | src/include/replication/syncrep.h | 20 | ||||
| -rw-r--r-- | src/include/replication/walsender_private.h | 16 |
2 files changed, 26 insertions, 10 deletions
diff --git a/src/include/replication/syncrep.h b/src/include/replication/syncrep.h index c5f0e91aada..9d286b66c65 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,7 +92,7 @@ extern void SyncRepInitConfig(void); extern void SyncRepReleaseWaiters(void); /* called by wal sender and user backend */ -extern List *SyncRepGetSyncStandbys(bool *am_sync); +extern int SyncRepGetCandidateStandbys(SyncRepStandbyData **standbys); /* called by checkpointer */ extern void SyncRepUpdateSyncStandbysDefined(void); diff --git a/src/include/replication/walsender_private.h b/src/include/replication/walsender_private.h index 366828f0a47..734acec2a41 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,6 +59,12 @@ typedef struct WalSnd TimeOffset flushLag; TimeOffset applyLag; + /* + * The priority order of the standby managed by this WALSender, as listed + * in synchronous_standby_names, or 0 if not-listed. + */ + int sync_standby_priority; + /* Protects shared variables shown above. */ slock_t mutex; @@ -70,13 +75,6 @@ typedef struct WalSnd 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; - - /* * Timestamp of the last message received from standby. */ TimestampTz replyTime; |
