|
PostgreSQL Source Code git master
|
#include "postgres.h"#include <float.h>#include "access/xlog.h"#include "access/xlogrecovery.h"#include "access/xlogwait.h"#include "miscadmin.h"#include "pgstat.h"#include "replication/walreceiver.h"#include "storage/latch.h"#include "storage/proc.h"#include "storage/shmem.h"#include "utils/fmgrprotos.h"#include "utils/pg_lsn.h"#include "utils/snapmgr.h"
Go to the source code of this file.
Macros | |
| #define | WAKEUP_PROC_STATIC_ARRAY_SIZE (16) |
Functions | |
| static int | waitlsn_cmp (const pairingheap_node *a, const pairingheap_node *b, void *arg) |
| StaticAssertDecl (lengthof(WaitLSNWaitEvents)==WAIT_LSN_TYPE_COUNT, "WaitLSNWaitEvents must match WaitLSNType enum") | |
| XLogRecPtr | GetCurrentLSNForWaitType (WaitLSNType lsnType) |
| Size | WaitLSNShmemSize (void) |
| void | WaitLSNShmemInit (void) |
| static void | updateMinWaitedLSN (WaitLSNType lsnType) |
| static void | addLSNWaiter (XLogRecPtr lsn, WaitLSNType lsnType) |
| static void | deleteLSNWaiter (WaitLSNType lsnType) |
| static void | wakeupWaiters (WaitLSNType lsnType, XLogRecPtr currentLSN) |
| void | WaitLSNWakeup (WaitLSNType lsnType, XLogRecPtr currentLSN) |
| void | WaitLSNCleanup (void) |
| static bool | WaitLSNTypeRequiresRecovery (WaitLSNType t) |
| WaitLSNResult | WaitForLSN (WaitLSNType lsnType, XLogRecPtr targetLSN, int64 timeout) |
Variables | |
| struct WaitLSNState * | waitLSNState = NULL |
| static const uint32 | WaitLSNWaitEvents [] |
| #define WAKEUP_PROC_STATIC_ARRAY_SIZE (16) |
Definition at line 241 of file xlogwait.c.
|
static |
Definition at line 191 of file xlogwait.c.
References Assert, fb(), i, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), MyProcNumber, pairingheap_add(), WaitLSNState::procInfos, updateMinWaitedLSN(), WAIT_LSN_TYPE_COUNT, WaitLSNState::waitersHeap, and waitLSNState.
Referenced by WaitForLSN().
|
static |
Definition at line 216 of file xlogwait.c.
References Assert, fb(), i, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), MyProcNumber, pairingheap_remove(), WaitLSNState::procInfos, updateMinWaitedLSN(), WAIT_LSN_TYPE_COUNT, WaitLSNState::waitersHeap, and waitLSNState.
Referenced by WaitForLSN(), and WaitLSNCleanup().
| XLogRecPtr GetCurrentLSNForWaitType | ( | WaitLSNType | lsnType | ) |
Definition at line 88 of file xlogwait.c.
References Assert, elog, ERROR, fb(), GetFlushRecPtr(), GetWalRcvFlushRecPtr(), GetWalRcvWriteRecPtr(), GetXLogReplayRecPtr(), pg_unreachable, WAIT_LSN_TYPE_COUNT, WAIT_LSN_TYPE_PRIMARY_FLUSH, WAIT_LSN_TYPE_STANDBY_FLUSH, WAIT_LSN_TYPE_STANDBY_REPLAY, and WAIT_LSN_TYPE_STANDBY_WRITE.
Referenced by ExecWaitStmt(), and WaitForLSN().
| StaticAssertDecl | ( | lengthof(WaitLSNWaitEvents) | = =WAIT_LSN_TYPE_COUNT, |
| "WaitLSNWaitEvents must match WaitLSNType enum" | |||
| ) |
|
static |
Definition at line 170 of file xlogwait.c.
References Assert, fb(), i, WaitLSNState::minWaitedLSN, pairingheap_container, pairingheap_first(), pairingheap_is_empty, pg_atomic_write_u64(), PG_UINT64_MAX, WAIT_LSN_TYPE_COUNT, WaitLSNState::waitersHeap, and waitLSNState.
Referenced by addLSNWaiter(), deleteLSNWaiter(), and wakeupWaiters().
| WaitLSNResult WaitForLSN | ( | WaitLSNType | lsnType, |
| XLogRecPtr | targetLSN, | ||
| int64 | timeout | ||
| ) |
Definition at line 375 of file xlogwait.c.
References addLSNWaiter(), Assert, CHECK_FOR_INTERRUPTS, deleteLSNWaiter(), ereport, errcode(), errcontext, errmsg(), FATAL, fb(), GetCurrentLSNForWaitType(), GetCurrentTimestamp(), MaxBackends, MyLatch, MyProcNumber, NUM_AUXILIARY_PROCS, PromoteIsTriggered(), RecoveryInProgress(), ResetLatch(), TimestampDifferenceMilliseconds(), TimestampTzPlusMilliseconds, WAIT_LSN_RESULT_NOT_IN_RECOVERY, WAIT_LSN_RESULT_SUCCESS, WAIT_LSN_RESULT_TIMEOUT, WaitLatch(), waitLSNState, WaitLSNTypeRequiresRecovery(), WaitLSNWaitEvents, WL_LATCH_SET, WL_POSTMASTER_DEATH, and WL_TIMEOUT.
Referenced by ExecWaitStmt().
|
static |
Definition at line 153 of file xlogwait.c.
References a, b, fb(), and pairingheap_const_container.
Referenced by WaitLSNShmemInit().
Definition at line 338 of file xlogwait.c.
References deleteLSNWaiter(), WaitLSNProcInfo::inHeap, WaitLSNProcInfo::lsnType, MyProcNumber, WaitLSNState::procInfos, and waitLSNState.
Referenced by AbortTransaction(), and ProcKill().
Definition at line 124 of file xlogwait.c.
References fb(), i, MaxBackends, WaitLSNState::minWaitedLSN, NUM_AUXILIARY_PROCS, pairingheap_initialize(), pg_atomic_init_u64(), PG_UINT64_MAX, WaitLSNState::procInfos, ShmemInitStruct(), WAIT_LSN_TYPE_COUNT, WaitLSNState::waitersHeap, waitlsn_cmp(), WaitLSNShmemSize(), and waitLSNState.
Referenced by CreateOrAttachShmemStructs().
Definition at line 113 of file xlogwait.c.
References add_size(), fb(), MaxBackends, mul_size(), NUM_AUXILIARY_PROCS, and WaitLSNState::procInfos.
Referenced by CalculateShmemSize(), and WaitLSNShmemInit().
|
inlinestatic |
Definition at line 359 of file xlogwait.c.
References WAIT_LSN_TYPE_STANDBY_FLUSH, WAIT_LSN_TYPE_STANDBY_REPLAY, and WAIT_LSN_TYPE_STANDBY_WRITE.
Referenced by WaitForLSN().
| void WaitLSNWakeup | ( | WaitLSNType | lsnType, |
| XLogRecPtr | currentLSN | ||
| ) |
Definition at line 317 of file xlogwait.c.
References Assert, fb(), i, WaitLSNState::minWaitedLSN, pg_atomic_read_u64(), WAIT_LSN_TYPE_COUNT, waitLSNState, wakeupWaiters(), and XLogRecPtrIsValid.
Referenced by PerformWalRecovery(), StartupXLOG(), XLogBackgroundFlush(), XLogFlush(), XLogWalRcvFlush(), and XLogWalRcvWrite().
|
static |
Definition at line 256 of file xlogwait.c.
References Assert, fb(), GetPGProcByNumber, i, j, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), pairingheap_container, pairingheap_first(), pairingheap_is_empty, pairingheap_remove_first(), SetLatch(), updateMinWaitedLSN(), WAIT_LSN_TYPE_COUNT, WaitLSNState::waitersHeap, waitLSNState, WAKEUP_PROC_STATIC_ARRAY_SIZE, and XLogRecPtrIsValid.
Referenced by WaitLSNWakeup().
| struct WaitLSNState* waitLSNState = NULL |
Definition at line 68 of file xlogwait.c.
Referenced by addLSNWaiter(), deleteLSNWaiter(), PerformWalRecovery(), updateMinWaitedLSN(), WaitForLSN(), WaitLSNCleanup(), WaitLSNShmemInit(), WaitLSNWakeup(), wakeupWaiters(), XLogBackgroundFlush(), XLogFlush(), XLogWalRcvFlush(), and XLogWalRcvWrite().