PostgreSQL Source Code  git master
syncrep.h File Reference
#include "access/xlogdefs.h"
Include dependency graph for syncrep.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  SyncRepStandbyData
 
struct  SyncRepConfigData
 

Macros

#define SyncRepRequested()    (max_wal_senders > 0 && synchronous_commit > SYNCHRONOUS_COMMIT_LOCAL_FLUSH)
 
#define SYNC_REP_NO_WAIT   (-1)
 
#define SYNC_REP_WAIT_WRITE   0
 
#define SYNC_REP_WAIT_FLUSH   1
 
#define SYNC_REP_WAIT_APPLY   2
 
#define NUM_SYNC_REP_WAIT_MODE   3
 
#define SYNC_REP_NOT_WAITING   0
 
#define SYNC_REP_WAITING   1
 
#define SYNC_REP_WAIT_COMPLETE   2
 
#define SYNC_REP_PRIORITY   0
 
#define SYNC_REP_QUORUM   1
 

Typedefs

typedef struct SyncRepStandbyData SyncRepStandbyData
 
typedef struct SyncRepConfigData SyncRepConfigData
 

Functions

void SyncRepWaitForLSN (XLogRecPtr lsn, bool commit)
 
void SyncRepCleanupAtProcExit (void)
 
void SyncRepInitConfig (void)
 
void SyncRepReleaseWaiters (void)
 
int SyncRepGetCandidateStandbys (SyncRepStandbyData **standbys)
 
void SyncRepUpdateSyncStandbysDefined (void)
 
int syncrep_yyparse (void)
 
int syncrep_yylex (void)
 
void syncrep_yyerror (const char *str)
 
void syncrep_scanner_init (const char *str)
 
void syncrep_scanner_finish (void)
 

Variables

PGDLLIMPORT SyncRepConfigDataSyncRepConfig
 
PGDLLIMPORT SyncRepConfigDatasyncrep_parse_result
 
PGDLLIMPORT char * syncrep_parse_error_msg
 
PGDLLIMPORT char * SyncRepStandbyNames
 

Macro Definition Documentation

◆ NUM_SYNC_REP_WAIT_MODE

#define NUM_SYNC_REP_WAIT_MODE   3

Definition at line 27 of file syncrep.h.

◆ SYNC_REP_NO_WAIT

#define SYNC_REP_NO_WAIT   (-1)

Definition at line 22 of file syncrep.h.

◆ SYNC_REP_NOT_WAITING

#define SYNC_REP_NOT_WAITING   0

Definition at line 30 of file syncrep.h.

◆ SYNC_REP_PRIORITY

#define SYNC_REP_PRIORITY   0

Definition at line 35 of file syncrep.h.

◆ SYNC_REP_QUORUM

#define SYNC_REP_QUORUM   1

Definition at line 36 of file syncrep.h.

◆ SYNC_REP_WAIT_APPLY

#define SYNC_REP_WAIT_APPLY   2

Definition at line 25 of file syncrep.h.

◆ SYNC_REP_WAIT_COMPLETE

#define SYNC_REP_WAIT_COMPLETE   2

Definition at line 32 of file syncrep.h.

◆ SYNC_REP_WAIT_FLUSH

#define SYNC_REP_WAIT_FLUSH   1

Definition at line 24 of file syncrep.h.

◆ SYNC_REP_WAIT_WRITE

#define SYNC_REP_WAIT_WRITE   0

Definition at line 23 of file syncrep.h.

◆ SYNC_REP_WAITING

#define SYNC_REP_WAITING   1

Definition at line 31 of file syncrep.h.

◆ SyncRepRequested

#define SyncRepRequested ( )     (max_wal_senders > 0 && synchronous_commit > SYNCHRONOUS_COMMIT_LOCAL_FLUSH)

Definition at line 18 of file syncrep.h.

Typedef Documentation

◆ SyncRepConfigData

◆ SyncRepStandbyData

Function Documentation

◆ syncrep_scanner_finish()

void syncrep_scanner_finish ( void  )

◆ syncrep_scanner_init()

void syncrep_scanner_init ( const char *  str)

◆ syncrep_yyerror()

void syncrep_yyerror ( const char *  str)

◆ syncrep_yylex()

int syncrep_yylex ( void  )

◆ syncrep_yyparse()

int syncrep_yyparse ( void  )

◆ SyncRepCleanupAtProcExit()

void SyncRepCleanupAtProcExit ( void  )

Definition at line 384 of file syncrep.c.

385 {
386  /*
387  * First check if we are removed from the queue without the lock to not
388  * slow down backend exit.
389  */
391  {
392  LWLockAcquire(SyncRepLock, LW_EXCLUSIVE);
393 
394  /* maybe we have just been removed, so recheck */
397 
398  LWLockRelease(SyncRepLock);
399  }
400 }
static void dlist_delete_thoroughly(dlist_node *node)
Definition: ilist.h:416
static bool dlist_node_is_detached(const dlist_node *node)
Definition: ilist.h:525
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
Definition: lwlock.c:1195
void LWLockRelease(LWLock *lock)
Definition: lwlock.c:1803
@ LW_EXCLUSIVE
Definition: lwlock.h:115
PGPROC * MyProc
Definition: proc.c:66
dlist_node syncRepLinks
Definition: proc.h:245

References dlist_delete_thoroughly(), dlist_node_is_detached(), LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), MyProc, and PGPROC::syncRepLinks.

Referenced by ProcKill().

◆ SyncRepGetCandidateStandbys()

int SyncRepGetCandidateStandbys ( SyncRepStandbyData **  standbys)

Definition at line 727 of file syncrep.c.

728 {
729  int i;
730  int n;
731 
732  /* Create result array */
733  *standbys = (SyncRepStandbyData *)
735 
736  /* Quick exit if sync replication is not requested */
737  if (SyncRepConfig == NULL)
738  return 0;
739 
740  /* Collect raw data from shared memory */
741  n = 0;
742  for (i = 0; i < max_wal_senders; i++)
743  {
744  volatile WalSnd *walsnd; /* Use volatile pointer to prevent code
745  * rearrangement */
746  SyncRepStandbyData *stby;
747  WalSndState state; /* not included in SyncRepStandbyData */
748 
749  walsnd = &WalSndCtl->walsnds[i];
750  stby = *standbys + n;
751 
752  SpinLockAcquire(&walsnd->mutex);
753  stby->pid = walsnd->pid;
754  state = walsnd->state;
755  stby->write = walsnd->write;
756  stby->flush = walsnd->flush;
757  stby->apply = walsnd->apply;
759  SpinLockRelease(&walsnd->mutex);
760 
761  /* Must be active */
762  if (stby->pid == 0)
763  continue;
764 
765  /* Must be streaming or stopping */
766  if (state != WALSNDSTATE_STREAMING &&
768  continue;
769 
770  /* Must be synchronous */
771  if (stby->sync_standby_priority == 0)
772  continue;
773 
774  /* Must have a valid flush position */
775  if (XLogRecPtrIsInvalid(stby->flush))
776  continue;
777 
778  /* OK, it's a candidate */
779  stby->walsnd_index = i;
780  stby->is_me = (walsnd == MyWalSnd);
781  n++;
782  }
783 
784  /*
785  * In quorum mode, we return all the candidates. In priority mode, if we
786  * have too many candidates then return only the num_sync ones of highest
787  * priority.
788  */
790  n > SyncRepConfig->num_sync)
791  {
792  /* Sort by priority ... */
793  qsort(*standbys, n, sizeof(SyncRepStandbyData),
795  /* ... then report just the first num_sync ones */
796  n = SyncRepConfig->num_sync;
797  }
798 
799  return n;
800 }
int i
Definition: isn.c:73
void * palloc(Size size)
Definition: mcxt.c:1210
#define qsort(a, b, c, d)
Definition: port.h:445
#define SpinLockRelease(lock)
Definition: spin.h:64
#define SpinLockAcquire(lock)
Definition: spin.h:62
uint8 syncrep_method
Definition: syncrep.h:68
int sync_standby_priority
Definition: syncrep.h:49
XLogRecPtr apply
Definition: syncrep.h:48
XLogRecPtr write
Definition: syncrep.h:46
XLogRecPtr flush
Definition: syncrep.h:47
WalSnd walsnds[FLEXIBLE_ARRAY_MEMBER]
slock_t mutex
XLogRecPtr flush
WalSndState state
XLogRecPtr write
int sync_standby_priority
XLogRecPtr apply
Definition: regguts.h:318
static int standby_priority_comparator(const void *a, const void *b)
Definition: syncrep.c:806
SyncRepConfigData * SyncRepConfig
Definition: syncrep.c:98
#define SYNC_REP_PRIORITY
Definition: syncrep.h:35
WalSnd * MyWalSnd
Definition: walsender.c:113
int max_wal_senders
Definition: walsender.c:122
WalSndCtlData * WalSndCtl
Definition: walsender.c:110
WalSndState
@ WALSNDSTATE_STREAMING
@ WALSNDSTATE_STOPPING
#define XLogRecPtrIsInvalid(r)
Definition: xlogdefs.h:29

References SyncRepStandbyData::apply, WalSnd::apply, SyncRepStandbyData::flush, WalSnd::flush, i, SyncRepStandbyData::is_me, max_wal_senders, WalSnd::mutex, MyWalSnd, SyncRepConfigData::num_sync, palloc(), SyncRepStandbyData::pid, WalSnd::pid, qsort, SpinLockAcquire, SpinLockRelease, standby_priority_comparator(), WalSnd::state, SYNC_REP_PRIORITY, SyncRepStandbyData::sync_standby_priority, WalSnd::sync_standby_priority, SyncRepConfigData::syncrep_method, SyncRepConfig, SyncRepStandbyData::walsnd_index, WalSndCtl, WalSndCtlData::walsnds, WALSNDSTATE_STOPPING, WALSNDSTATE_STREAMING, SyncRepStandbyData::write, WalSnd::write, and XLogRecPtrIsInvalid.

Referenced by pg_stat_get_wal_senders(), and SyncRepGetSyncRecPtr().

◆ SyncRepInitConfig()

void SyncRepInitConfig ( void  )

Definition at line 413 of file syncrep.c.

414 {
415  int priority;
416 
417  /*
418  * Determine if we are a potential sync standby and remember the result
419  * for handling replies from standby.
420  */
421  priority = SyncRepGetStandbyPriority();
422  if (MyWalSnd->sync_standby_priority != priority)
423  {
425  MyWalSnd->sync_standby_priority = priority;
427 
428  ereport(DEBUG1,
429  (errmsg_internal("standby \"%s\" now has synchronous standby priority %u",
430  application_name, priority)));
431  }
432 }
int errmsg_internal(const char *fmt,...)
Definition: elog.c:1156
#define DEBUG1
Definition: elog.h:30
#define ereport(elevel,...)
Definition: elog.h:149
char * application_name
Definition: guc_tables.c:516
static int SyncRepGetStandbyPriority(void)
Definition: syncrep.c:833

References application_name, DEBUG1, ereport, errmsg_internal(), WalSnd::mutex, MyWalSnd, SpinLockAcquire, SpinLockRelease, WalSnd::sync_standby_priority, and SyncRepGetStandbyPriority().

Referenced by ProcessPendingWrites(), StartLogicalReplication(), StartReplication(), WalSndLoop(), and WalSndWaitForWal().

◆ SyncRepReleaseWaiters()

void SyncRepReleaseWaiters ( void  )

Definition at line 442 of file syncrep.c.

443 {
444  volatile WalSndCtlData *walsndctl = WalSndCtl;
445  XLogRecPtr writePtr;
446  XLogRecPtr flushPtr;
447  XLogRecPtr applyPtr;
448  bool got_recptr;
449  bool am_sync;
450  int numwrite = 0;
451  int numflush = 0;
452  int numapply = 0;
453 
454  /*
455  * If this WALSender is serving a standby that is not on the list of
456  * potential sync standbys then we have nothing to do. If we are still
457  * starting up, still running base backup or the current flush position is
458  * still invalid, then leave quickly also. Streaming or stopping WAL
459  * senders are allowed to release waiters.
460  */
461  if (MyWalSnd->sync_standby_priority == 0 ||
465  {
466  announce_next_takeover = true;
467  return;
468  }
469 
470  /*
471  * We're a potential sync standby. Release waiters if there are enough
472  * sync standbys and we are considered as sync.
473  */
474  LWLockAcquire(SyncRepLock, LW_EXCLUSIVE);
475 
476  /*
477  * Check whether we are a sync standby or not, and calculate the synced
478  * positions among all sync standbys. (Note: although this step does not
479  * of itself require holding SyncRepLock, it seems like a good idea to do
480  * it after acquiring the lock. This ensures that the WAL pointers we use
481  * to release waiters are newer than any previous execution of this
482  * routine used.)
483  */
484  got_recptr = SyncRepGetSyncRecPtr(&writePtr, &flushPtr, &applyPtr, &am_sync);
485 
486  /*
487  * If we are managing a sync standby, though we weren't prior to this,
488  * then announce we are now a sync standby.
489  */
490  if (announce_next_takeover && am_sync)
491  {
492  announce_next_takeover = false;
493 
495  ereport(LOG,
496  (errmsg("standby \"%s\" is now a synchronous standby with priority %u",
498  else
499  ereport(LOG,
500  (errmsg("standby \"%s\" is now a candidate for quorum synchronous standby",
501  application_name)));
502  }
503 
504  /*
505  * If the number of sync standbys is less than requested or we aren't
506  * managing a sync standby then just leave.
507  */
508  if (!got_recptr || !am_sync)
509  {
510  LWLockRelease(SyncRepLock);
511  announce_next_takeover = !am_sync;
512  return;
513  }
514 
515  /*
516  * Set the lsn first so that when we wake backends they will release up to
517  * this location.
518  */
519  if (walsndctl->lsn[SYNC_REP_WAIT_WRITE] < writePtr)
520  {
521  walsndctl->lsn[SYNC_REP_WAIT_WRITE] = writePtr;
522  numwrite = SyncRepWakeQueue(false, SYNC_REP_WAIT_WRITE);
523  }
524  if (walsndctl->lsn[SYNC_REP_WAIT_FLUSH] < flushPtr)
525  {
526  walsndctl->lsn[SYNC_REP_WAIT_FLUSH] = flushPtr;
527  numflush = SyncRepWakeQueue(false, SYNC_REP_WAIT_FLUSH);
528  }
529  if (walsndctl->lsn[SYNC_REP_WAIT_APPLY] < applyPtr)
530  {
531  walsndctl->lsn[SYNC_REP_WAIT_APPLY] = applyPtr;
532  numapply = SyncRepWakeQueue(false, SYNC_REP_WAIT_APPLY);
533  }
534 
535  LWLockRelease(SyncRepLock);
536 
537  elog(DEBUG3, "released %d procs up to write %X/%X, %d procs up to flush %X/%X, %d procs up to apply %X/%X",
538  numwrite, LSN_FORMAT_ARGS(writePtr),
539  numflush, LSN_FORMAT_ARGS(flushPtr),
540  numapply, LSN_FORMAT_ARGS(applyPtr));
541 }
int errmsg(const char *fmt,...)
Definition: elog.c:1069
#define LOG
Definition: elog.h:31
#define DEBUG3
Definition: elog.h:28
XLogRecPtr lsn[NUM_SYNC_REP_WAIT_MODE]
static bool SyncRepGetSyncRecPtr(XLogRecPtr *writePtr, XLogRecPtr *flushPtr, XLogRecPtr *applyPtr, bool *am_sync)
Definition: syncrep.c:554
static int SyncRepWakeQueue(bool all, int mode)
Definition: syncrep.c:880
static bool announce_next_takeover
Definition: syncrep.c:96
#define SYNC_REP_WAIT_WRITE
Definition: syncrep.h:23
#define SYNC_REP_WAIT_FLUSH
Definition: syncrep.h:24
#define SYNC_REP_WAIT_APPLY
Definition: syncrep.h:25
#define LSN_FORMAT_ARGS(lsn)
Definition: xlogdefs.h:43
uint64 XLogRecPtr
Definition: xlogdefs.h:21

References announce_next_takeover, application_name, DEBUG3, elog(), ereport, errmsg(), WalSnd::flush, LOG, WalSndCtlData::lsn, LSN_FORMAT_ARGS, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), MyWalSnd, WalSnd::state, SYNC_REP_PRIORITY, SYNC_REP_WAIT_APPLY, SYNC_REP_WAIT_FLUSH, SYNC_REP_WAIT_WRITE, WalSnd::sync_standby_priority, SyncRepConfigData::syncrep_method, SyncRepConfig, SyncRepGetSyncRecPtr(), SyncRepWakeQueue(), WalSndCtl, WALSNDSTATE_STOPPING, WALSNDSTATE_STREAMING, and XLogRecPtrIsInvalid.

Referenced by ProcessStandbyReplyMessage().

◆ SyncRepUpdateSyncStandbysDefined()

void SyncRepUpdateSyncStandbysDefined ( void  )

Definition at line 937 of file syncrep.c.

938 {
939  bool sync_standbys_defined = SyncStandbysDefined();
940 
941  if (sync_standbys_defined != WalSndCtl->sync_standbys_defined)
942  {
943  LWLockAcquire(SyncRepLock, LW_EXCLUSIVE);
944 
945  /*
946  * If synchronous_standby_names has been reset to empty, it's futile
947  * for backends to continue waiting. Since the user no longer wants
948  * synchronous replication, we'd better wake them up.
949  */
950  if (!sync_standbys_defined)
951  {
952  int i;
953 
954  for (i = 0; i < NUM_SYNC_REP_WAIT_MODE; i++)
955  SyncRepWakeQueue(true, i);
956  }
957 
958  /*
959  * Only allow people to join the queue when there are synchronous
960  * standbys defined. Without this interlock, there's a race
961  * condition: we might wake up all the current waiters; then, some
962  * backend that hasn't yet reloaded its config might go to sleep on
963  * the queue (and never wake up). This prevents that.
964  */
965  WalSndCtl->sync_standbys_defined = sync_standbys_defined;
966 
967  LWLockRelease(SyncRepLock);
968  }
969 }
#define SyncStandbysDefined()
Definition: syncrep.c:93
#define NUM_SYNC_REP_WAIT_MODE
Definition: syncrep.h:27

References i, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), NUM_SYNC_REP_WAIT_MODE, WalSndCtlData::sync_standbys_defined, SyncRepWakeQueue(), SyncStandbysDefined, and WalSndCtl.

Referenced by UpdateSharedMemoryConfig().

◆ SyncRepWaitForLSN()

void SyncRepWaitForLSN ( XLogRecPtr  lsn,
bool  commit 
)

Definition at line 149 of file syncrep.c.

150 {
151  char *new_status = NULL;
152  const char *old_status;
153  int mode;
154 
155  /*
156  * This should be called while holding interrupts during a transaction
157  * commit to prevent the follow-up shared memory queue cleanups to be
158  * influenced by external interruptions.
159  */
161 
162  /*
163  * Fast exit if user has not requested sync replication, or there are no
164  * sync replication standby names defined.
165  *
166  * Since this routine gets called every commit time, it's important to
167  * exit quickly if sync replication is not requested. So we check
168  * WalSndCtl->sync_standbys_defined flag without the lock and exit
169  * immediately if it's false. If it's true, we need to check it again
170  * later while holding the lock, to check the flag and operate the sync
171  * rep queue atomically. This is necessary to avoid the race condition
172  * described in SyncRepUpdateSyncStandbysDefined(). On the other hand, if
173  * it's false, the lock is not necessary because we don't touch the queue.
174  */
175  if (!SyncRepRequested() ||
176  !((volatile WalSndCtlData *) WalSndCtl)->sync_standbys_defined)
177  return;
178 
179  /* Cap the level for anything other than commit to remote flush only. */
180  if (commit)
182  else
184 
186  Assert(WalSndCtl != NULL);
187 
188  LWLockAcquire(SyncRepLock, LW_EXCLUSIVE);
190 
191  /*
192  * We don't wait for sync rep if WalSndCtl->sync_standbys_defined is not
193  * set. See SyncRepUpdateSyncStandbysDefined.
194  *
195  * Also check that the standby hasn't already replied. Unlikely race
196  * condition but we'll be fetching that cache line anyway so it's likely
197  * to be a low cost check.
198  */
200  lsn <= WalSndCtl->lsn[mode])
201  {
202  LWLockRelease(SyncRepLock);
203  return;
204  }
205 
206  /*
207  * Set our waitLSN so WALSender will know when to wake us, and add
208  * ourselves to the queue.
209  */
210  MyProc->waitLSN = lsn;
213  Assert(SyncRepQueueIsOrderedByLSN(mode));
214  LWLockRelease(SyncRepLock);
215 
216  /* Alter ps display to show waiting for sync rep. */
218  {
219  int len;
220 
221  old_status = get_ps_display(&len);
222  new_status = (char *) palloc(len + 32 + 1);
223  memcpy(new_status, old_status, len);
224  sprintf(new_status + len, " waiting for %X/%X",
225  LSN_FORMAT_ARGS(lsn));
226  set_ps_display(new_status);
227  new_status[len] = '\0'; /* truncate off " waiting ..." */
228  }
229 
230  /*
231  * Wait for specified LSN to be confirmed.
232  *
233  * Each proc has its own wait latch, so we perform a normal latch
234  * check/wait loop here.
235  */
236  for (;;)
237  {
238  int rc;
239 
240  /* Must reset the latch before testing state. */
242 
243  /*
244  * Acquiring the lock is not needed, the latch ensures proper
245  * barriers. If it looks like we're done, we must really be done,
246  * because once walsender changes the state to SYNC_REP_WAIT_COMPLETE,
247  * it will never update it again, so we can't be seeing a stale value
248  * in that case.
249  */
251  break;
252 
253  /*
254  * If a wait for synchronous replication is pending, we can neither
255  * acknowledge the commit nor raise ERROR or FATAL. The latter would
256  * lead the client to believe that the transaction aborted, which is
257  * not true: it's already committed locally. The former is no good
258  * either: the client has requested synchronous replication, and is
259  * entitled to assume that an acknowledged commit is also replicated,
260  * which might not be true. So in this case we issue a WARNING (which
261  * some clients may be able to interpret) and shut off further output.
262  * We do NOT reset ProcDiePending, so that the process will die after
263  * the commit is cleaned up.
264  */
265  if (ProcDiePending)
266  {
268  (errcode(ERRCODE_ADMIN_SHUTDOWN),
269  errmsg("canceling the wait for synchronous replication and terminating connection due to administrator command"),
270  errdetail("The transaction has already committed locally, but might not have been replicated to the standby.")));
273  break;
274  }
275 
276  /*
277  * It's unclear what to do if a query cancel interrupt arrives. We
278  * can't actually abort at this point, but ignoring the interrupt
279  * altogether is not helpful, so we just terminate the wait with a
280  * suitable warning.
281  */
282  if (QueryCancelPending)
283  {
284  QueryCancelPending = false;
286  (errmsg("canceling wait for synchronous replication due to user request"),
287  errdetail("The transaction has already committed locally, but might not have been replicated to the standby.")));
289  break;
290  }
291 
292  /*
293  * Wait on latch. Any condition that should wake us up will set the
294  * latch, so no need for timeout.
295  */
298 
299  /*
300  * If the postmaster dies, we'll probably never get an acknowledgment,
301  * because all the wal sender processes will exit. So just bail out.
302  */
303  if (rc & WL_POSTMASTER_DEATH)
304  {
305  ProcDiePending = true;
308  break;
309  }
310  }
311 
312  /*
313  * WalSender has checked our LSN and has removed us from queue. Clean up
314  * state and leave. It's OK to reset these shared memory fields without
315  * holding SyncRepLock, because any walsenders will ignore us anyway when
316  * we're not on the queue. We need a read barrier to make sure we see the
317  * changes to the queue link (this might be unnecessary without
318  * assertions, but better safe than sorry).
319  */
320  pg_read_barrier();
323  MyProc->waitLSN = 0;
324 
325  if (new_status)
326  {
327  /* Reset ps display */
328  set_ps_display(new_status);
329  pfree(new_status);
330  }
331 }
#define pg_read_barrier()
Definition: atomics.h:153
#define Min(x, y)
Definition: c.h:988
@ DestNone
Definition: dest.h:87
int errdetail(const char *fmt,...)
Definition: elog.c:1202
int errcode(int sqlerrcode)
Definition: elog.c:858
#define WARNING
Definition: elog.h:36
volatile uint32 InterruptHoldoffCount
Definition: globals.c:40
volatile sig_atomic_t QueryCancelPending
Definition: globals.c:31
struct Latch * MyLatch
Definition: globals.c:58
volatile sig_atomic_t ProcDiePending
Definition: globals.c:32
void ResetLatch(Latch *latch)
Definition: latch.c:699
int WaitLatch(Latch *latch, int wakeEvents, long timeout, uint32 wait_event_info)
Definition: latch.c:492
#define WL_LATCH_SET
Definition: latch.h:125
#define WL_POSTMASTER_DEATH
Definition: latch.h:129
Assert(fmt[strlen(fmt) - 1] !='\n')
void pfree(void *pointer)
Definition: mcxt.c:1436
static PgChecksumMode mode
Definition: pg_checksums.c:65
const void size_t len
#define sprintf
Definition: port.h:240
CommandDest whereToSendOutput
Definition: postgres.c:84
const char * get_ps_display(int *displen)
Definition: ps_status.c:414
bool update_process_title
Definition: ps_status.c:35
void set_ps_display(const char *activity)
Definition: ps_status.c:342
XLogRecPtr waitLSN
Definition: proc.h:243
int syncRepState
Definition: proc.h:244
static int SyncRepWaitMode
Definition: syncrep.c:99
static void SyncRepQueueInsert(int mode)
Definition: syncrep.c:340
static void SyncRepCancelWait(void)
Definition: syncrep.c:374
#define SyncRepRequested()
Definition: syncrep.h:18
#define SYNC_REP_WAITING
Definition: syncrep.h:31
#define SYNC_REP_WAIT_COMPLETE
Definition: syncrep.h:32
#define SYNC_REP_NOT_WAITING
Definition: syncrep.h:30
@ WAIT_EVENT_SYNC_REP
Definition: wait_event.h:130

References Assert(), DestNone, dlist_node_is_detached(), ereport, errcode(), errdetail(), errmsg(), get_ps_display(), InterruptHoldoffCount, len, LSN_FORMAT_ARGS, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), Min, mode, MyLatch, MyProc, palloc(), pfree(), pg_read_barrier, ProcDiePending, QueryCancelPending, ResetLatch(), set_ps_display(), sprintf, SYNC_REP_NOT_WAITING, SYNC_REP_WAIT_COMPLETE, SYNC_REP_WAIT_FLUSH, SYNC_REP_WAITING, WalSndCtlData::sync_standbys_defined, SyncRepCancelWait(), PGPROC::syncRepLinks, SyncRepQueueInsert(), SyncRepRequested, PGPROC::syncRepState, SyncRepWaitMode, update_process_title, WAIT_EVENT_SYNC_REP, WaitLatch(), PGPROC::waitLSN, WalSndCtl, WARNING, whereToSendOutput, WL_LATCH_SET, and WL_POSTMASTER_DEATH.

Referenced by EndPrepare(), RecordTransactionAbortPrepared(), RecordTransactionCommit(), and RecordTransactionCommitPrepared().

Variable Documentation

◆ syncrep_parse_error_msg

PGDLLIMPORT char* syncrep_parse_error_msg
extern

◆ syncrep_parse_result

PGDLLIMPORT SyncRepConfigData* syncrep_parse_result
extern

◆ SyncRepConfig

◆ SyncRepStandbyNames

PGDLLIMPORT char* SyncRepStandbyNames
extern

Definition at line 91 of file syncrep.c.