PostgreSQL Source Code  git master
walsender.h File Reference
#include <signal.h>
Include dependency graph for walsender.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define WalSndWakeupRequest()   do { wake_wal_senders = true; } while (0)
 
#define WalSndWakeupProcessRequests()
 

Enumerations

enum  CRSSnapshotAction { CRS_EXPORT_SNAPSHOT, CRS_NOEXPORT_SNAPSHOT, CRS_USE_SNAPSHOT }
 

Functions

void InitWalSender (void)
 
bool exec_replication_command (const char *query_string)
 
void WalSndErrorCleanup (void)
 
void WalSndSignals (void)
 
Size WalSndShmemSize (void)
 
void WalSndShmemInit (void)
 
void WalSndWakeup (void)
 
void WalSndInitStopping (void)
 
void WalSndWaitStopping (void)
 
void HandleWalSndInitStopping (void)
 
void WalSndRqstFileReload (void)
 

Variables

bool am_walsender
 
bool am_cascading_walsender
 
bool am_db_walsender
 
bool wake_wal_senders
 
int max_wal_senders
 
int wal_sender_timeout
 
bool log_replication_commands
 

Macro Definition Documentation

◆ WalSndWakeupProcessRequests

#define WalSndWakeupProcessRequests ( )
Value:
do \
{ \
{ \
wake_wal_senders = false; \
if (max_wal_senders > 0) \
WalSndWakeup(); \
} \
} while (0)
int max_wal_senders
Definition: walsender.c:120
bool wake_wal_senders
Definition: walsender.c:129

Definition at line 62 of file walsender.h.

Referenced by XLogBackgroundFlush(), and XLogFlush().

◆ WalSndWakeupRequest

#define WalSndWakeupRequest ( )    do { wake_wal_senders = true; } while (0)

Definition at line 56 of file walsender.h.

Referenced by XLogWrite().

Enumeration Type Documentation

◆ CRSSnapshotAction

Enumerator
CRS_EXPORT_SNAPSHOT 
CRS_NOEXPORT_SNAPSHOT 
CRS_USE_SNAPSHOT 

Definition at line 20 of file walsender.h.

Function Documentation

◆ exec_replication_command()

bool exec_replication_command ( const char *  query_string)

Definition at line 1438 of file walsender.c.

References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, CHECK_FOR_INTERRUPTS, CommitTransactionCommand(), CreateDestReceiver(), CreateReplicationSlot(), CurrentMemoryContext, DEBUG1, generate_unaccent_rules::dest, DestRemote, DestRemoteSimple, DropReplicationSlot(), elog, EndCommand(), ereport, errcode(), errmsg(), errmsg_internal(), ERROR, GetPGVariable(), got_STOPPING, IdentifySystem(), initStringInfo(), InvalidOid, IsA, IsAbortedTransactionBlockState(), IsTransactionBlock(), StartReplicationCmd::kind, LOG, log_replication_commands, MemoryContextDelete(), MemoryContextSwitchTo(), MyDatabaseId, VariableShowStmt::name, pgstat_report_activity(), PreventInTransactionBlock(), REPLICATION_KIND_PHYSICAL, replication_parse_result, replication_scanner_init(), replication_yyparse(), SendBaseBackup(), SendTimeLineHistory(), SnapBuildClearExportedSnapshot(), StartLogicalReplication(), StartReplication(), StartTransactionCommand(), WalSnd::state, STATE_IDLE, STATE_RUNNING, T_BaseBackupCmd, T_CreateReplicationSlotCmd, T_DropReplicationSlotCmd, T_IdentifySystemCmd, T_SQLCmd, T_StartReplicationCmd, T_TimeLineHistoryCmd, T_VariableShowStmt, TimeLineHistoryCmd::type, Node::type, WalSndSetState(), and WALSNDSTATE_STOPPING.

Referenced by PostgresMain().

1439 {
1440  int parse_rc;
1441  Node *cmd_node;
1442  MemoryContext cmd_context;
1443  MemoryContext old_context;
1444 
1445  /*
1446  * If WAL sender has been told that shutdown is getting close, switch its
1447  * status accordingly to handle the next replication commands correctly.
1448  */
1449  if (got_STOPPING)
1451 
1452  /*
1453  * Throw error if in stopping mode. We need prevent commands that could
1454  * generate WAL while the shutdown checkpoint is being written. To be
1455  * safe, we just prohibit all new commands.
1456  */
1458  ereport(ERROR,
1459  (errmsg("cannot execute new commands while WAL sender is in stopping mode")));
1460 
1461  /*
1462  * CREATE_REPLICATION_SLOT ... LOGICAL exports a snapshot until the next
1463  * command arrives. Clean up the old stuff if there's anything.
1464  */
1466 
1468 
1470  "Replication command context",
1472  old_context = MemoryContextSwitchTo(cmd_context);
1473 
1474  replication_scanner_init(cmd_string);
1475  parse_rc = replication_yyparse();
1476  if (parse_rc != 0)
1477  ereport(ERROR,
1478  (errcode(ERRCODE_SYNTAX_ERROR),
1479  (errmsg_internal("replication command parser returned %d",
1480  parse_rc))));
1481 
1482  cmd_node = replication_parse_result;
1483 
1484  /*
1485  * Log replication command if log_replication_commands is enabled. Even
1486  * when it's disabled, log the command with DEBUG1 level for backward
1487  * compatibility. Note that SQL commands are not logged here, and will be
1488  * logged later if log_statement is enabled.
1489  */
1490  if (cmd_node->type != T_SQLCmd)
1492  (errmsg("received replication command: %s", cmd_string)));
1493 
1494  /*
1495  * CREATE_REPLICATION_SLOT ... LOGICAL exports a snapshot. If it was
1496  * called outside of transaction the snapshot should be cleared here.
1497  */
1498  if (!IsTransactionBlock())
1500 
1501  /*
1502  * For aborted transactions, don't allow anything except pure SQL, the
1503  * exec_simple_query() will handle it correctly.
1504  */
1505  if (IsAbortedTransactionBlockState() && !IsA(cmd_node, SQLCmd))
1506  ereport(ERROR,
1507  (errcode(ERRCODE_IN_FAILED_SQL_TRANSACTION),
1508  errmsg("current transaction is aborted, "
1509  "commands ignored until end of transaction block")));
1510 
1512 
1513  /*
1514  * Allocate buffers that will be used for each outgoing and incoming
1515  * message. We do this just once per command to reduce palloc overhead.
1516  */
1520 
1521  /* Report to pgstat that this process is running */
1523 
1524  switch (cmd_node->type)
1525  {
1526  case T_IdentifySystemCmd:
1527  IdentifySystem();
1528  break;
1529 
1530  case T_BaseBackupCmd:
1531  PreventInTransactionBlock(true, "BASE_BACKUP");
1532  SendBaseBackup((BaseBackupCmd *) cmd_node);
1533  break;
1534 
1537  break;
1538 
1541  break;
1542 
1543  case T_StartReplicationCmd:
1544  {
1545  StartReplicationCmd *cmd = (StartReplicationCmd *) cmd_node;
1546 
1547  PreventInTransactionBlock(true, "START_REPLICATION");
1548 
1549  if (cmd->kind == REPLICATION_KIND_PHYSICAL)
1550  StartReplication(cmd);
1551  else
1553  break;
1554  }
1555 
1556  case T_TimeLineHistoryCmd:
1557  PreventInTransactionBlock(true, "TIMELINE_HISTORY");
1559  break;
1560 
1561  case T_VariableShowStmt:
1562  {
1564  VariableShowStmt *n = (VariableShowStmt *) cmd_node;
1565 
1566  /* syscache access needs a transaction environment */
1568  GetPGVariable(n->name, dest);
1570  }
1571  break;
1572 
1573  case T_SQLCmd:
1574  if (MyDatabaseId == InvalidOid)
1575  ereport(ERROR,
1576  (errmsg("cannot execute SQL commands in WAL sender for physical replication")));
1577 
1578  /* Report to pgstat that this process is now idle */
1580 
1581  /* Tell the caller that this wasn't a WalSender command. */
1582  return false;
1583 
1584  default:
1585  elog(ERROR, "unrecognized replication command node tag: %u",
1586  cmd_node->type);
1587  }
1588 
1589  /* done */
1590  MemoryContextSwitchTo(old_context);
1591  MemoryContextDelete(cmd_context);
1592 
1593  /* Send CommandComplete message */
1594  EndCommand("SELECT", DestRemote);
1595 
1596  /* Report to pgstat that this process is now idle */
1598 
1599  return true;
1600 }
#define IsA(nodeptr, _type_)
Definition: nodes.h:576
void MemoryContextDelete(MemoryContext context)
Definition: mcxt.c:211
#define AllocSetContextCreate
Definition: memutils.h:170
#define DEBUG1
Definition: elog.h:25
void pgstat_report_activity(BackendState state, const char *cmd_str)
Definition: pgstat.c:3119
static void SendTimeLineHistory(TimeLineHistoryCmd *cmd)
Definition: walsender.c:434
static void DropReplicationSlot(DropReplicationSlotCmd *cmd)
Definition: walsender.c:1052
void CommitTransactionCommand(void)
Definition: xact.c:2897
bool IsAbortedTransactionBlockState(void)
Definition: xact.c:375
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition: palloc.h:109
Definition: nodes.h:525
static StringInfoData output_message
Definition: walsender.c:152
static volatile sig_atomic_t got_STOPPING
Definition: walsender.c:182
int errcode(int sqlerrcode)
Definition: elog.c:608
#define LOG
Definition: elog.h:26
void GetPGVariable(const char *name, DestReceiver *dest)
Definition: guc.c:8791
Node * replication_parse_result
bool IsTransactionBlock(void)
Definition: xact.c:4635
ReplicationKind kind
Definition: replnodes.h:82
void EndCommand(const char *commandTag, CommandDest dest)
Definition: dest.c:166
#define ERROR
Definition: elog.h:43
void SendBaseBackup(BaseBackupCmd *cmd)
Definition: basebackup.c:759
#define ALLOCSET_DEFAULT_SIZES
Definition: memutils.h:192
WalSndState state
NodeTag type
Definition: nodes.h:527
DestReceiver * CreateDestReceiver(CommandDest dest)
Definition: dest.c:113
static void StartReplication(StartReplicationCmd *cmd)
Definition: walsender.c:540
void PreventInTransactionBlock(bool isTopLevel, const char *stmtType)
Definition: xact.c:3330
MemoryContext CurrentMemoryContext
Definition: mcxt.c:38
#define ereport(elevel, rest)
Definition: elog.h:141
int replication_yyparse(void)
void initStringInfo(StringInfo str)
Definition: stringinfo.c:59
static StringInfoData reply_message
Definition: walsender.c:153
static void StartLogicalReplication(StartReplicationCmd *cmd)
Definition: walsender.c:1063
Oid MyDatabaseId
Definition: globals.c:85
WalSnd * MyWalSnd
Definition: walsender.c:111
#define InvalidOid
Definition: postgres_ext.h:36
int errmsg_internal(const char *fmt,...)
Definition: elog.c:911
void WalSndSetState(WalSndState state)
Definition: walsender.c:3176
void StartTransactionCommand(void)
Definition: xact.c:2796
static void CreateReplicationSlot(CreateReplicationSlotCmd *cmd)
Definition: walsender.c:852
static StringInfoData tmpbuf
Definition: walsender.c:154
bool log_replication_commands
Definition: walsender.c:124
int errmsg(const char *fmt,...)
Definition: elog.c:822
#define elog(elevel,...)
Definition: elog.h:228
#define CHECK_FOR_INTERRUPTS()
Definition: miscadmin.h:99
static void IdentifySystem(void)
Definition: walsender.c:345
void SnapBuildClearExportedSnapshot(void)
Definition: snapbuild.c:692
void replication_scanner_init(const char *query_string)

◆ HandleWalSndInitStopping()

void HandleWalSndInitStopping ( void  )

Definition at line 2985 of file walsender.c.

References am_walsender, Assert, got_STOPPING, kill, MyProcPid, and replication_active.

Referenced by procsignal_sigusr1_handler().

2986 {
2988 
2989  /*
2990  * If replication has not yet started, die like with SIGTERM. If
2991  * replication is active, only set a flag and wake up the main loop. It
2992  * will send any outstanding WAL, wait for it to be replicated to the
2993  * standby, and then exit gracefully.
2994  */
2995  if (!replication_active)
2996  kill(MyProcPid, SIGTERM);
2997  else
2998  got_STOPPING = true;
2999 }
int MyProcPid
Definition: globals.c:40
static volatile sig_atomic_t got_STOPPING
Definition: walsender.c:182
#define kill(pid, sig)
Definition: win32_port.h:426
bool am_walsender
Definition: walsender.c:114
static volatile sig_atomic_t replication_active
Definition: walsender.c:190
#define Assert(condition)
Definition: c.h:733

◆ InitWalSender()

void InitWalSender ( void  )

Referenced by PostgresMain().

◆ WalSndErrorCleanup()

void WalSndErrorCleanup ( void  )

Definition at line 298 of file walsender.c.

References close, ConditionVariableCancelSleep(), DestNone, DestRemote, got_SIGUSR2, got_STOPPING, LWLockReleaseAll(), MyReplicationSlot, pgstat_report_wait_end(), proc_exit(), replication_active, ReplicationSlotCleanup(), ReplicationSlotRelease(), WalSndSetState(), WalSndShutdown(), WALSNDSTATE_STARTUP, whereToSendOutput, and WALOpenSegment::ws_file.

Referenced by PostgresMain().

299 {
303 
304  if (sendSeg->ws_file >= 0)
305  {
307  sendSeg->ws_file = -1;
308  }
309 
310  if (MyReplicationSlot != NULL)
312 
314 
315  replication_active = false;
316 
317  if (got_STOPPING || got_SIGUSR2)
318  proc_exit(0);
319 
320  /* Revert back to startup state */
322 }
static volatile sig_atomic_t got_STOPPING
Definition: walsender.c:182
void proc_exit(int code)
Definition: ipc.c:104
void ConditionVariableCancelSleep(void)
void ReplicationSlotRelease(void)
Definition: slot.c:424
static WALOpenSegment * sendSeg
Definition: walsender.c:131
static void pgstat_report_wait_end(void)
Definition: pgstat.h:1342
static volatile sig_atomic_t got_SIGUSR2
Definition: walsender.c:181
static volatile sig_atomic_t replication_active
Definition: walsender.c:190
ReplicationSlot * MyReplicationSlot
Definition: slot.c:96
void WalSndSetState(WalSndState state)
Definition: walsender.c:3176
void ReplicationSlotCleanup(void)
Definition: slot.c:479
void LWLockReleaseAll(void)
Definition: lwlock.c:1825
#define close(a)
Definition: win32.h:12

◆ WalSndInitStopping()

void WalSndInitStopping ( void  )

Definition at line 3112 of file walsender.c.

References i, InvalidBackendId, max_wal_senders, WalSnd::mutex, WalSnd::pid, PROCSIG_WALSND_INIT_STOPPING, SendProcSignal(), SpinLockAcquire, SpinLockRelease, and WalSndCtlData::walsnds.

Referenced by ShutdownXLOG().

3113 {
3114  int i;
3115 
3116  for (i = 0; i < max_wal_senders; i++)
3117  {
3118  WalSnd *walsnd = &WalSndCtl->walsnds[i];
3119  pid_t pid;
3120 
3121  SpinLockAcquire(&walsnd->mutex);
3122  pid = walsnd->pid;
3123  SpinLockRelease(&walsnd->mutex);
3124 
3125  if (pid == 0)
3126  continue;
3127 
3129  }
3130 }
WalSndCtlData * WalSndCtl
Definition: walsender.c:108
WalSnd walsnds[FLEXIBLE_ARRAY_MEMBER]
slock_t mutex
#define SpinLockAcquire(lock)
Definition: spin.h:62
int SendProcSignal(pid_t pid, ProcSignalReason reason, BackendId backendId)
Definition: procsignal.c:179
int max_wal_senders
Definition: walsender.c:120
#define SpinLockRelease(lock)
Definition: spin.h:64
#define InvalidBackendId
Definition: backendid.h:23
int i

◆ WalSndRqstFileReload()

void WalSndRqstFileReload ( void  )

Definition at line 2962 of file walsender.c.

References i, max_wal_senders, WalSnd::mutex, WalSnd::needreload, WalSnd::pid, SpinLockAcquire, SpinLockRelease, and WalSndCtlData::walsnds.

Referenced by KeepFileRestoredFromArchive().

2963 {
2964  int i;
2965 
2966  for (i = 0; i < max_wal_senders; i++)
2967  {
2968  WalSnd *walsnd = &WalSndCtl->walsnds[i];
2969 
2970  SpinLockAcquire(&walsnd->mutex);
2971  if (walsnd->pid == 0)
2972  {
2973  SpinLockRelease(&walsnd->mutex);
2974  continue;
2975  }
2976  walsnd->needreload = true;
2977  SpinLockRelease(&walsnd->mutex);
2978  }
2979 }
WalSndCtlData * WalSndCtl
Definition: walsender.c:108
WalSnd walsnds[FLEXIBLE_ARRAY_MEMBER]
slock_t mutex
#define SpinLockAcquire(lock)
Definition: spin.h:62
int max_wal_senders
Definition: walsender.c:120
#define SpinLockRelease(lock)
Definition: spin.h:64
bool needreload
int i

◆ WalSndShmemInit()

void WalSndShmemInit ( void  )

Definition at line 3051 of file walsender.c.

References i, max_wal_senders, MemSet, WalSnd::mutex, NUM_SYNC_REP_WAIT_MODE, ShmemInitStruct(), SHMQueueInit(), SpinLockInit, WalSndCtlData::SyncRepQueue, WalSndCtlData::walsnds, and WalSndShmemSize().

Referenced by CreateSharedMemoryAndSemaphores().

3052 {
3053  bool found;
3054  int i;
3055 
3056  WalSndCtl = (WalSndCtlData *)
3057  ShmemInitStruct("Wal Sender Ctl", WalSndShmemSize(), &found);
3058 
3059  if (!found)
3060  {
3061  /* First time through, so initialize */
3063 
3064  for (i = 0; i < NUM_SYNC_REP_WAIT_MODE; i++)
3066 
3067  for (i = 0; i < max_wal_senders; i++)
3068  {
3069  WalSnd *walsnd = &WalSndCtl->walsnds[i];
3070 
3071  SpinLockInit(&walsnd->mutex);
3072  }
3073  }
3074 }
Size WalSndShmemSize(void)
Definition: walsender.c:3039
#define SpinLockInit(lock)
Definition: spin.h:60
WalSndCtlData * WalSndCtl
Definition: walsender.c:108
#define MemSet(start, val, len)
Definition: c.h:956
WalSnd walsnds[FLEXIBLE_ARRAY_MEMBER]
slock_t mutex
void * ShmemInitStruct(const char *name, Size size, bool *foundPtr)
Definition: shmem.c:372
SHM_QUEUE SyncRepQueue[NUM_SYNC_REP_WAIT_MODE]
int max_wal_senders
Definition: walsender.c:120
void SHMQueueInit(SHM_QUEUE *queue)
Definition: shmqueue.c:36
int i
#define NUM_SYNC_REP_WAIT_MODE
Definition: syncrep.h:28

◆ WalSndShmemSize()

Size WalSndShmemSize ( void  )

Definition at line 3039 of file walsender.c.

References add_size(), max_wal_senders, mul_size(), and offsetof.

Referenced by CreateSharedMemoryAndSemaphores(), and WalSndShmemInit().

3040 {
3041  Size size = 0;
3042 
3043  size = offsetof(WalSndCtlData, walsnds);
3044  size = add_size(size, mul_size(max_wal_senders, sizeof(WalSnd)));
3045 
3046  return size;
3047 }
int max_wal_senders
Definition: walsender.c:120
Size mul_size(Size s1, Size s2)
Definition: shmem.c:492
Size add_size(Size s1, Size s2)
Definition: shmem.c:475
size_t Size
Definition: c.h:467
#define offsetof(type, field)
Definition: c.h:656

◆ WalSndSignals()

void WalSndSignals ( void  )

Definition at line 3019 of file walsender.c.

References die, InitializeTimeouts(), PostgresSigHupHandler(), pqsignal(), procsignal_sigusr1_handler(), quickdie(), SIG_DFL, SIG_IGN, SIGCHLD, SIGHUP, SIGPIPE, SIGQUIT, SIGUSR1, SIGUSR2, StatementCancelHandler(), and WalSndLastCycleHandler().

Referenced by PostgresMain().

3020 {
3021  /* Set up signal handlers */
3022  pqsignal(SIGHUP, PostgresSigHupHandler); /* set flag to read config
3023  * file */
3024  pqsignal(SIGINT, StatementCancelHandler); /* query cancel */
3025  pqsignal(SIGTERM, die); /* request shutdown */
3026  pqsignal(SIGQUIT, quickdie); /* hard crash time */
3027  InitializeTimeouts(); /* establishes SIGALRM handler */
3030  pqsignal(SIGUSR2, WalSndLastCycleHandler); /* request a last cycle and
3031  * shutdown */
3032 
3033  /* Reset some signals that are accepted by postmaster but not here */
3035 }
void InitializeTimeouts(void)
Definition: timeout.c:346
#define SIGQUIT
Definition: win32_port.h:155
#define SIGUSR1
Definition: win32_port.h:166
static void WalSndLastCycleHandler(SIGNAL_ARGS)
Definition: walsender.c:3007
#define SIGCHLD
Definition: win32_port.h:164
#define SIGPIPE
Definition: win32_port.h:159
#define SIGUSR2
Definition: win32_port.h:167
void StatementCancelHandler(SIGNAL_ARGS)
Definition: postgres.c:2814
#define SIGHUP
Definition: win32_port.h:154
void PostgresSigHupHandler(SIGNAL_ARGS)
Definition: postgres.c:2854
#define SIG_IGN
Definition: win32_port.h:151
pqsigfunc pqsignal(int signum, pqsigfunc handler)
Definition: signal.c:170
#define SIG_DFL
Definition: win32_port.h:149
void procsignal_sigusr1_handler(SIGNAL_ARGS)
Definition: procsignal.c:260
void quickdie(SIGNAL_ARGS)
Definition: postgres.c:2716
#define die(msg)
Definition: pg_test_fsync.c:96

◆ WalSndWaitStopping()

void WalSndWaitStopping ( void  )

Definition at line 3138 of file walsender.c.

References i, max_wal_senders, WalSnd::mutex, pg_usleep(), WalSnd::pid, SpinLockAcquire, SpinLockRelease, WalSnd::state, WalSndCtlData::walsnds, and WALSNDSTATE_STOPPING.

Referenced by ShutdownXLOG().

3139 {
3140  for (;;)
3141  {
3142  int i;
3143  bool all_stopped = true;
3144 
3145  for (i = 0; i < max_wal_senders; i++)
3146  {
3147  WalSnd *walsnd = &WalSndCtl->walsnds[i];
3148 
3149  SpinLockAcquire(&walsnd->mutex);
3150 
3151  if (walsnd->pid == 0)
3152  {
3153  SpinLockRelease(&walsnd->mutex);
3154  continue;
3155  }
3156 
3157  if (walsnd->state != WALSNDSTATE_STOPPING)
3158  {
3159  all_stopped = false;
3160  SpinLockRelease(&walsnd->mutex);
3161  break;
3162  }
3163  SpinLockRelease(&walsnd->mutex);
3164  }
3165 
3166  /* safe to leave if confirmation is done for all WAL senders */
3167  if (all_stopped)
3168  return;
3169 
3170  pg_usleep(10000L); /* wait for 10 msec */
3171  }
3172 }
WalSndCtlData * WalSndCtl
Definition: walsender.c:108
WalSnd walsnds[FLEXIBLE_ARRAY_MEMBER]
slock_t mutex
#define SpinLockAcquire(lock)
Definition: spin.h:62
void pg_usleep(long microsec)
Definition: signal.c:53
WalSndState state
int max_wal_senders
Definition: walsender.c:120
#define SpinLockRelease(lock)
Definition: spin.h:64
int i

◆ WalSndWakeup()

void WalSndWakeup ( void  )

Definition at line 3083 of file walsender.c.

References i, WalSnd::latch, max_wal_senders, WalSnd::mutex, SetLatch(), SpinLockAcquire, SpinLockRelease, and WalSndCtlData::walsnds.

Referenced by KeepFileRestoredFromArchive(), StartupXLOG(), and XLogWalRcvFlush().

3084 {
3085  int i;
3086 
3087  for (i = 0; i < max_wal_senders; i++)
3088  {
3089  Latch *latch;
3090  WalSnd *walsnd = &WalSndCtl->walsnds[i];
3091 
3092  /*
3093  * Get latch pointer with spinlock held, for the unlikely case that
3094  * pointer reads aren't atomic (as they're 8 bytes).
3095  */
3096  SpinLockAcquire(&walsnd->mutex);
3097  latch = walsnd->latch;
3098  SpinLockRelease(&walsnd->mutex);
3099 
3100  if (latch != NULL)
3101  SetLatch(latch);
3102  }
3103 }
WalSndCtlData * WalSndCtl
Definition: walsender.c:108
WalSnd walsnds[FLEXIBLE_ARRAY_MEMBER]
void SetLatch(Latch *latch)
Definition: latch.c:436
slock_t mutex
#define SpinLockAcquire(lock)
Definition: spin.h:62
Latch * latch
Definition: latch.h:110
int max_wal_senders
Definition: walsender.c:120
#define SpinLockRelease(lock)
Definition: spin.h:64
int i

Variable Documentation

◆ am_cascading_walsender

◆ am_db_walsender

bool am_db_walsender

Definition at line 117 of file walsender.c.

Referenced by check_db(), InitPostgres(), and ProcessStartupPacket().

◆ am_walsender

◆ log_replication_commands

bool log_replication_commands

Definition at line 124 of file walsender.c.

Referenced by exec_replication_command().

◆ max_wal_senders

◆ wake_wal_senders

bool wake_wal_senders

Definition at line 129 of file walsender.c.

◆ wal_sender_timeout

int wal_sender_timeout