|
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"
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 905 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 1493 of file standby.c.
References _, fb(), PROCSIG_RECOVERY_CONFLICT_BUFFERPIN, PROCSIG_RECOVERY_CONFLICT_DATABASE, PROCSIG_RECOVERY_CONFLICT_LOCK, PROCSIG_RECOVERY_CONFLICT_LOGICALSLOT, PROCSIG_RECOVERY_CONFLICT_SNAPSHOT, PROCSIG_RECOVERY_CONFLICT_STARTUP_DEADLOCK, and PROCSIG_RECOVERY_CONFLICT_TABLESPACE.
Referenced by LogRecoveryConflict().
|
static |
Definition at line 201 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 95 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 1432 of file standby.c.
References fb(), GetCurrentTransactionId(), LogAccessExclusiveLocks(), MyXactFlags, XACT_FLAGS_ACQUIREDACCESSEXCLUSIVELOCK, and xl_standby_lock::xid.
Referenced by LockAcquireExtended().
Definition at line 1449 of file standby.c.
References fb(), and GetCurrentTransactionId().
Referenced by LockAcquireExtended().
|
static |
Definition at line 1414 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 1354 of file standby.c.
References DEBUG2, elog, fb(), LSN_FORMAT_ARGS, MinSizeOfXactRunningXacts, SUBXIDS_IN_ARRAY, xl_running_xacts::xcnt, XLOG_MARK_UNIMPORTANT, XLOG_RUNNING_XACTS, XLogBeginInsert(), XLogInsert(), XLogRegisterData(), XLogSetAsyncXactLSN(), and XLogSetRecordFlags().
Referenced by LogStandbySnapshot().
| void LogRecoveryConflict | ( | ProcSignalReason | reason, |
| TimestampTz | wait_start, | ||
| TimestampTz | now, | ||
| VirtualTransactionId * | wait_list, | ||
| bool | still_waiting | ||
| ) |
Definition at line 274 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 1471 of file standby.c.
References fb(), MinSizeOfInvalidations, MyDatabaseId, MyDatabaseTableSpace, XLOG_INVALIDATIONS, XLogBeginInsert(), XLogInsert(), and XLogRegisterData().
Referenced by RecordTransactionCommit().
| XLogRecPtr LogStandbySnapshot | ( | void | ) |
Definition at line 1282 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(), and SnapBuildWaitSnapshot().
Definition at line 793 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, PROCSIG_RECOVERY_CONFLICT_BUFFERPIN, PROCSIG_RECOVERY_CONFLICT_STARTUP_DEADLOCK, ProcWaitForSignal(), SendRecoveryConflictWithBufferPin(), STANDBY_DEADLOCK_TIMEOUT, STANDBY_TIMEOUT, TMPARAM_AFTER, and TMPARAM_AT.
Referenced by LockBufferForCleanup().
Definition at line 569 of file standby.c.
References CancelDBBackends(), CountDBBackends(), pg_usleep(), and PROCSIG_RECOVERY_CONFLICT_DATABASE.
Referenced by dbase_redo().
Definition at line 623 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, PROCSIG_RECOVERY_CONFLICT_LOCK, PROCSIG_RECOVERY_CONFLICT_STARTUP_DEADLOCK, ProcWaitForSignal(), ResolveRecoveryConflictWithVirtualXIDs(), SignalVirtualTransaction(), 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 468 of file standby.c.
References Assert, RelFileLocator::dbOid, fb(), GetConflictingVirtualXIDs(), InvalidateObsoleteReplicationSlots(), IsLogicalDecodingEnabled(), PROCSIG_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(), heap_xlog_visible(), ResolveRecoveryConflictWithSnapshotFullXid(), and spgRedoVacuumRedirect().
| void ResolveRecoveryConflictWithSnapshotFullXid | ( | FullTransactionId | snapshotConflictHorizon, |
| bool | isCatalogRel, | ||
| RelFileLocator | locator | ||
| ) |
Definition at line 512 of file standby.c.
References fb(), MaxTransactionId, ReadNextFullTransactionId(), ResolveRecoveryConflictWithSnapshot(), U64FromFullTransactionId, and XidFromFullTransactionId.
Referenced by btree_xlog_reuse_page(), and gistRedoPageReuse().
Definition at line 539 of file standby.c.
References fb(), GetConflictingVirtualXIDs(), InvalidOid, InvalidTransactionId, PROCSIG_RECOVERY_CONFLICT_TABLESPACE, and ResolveRecoveryConflictWithVirtualXIDs().
Referenced by tblspc_redo().
|
static |
Definition at line 360 of file standby.c.
References Assert, CancelVirtualTransaction(), DeadlockTimeout, fb(), GetCurrentTimestamp(), log_recovery_conflict_waits, LogRecoveryConflict(), now(), pg_usleep(), set_ps_display_remove_suffix(), set_ps_display_suffix(), 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 877 of file standby.c.
References Assert, CancelDBBackends(), InvalidOid, PROCSIG_RECOVERY_CONFLICT_BUFFERPIN, and PROCSIG_RECOVERY_CONFLICT_STARTUP_DEADLOCK.
Referenced by ResolveRecoveryConflictWithBufferPin().
Definition at line 161 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 1163 of file standby.c.
References Assert, elog, fb(), i, RunningTransactionsData::latestCompletedXid, RunningTransactionsData::nextXid, 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 986 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 936 of file standby.c.
References got_standby_deadlock_timeout.
Referenced by StartupProcessMain().
Definition at line 954 of file standby.c.
References got_standby_lock_timeout.
Referenced by StartupProcessMain().
Definition at line 1106 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 1068 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 1092 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 1130 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 1035 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 945 of file standby.c.
References got_standby_delay_timeout.
Referenced by StartupProcessMain().
Definition at line 234 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 69 of file standby.c.
Referenced by ResolveRecoveryConflictWithBufferPin(), ResolveRecoveryConflictWithLock(), and StandbyDeadLockHandler().
|
static |
Definition at line 70 of file standby.c.
Referenced by ResolveRecoveryConflictWithBufferPin(), and StandbyTimeoutHandler().
|
static |
Definition at line 71 of file standby.c.
Referenced by ResolveRecoveryConflictWithLock(), and StandbyLockTimeoutHandler().
Definition at line 42 of file standby.c.
Referenced by LockBufferForCleanup(), ProcSleep(), and ResolveRecoveryConflictWithVirtualXIDs().
| int max_standby_archive_delay = 30 * 1000 |
Definition at line 40 of file standby.c.
Referenced by GetStandbyLimitTime().
| int max_standby_streaming_delay = 30 * 1000 |
Definition at line 41 of file standby.c.
Referenced by GetStandbyLimitTime().
Definition at line 65 of file standby.c.
Referenced by InitRecoveryTransactionEnvironment(), ShutdownRecoveryTransactionEnvironment(), StandbyAcquireAccessExclusiveLock(), and StandbyReleaseXidEntryLocks().
Definition at line 66 of file standby.c.
Referenced by InitRecoveryTransactionEnvironment(), ShutdownRecoveryTransactionEnvironment(), StandbyAcquireAccessExclusiveLock(), StandbyReleaseAllLocks(), StandbyReleaseLocks(), and StandbyReleaseOldLocks().
|
static |
Definition at line 226 of file standby.c.
Referenced by ResolveRecoveryConflictWithVirtualXIDs(), and WaitExceedsMaxStandbyDelay().