|
PostgreSQL Source Code git master
|
#include "postgres.h"#include "access/transam.h"#include "access/twophase.h"#include "access/xact.h"#include "access/xloginsert.h"#include "access/xlogrecovery.h"#include "access/xlogutils.h"#include "miscadmin.h"#include "pgstat.h"#include "replication/slot.h"#include "storage/bufmgr.h"#include "storage/proc.h"#include "storage/procarray.h"#include "storage/sinvaladt.h"#include "storage/standby.h"#include "utils/hsearch.h"#include "utils/injection_point.h"#include "utils/ps_status.h"#include "utils/timeout.h"#include "utils/timestamp.h"#include "utils/wait_event.h"
Go to the source code of this file.
Data Structures | |
| struct | RecoveryLockEntry |
| struct | RecoveryLockXidEntry |
Macros | |
| #define | STANDBY_INITIAL_WAIT_US 1000 |
Typedefs | |
| typedef struct RecoveryLockEntry | RecoveryLockEntry |
| typedef struct RecoveryLockXidEntry | RecoveryLockXidEntry |
Definition at line 907 of file standby.c.
References Assert, ereport, errcode(), ERRCODE_T_R_DEADLOCK_DETECTED, errdetail(), errmsg, ERROR, HoldingBufferPinThatDelaysRecovery(), and InRecovery.
Referenced by ProcSleep().
|
static |
Definition at line 1515 of file standby.c.
References _, fb(), RECOVERY_CONFLICT_BUFFERPIN, RECOVERY_CONFLICT_BUFFERPIN_DEADLOCK, RECOVERY_CONFLICT_DATABASE, RECOVERY_CONFLICT_LOCK, RECOVERY_CONFLICT_LOGICALSLOT, RECOVERY_CONFLICT_SNAPSHOT, RECOVERY_CONFLICT_STARTUP_DEADLOCK, and RECOVERY_CONFLICT_TABLESPACE.
Referenced by LogRecoveryConflict().
|
static |
Definition at line 202 of file standby.c.
References fb(), GetXLogReceiptTime(), max_standby_archive_delay, max_standby_streaming_delay, and TimestampTzPlusMilliseconds.
Referenced by ResolveRecoveryConflictWithBufferPin(), ResolveRecoveryConflictWithLock(), and WaitExceedsMaxStandbyDelay().
Definition at line 96 of file standby.c.
References Assert, fb(), GetNextLocalTransactionId(), HASH_BLOBS, hash_create(), HASH_ELEM, VirtualTransactionId::localTransactionId, MyProc, MyProcNumber, VirtualTransactionId::procNumber, PGPROC::procNumber, RecoveryLockHash, RecoveryLockXidHash, SharedInvalBackendInit(), STANDBY_INITIALIZED, standbyState, VirtualXactLockTableInsert(), and PGPROC::vxid.
Referenced by StartupXLOG().
Definition at line 1454 of file standby.c.
References fb(), GetCurrentTransactionId(), LogAccessExclusiveLocks(), MyXactFlags, XACT_FLAGS_ACQUIREDACCESSEXCLUSIVELOCK, and xl_standby_lock::xid.
Referenced by LockAcquireExtended().
Definition at line 1471 of file standby.c.
References fb(), and GetCurrentTransactionId().
Referenced by LockAcquireExtended().
|
static |
Definition at line 1436 of file standby.c.
References fb(), xl_standby_locks::nlocks, XLOG_MARK_UNIMPORTANT, XLOG_STANDBY_LOCK, XLogBeginInsert(), XLogInsert(), XLogRegisterData(), and XLogSetRecordFlags().
Referenced by LogAccessExclusiveLock(), and LogStandbySnapshot().
|
static |
Definition at line 1375 of file standby.c.
References xl_running_xacts::dbid, DEBUG2, elog, fb(), LSN_FORMAT_ARGS, MinSizeOfXactRunningXacts, SUBXIDS_IN_ARRAY, XLOG_MARK_UNIMPORTANT, XLOG_RUNNING_XACTS, XLogBeginInsert(), XLogInsert(), XLogRegisterData(), XLogSetAsyncXactLSN(), and XLogSetRecordFlags().
Referenced by LogStandbySnapshot().
| void LogRecoveryConflict | ( | RecoveryConflictReason | reason, |
| TimestampTz | wait_start, | ||
| TimestampTz | now, | ||
| VirtualTransactionId * | wait_list, | ||
| bool | still_waiting | ||
| ) |
Definition at line 275 of file standby.c.
References appendStringInfo(), Assert, buf, ereport, errdetail_log_plural(), errmsg, fb(), get_recovery_conflict_desc(), initStringInfo(), LOG, now(), pfree(), PGPROC::pid, ProcNumberGetProc(), TimestampDifference(), and VirtualTransactionIdIsValid.
Referenced by LockBufferForCleanup(), ProcSleep(), and ResolveRecoveryConflictWithVirtualXIDs().
| void LogStandbyInvalidations | ( | int | nmsgs, |
| SharedInvalidationMessage * | msgs, | ||
| bool | relcacheInitFileInval | ||
| ) |
Definition at line 1493 of file standby.c.
References fb(), MinSizeOfInvalidations, MyDatabaseId, MyDatabaseTableSpace, XLOG_INVALIDATIONS, XLogBeginInsert(), XLogInsert(), and XLogRegisterData().
Referenced by RecordTransactionCommit().
| XLogRecPtr LogStandbySnapshot | ( | Oid | dbid | ) |
Definition at line 1303 of file standby.c.
References Assert, fb(), GetInsertRecPtr(), GetRunningTransactionData(), GetRunningTransactionLocks(), IS_INJECTION_POINT_ATTACHED, IsLogicalDecodingEnabled(), LogAccessExclusiveLocks(), LogCurrentRunningXacts(), LWLockRelease(), pfree(), and XLogStandbyInfoActive.
Referenced by BackgroundWriterMain(), CreateCheckPoint(), pg_log_standby_snapshot(), ReplicationSlotReserveWal(), SnapBuildProcessRunningXacts(), and SnapBuildWaitSnapshot().
Definition at line 795 of file standby.c.
References Assert, DeadlockTimeout, disable_all_timeouts(), enable_timeouts(), fb(), GetCurrentTimestamp(), GetStandbyLimitTime(), got_standby_deadlock_timeout, got_standby_delay_timeout, EnableTimeoutParams::id, InHotStandby, ProcWaitForSignal(), RECOVERY_CONFLICT_BUFFERPIN, RECOVERY_CONFLICT_BUFFERPIN_DEADLOCK, SendRecoveryConflictWithBufferPin(), STANDBY_DEADLOCK_TIMEOUT, STANDBY_TIMEOUT, TMPARAM_AFTER, and TMPARAM_AT.
Referenced by LockBufferForCleanup().
Definition at line 572 of file standby.c.
References CountDBBackends(), pg_usleep(), RECOVERY_CONFLICT_DATABASE, and SignalRecoveryConflictWithDatabase().
Referenced by dbase_redo().
Definition at line 626 of file standby.c.
References AccessExclusiveLock, Assert, cleanup(), DeadlockTimeout, disable_all_timeouts(), enable_timeouts(), fb(), GetCurrentTimestamp(), GetLockConflicts(), GetStandbyLimitTime(), got_standby_deadlock_timeout, got_standby_lock_timeout, EnableTimeoutParams::id, InHotStandby, LOCKTAG::locktag_type, MyProc, now(), pg_atomic_read_u64(), pg_atomic_write_u64(), PG_WAIT_LOCK, ProcWaitForSignal(), RECOVERY_CONFLICT_LOCK, RECOVERY_CONFLICT_STARTUP_DEADLOCK, ResolveRecoveryConflictWithVirtualXIDs(), SignalRecoveryConflictWithVirtualXID(), STANDBY_DEADLOCK_TIMEOUT, STANDBY_LOCK_TIMEOUT, TMPARAM_AFTER, TMPARAM_AT, VirtualTransactionIdIsValid, and PGPROC::waitStart.
Referenced by ProcSleep().
| void ResolveRecoveryConflictWithSnapshot | ( | TransactionId | snapshotConflictHorizon, |
| bool | isCatalogRel, | ||
| RelFileLocator | locator | ||
| ) |
Definition at line 470 of file standby.c.
References Assert, RelFileLocator::dbOid, fb(), GetConflictingVirtualXIDs(), InvalidateObsoleteReplicationSlots(), IsLogicalDecodingEnabled(), RECOVERY_CONFLICT_SNAPSHOT, ResolveRecoveryConflictWithVirtualXIDs(), RS_INVAL_HORIZON, TransactionIdIsNormal, and TransactionIdIsValid.
Referenced by btree_xlog_delete(), gistRedoDeleteRecord(), hash_xlog_vacuum_one_page(), heap_xlog_prune_freeze(), ResolveRecoveryConflictWithSnapshotFullXid(), and spgRedoVacuumRedirect().
| void ResolveRecoveryConflictWithSnapshotFullXid | ( | FullTransactionId | snapshotConflictHorizon, |
| bool | isCatalogRel, | ||
| RelFileLocator | locator | ||
| ) |
Definition at line 515 of file standby.c.
References fb(), MaxTransactionId, ReadNextFullTransactionId(), ResolveRecoveryConflictWithSnapshot(), U64FromFullTransactionId, and XidFromFullTransactionId.
Referenced by btree_xlog_reuse_page(), and gistRedoPageReuse().
Definition at line 542 of file standby.c.
References fb(), GetConflictingVirtualXIDs(), InvalidOid, InvalidTransactionId, RECOVERY_CONFLICT_TABLESPACE, and ResolveRecoveryConflictWithVirtualXIDs().
Referenced by tblspc_redo().
|
static |
Definition at line 361 of file standby.c.
References Assert, DeadlockTimeout, fb(), GetCurrentTimestamp(), log_recovery_conflict_waits, LogRecoveryConflict(), now(), pg_usleep(), set_ps_display_remove_suffix(), set_ps_display_suffix(), SignalRecoveryConflictWithVirtualXID(), STANDBY_INITIAL_WAIT_US, standbyWait_us, TimestampDifferenceExceeds(), update_process_title, VirtualTransactionIdIsValid, VirtualXactLock(), WaitExceedsMaxStandbyDelay(), and waiting.
Referenced by ResolveRecoveryConflictWithLock(), ResolveRecoveryConflictWithSnapshot(), and ResolveRecoveryConflictWithTablespace().
|
static |
Definition at line 879 of file standby.c.
References Assert, InvalidOid, RECOVERY_CONFLICT_BUFFERPIN, RECOVERY_CONFLICT_BUFFERPIN_DEADLOCK, and SignalRecoveryConflictWithDatabase().
Referenced by ResolveRecoveryConflictWithBufferPin().
Definition at line 162 of file standby.c.
References ExpireAllKnownAssignedTransactionIds(), fb(), hash_destroy(), RecoveryLockHash, RecoveryLockXidHash, StandbyReleaseAllLocks(), and VirtualXactLockTableCleanup().
Referenced by StartupProcExit(), and StartupXLOG().
| void standby_redo | ( | XLogReaderState * | record | ) |
Definition at line 1165 of file standby.c.
References Assert, elog, fb(), i, RunningTransactionsData::latestCompletedXid, RunningTransactionsData::nextXid, OidIsValid, RunningTransactionsData::oldestRunningXid, PANIC, pgstat_report_stat(), ProcArrayApplyRecoveryInfo(), ProcessCommittedInvalidationMessages(), STANDBY_DISABLED, StandbyAcquireAccessExclusiveLock(), standbyState, RunningTransactionsData::subxcnt, RunningTransactionsData::subxid_status, SUBXIDS_IN_ARRAY, SUBXIDS_MISSING, RunningTransactionsData::xcnt, RunningTransactionsData::xids, XLOG_INVALIDATIONS, XLOG_RUNNING_XACTS, XLOG_STANDBY_LOCK, XLogRecGetData, XLogRecGetInfo, and XLogRecHasAnyBlockRefs.
| void StandbyAcquireAccessExclusiveLock | ( | TransactionId | xid, |
| Oid | dbOid, | ||
| Oid | relOid | ||
| ) |
Definition at line 988 of file standby.c.
References AccessExclusiveLock, Assert, xl_standby_lock::dbOid, DEBUG4, elog, fb(), HASH_ENTER, hash_search(), RecoveryLockEntry::key, LockAcquire(), OidIsValid, RecoveryLockHash, RecoveryLockXidHash, xl_standby_lock::relOid, SET_LOCKTAG_RELATION, TransactionIdDidAbort(), TransactionIdDidCommit(), TransactionIdIsValid, and xl_standby_lock::xid.
Referenced by lock_twophase_standby_recover(), and standby_redo().
Definition at line 938 of file standby.c.
References got_standby_deadlock_timeout.
Referenced by StartupProcessMain().
Definition at line 956 of file standby.c.
References got_standby_lock_timeout.
Referenced by StartupProcessMain().
Definition at line 1108 of file standby.c.
References DEBUG2, elog, fb(), HASH_REMOVE, hash_search(), hash_seq_init(), hash_seq_search(), RecoveryLockXidHash, and StandbyReleaseXidEntryLocks().
Referenced by ShutdownRecoveryTransactionEnvironment(), and StandbyReleaseLocks().
|
static |
Definition at line 1070 of file standby.c.
References fb(), HASH_FIND, HASH_REMOVE, hash_search(), RecoveryLockXidHash, StandbyReleaseAllLocks(), StandbyReleaseXidEntryLocks(), and TransactionIdIsValid.
Referenced by StandbyReleaseLockTree().
| void StandbyReleaseLockTree | ( | TransactionId | xid, |
| int | nsubxids, | ||
| TransactionId * | subxids | ||
| ) |
Definition at line 1094 of file standby.c.
References fb(), i, and StandbyReleaseLocks().
Referenced by RecoverPreparedTransactions(), xact_redo_abort(), and xact_redo_commit().
| void StandbyReleaseOldLocks | ( | TransactionId | oldxid | ) |
Definition at line 1132 of file standby.c.
References Assert, fb(), HASH_REMOVE, hash_search(), hash_seq_init(), hash_seq_search(), RecoveryLockXidHash, StandbyReleaseXidEntryLocks(), StandbyTransactionIdIsPrepared(), TransactionIdIsValid, TransactionIdPrecedes(), and RecoveryLockXidEntry::xid.
Referenced by ProcArrayApplyRecoveryInfo().
|
static |
Definition at line 1037 of file standby.c.
References AccessExclusiveLock, Assert, xl_standby_lock::dbOid, DEBUG4, elog, fb(), HASH_REMOVE, hash_search(), RecoveryLockEntry::key, LockRelease(), LOG, next, RecoveryLockEntry::next, RecoveryLockHash, xl_standby_lock::relOid, SET_LOCKTAG_RELATION, and xl_standby_lock::xid.
Referenced by StandbyReleaseAllLocks(), StandbyReleaseLocks(), and StandbyReleaseOldLocks().
Definition at line 947 of file standby.c.
References got_standby_delay_timeout.
Referenced by StartupProcessMain().
Definition at line 235 of file standby.c.
References CHECK_FOR_INTERRUPTS, fb(), GetCurrentTimestamp(), GetStandbyLimitTime(), pg_usleep(), pgstat_report_wait_end(), pgstat_report_wait_start(), and standbyWait_us.
Referenced by ResolveRecoveryConflictWithVirtualXIDs().
|
static |
Definition at line 70 of file standby.c.
Referenced by ResolveRecoveryConflictWithBufferPin(), ResolveRecoveryConflictWithLock(), and StandbyDeadLockHandler().
|
static |
Definition at line 71 of file standby.c.
Referenced by ResolveRecoveryConflictWithBufferPin(), and StandbyTimeoutHandler().
|
static |
Definition at line 72 of file standby.c.
Referenced by ResolveRecoveryConflictWithLock(), and StandbyLockTimeoutHandler().
Definition at line 43 of file standby.c.
Referenced by LockBufferForCleanup(), ProcSleep(), and ResolveRecoveryConflictWithVirtualXIDs().
| int max_standby_archive_delay = 30 * 1000 |
Definition at line 41 of file standby.c.
Referenced by GetStandbyLimitTime().
| int max_standby_streaming_delay = 30 * 1000 |
Definition at line 42 of file standby.c.
Referenced by GetStandbyLimitTime().
Definition at line 66 of file standby.c.
Referenced by InitRecoveryTransactionEnvironment(), ShutdownRecoveryTransactionEnvironment(), StandbyAcquireAccessExclusiveLock(), and StandbyReleaseXidEntryLocks().
Definition at line 67 of file standby.c.
Referenced by InitRecoveryTransactionEnvironment(), ShutdownRecoveryTransactionEnvironment(), StandbyAcquireAccessExclusiveLock(), StandbyReleaseAllLocks(), StandbyReleaseLocks(), and StandbyReleaseOldLocks().
|
static |
Definition at line 227 of file standby.c.
Referenced by ResolveRecoveryConflictWithVirtualXIDs(), and WaitExceedsMaxStandbyDelay().