PostgreSQL Source Code
git master
|
#include "postgres.h"
#include "access/subtrans.h"
#include "access/transam.h"
#include "access/xact.h"
#include "catalog/catalog.h"
#include "commands/progress.h"
#include "miscadmin.h"
#include "pgstat.h"
#include "storage/lmgr.h"
#include "storage/proc.h"
#include "storage/procarray.h"
#include "storage/sinvaladt.h"
#include "utils/inval.h"
Go to the source code of this file.
Data Structures | |
struct | XactLockTableWaitInfo |
Typedefs | |
typedef struct XactLockTableWaitInfo | XactLockTableWaitInfo |
Variables | |
static uint32 | speculativeInsertionToken = 0 |
typedef struct XactLockTableWaitInfo XactLockTableWaitInfo |
Definition at line 331 of file lmgr.c.
References LockRelId::dbId, elog(), GetLockmodeName(), LockHeldByMe(), LockInfoData::lockRelId, LOCKTAG::locktag_lockmethodid, MaxLockMode, RelationData::rd_lockInfo, RelationGetRelationName, LockRelId::relId, SET_LOCKTAG_RELATION, and WARNING.
Referenced by addRangeTableEntryForRelation(), ExecGetRangeTableRelation(), relation_open(), and try_relation_open().
bool ConditionalLockPage | ( | Relation | relation, |
BlockNumber | blkno, | ||
LOCKMODE | lockmode | ||
) |
Definition at line 533 of file lmgr.c.
References LockRelId::dbId, LockAcquire(), LOCKACQUIRE_NOT_AVAIL, LockInfoData::lockRelId, RelationData::rd_lockInfo, LockRelId::relId, and SET_LOCKTAG_PAGE.
Referenced by ginInsertCleanup().
Definition at line 276 of file lmgr.c.
References AcceptInvalidationMessages(), LockRelId::dbId, LOCKACQUIRE_ALREADY_CLEAR, LOCKACQUIRE_NOT_AVAIL, LockAcquireExtended(), LockInfoData::lockRelId, MarkLockClear(), RelationData::rd_lockInfo, LockRelId::relId, res, and SET_LOCKTAG_RELATION.
Referenced by lazy_truncate_heap().
Definition at line 449 of file lmgr.c.
References LockRelId::dbId, LockAcquire(), LOCKACQUIRE_NOT_AVAIL, LockInfoData::lockRelId, RelationData::rd_lockInfo, LockRelId::relId, and SET_LOCKTAG_RELATION_EXTEND.
Definition at line 152 of file lmgr.c.
References AcceptInvalidationMessages(), LOCKACQUIRE_ALREADY_CLEAR, LOCKACQUIRE_NOT_AVAIL, LockAcquireExtended(), MarkLockClear(), res, and SetLocktagRelationOid().
Referenced by AlterTableMoveAll(), do_autovacuum(), LockTableRecurse(), LockViewRecurse_walker(), RangeVarGetRelidExtended(), and vacuum_open_relation().
bool ConditionalLockTuple | ( | Relation | relation, |
ItemPointer | tid, | ||
LOCKMODE | lockmode | ||
) |
Definition at line 589 of file lmgr.c.
References LockRelId::dbId, ItemPointerGetBlockNumber(), ItemPointerGetOffsetNumber(), LockAcquire(), LOCKACQUIRE_NOT_AVAIL, LockInfoData::lockRelId, RelationData::rd_lockInfo, LockRelId::relId, and SET_LOCKTAG_TUPLE.
bool ConditionalXactLockTableWait | ( | TransactionId | xid | ) |
Definition at line 741 of file lmgr.c.
References Assert(), GetTopTransactionIdIfAny(), LockAcquire(), LOCKACQUIRE_NOT_AVAIL, LockRelease(), pg_usleep(), SET_LOCKTAG_TRANSACTION, ShareLock, SubTransGetTopmostTransaction(), TransactionIdEquals, TransactionIdIsInProgress(), and TransactionIdIsValid.
Referenced by Do_MultiXactIdWait(), heap_lock_tuple(), and heapam_tuple_lock().
void DescribeLockTag | ( | StringInfo | buf, |
const LOCKTAG * | tag | ||
) |
Definition at line 1168 of file lmgr.c.
References _, appendStringInfo(), buf, LOCKTAG_ADVISORY, LOCKTAG_APPLY_TRANSACTION, LOCKTAG_DATABASE_FROZEN_IDS, LOCKTAG::locktag_field1, LOCKTAG::locktag_field2, LOCKTAG::locktag_field3, LOCKTAG::locktag_field4, LOCKTAG_OBJECT, LOCKTAG_PAGE, LOCKTAG_RELATION, LOCKTAG_RELATION_EXTEND, LOCKTAG_SPECULATIVE_TOKEN, LOCKTAG_TRANSACTION, LOCKTAG_TUPLE, LOCKTAG::locktag_type, LOCKTAG_USERLOCK, and LOCKTAG_VIRTUALTRANSACTION.
Referenced by DeadLockReport(), and ProcSleep().
const char* GetLockNameFromTagType | ( | uint16 | locktag_type | ) |
Definition at line 1265 of file lmgr.c.
References LOCKTAG_LAST_TYPE, and LockTagTypeNames.
Referenced by pgstat_get_wait_event().
void LockApplyTransactionForSession | ( | Oid | suboid, |
TransactionId | xid, | ||
uint16 | objid, | ||
LOCKMODE | lockmode | ||
) |
Definition at line 1128 of file lmgr.c.
References LockAcquire(), MyDatabaseId, and SET_LOCKTAG_APPLY_TRANSACTION.
Referenced by pa_lock_stream(), and pa_lock_transaction().
void LockDatabaseFrozenIds | ( | LOCKMODE | lockmode | ) |
Definition at line 498 of file lmgr.c.
References LockAcquire(), MyDatabaseId, and SET_LOCKTAG_DATABASE_FROZEN_IDS.
Referenced by vac_update_datfrozenxid().
Definition at line 1005 of file lmgr.c.
References AcceptInvalidationMessages(), LockAcquire(), MyDatabaseId, and SET_LOCKTAG_OBJECT.
Referenced by AcquireDeletionLock(), AddEnumLabel(), AlterPublication(), AlterPublicationOptions(), get_object_address(), LockSchemaList(), RangeVarGetAndCheckCreationNamespace(), and RenameEnumLabel().
Definition at line 374 of file lmgr.c.
References LockRelId::dbId, LockHasWaiters(), LockInfoData::lockRelId, RelationData::rd_lockInfo, LockRelId::relId, and SET_LOCKTAG_RELATION.
Referenced by count_nondeletable_pages().
void LockPage | ( | Relation | relation, |
BlockNumber | blkno, | ||
LOCKMODE | lockmode | ||
) |
Definition at line 514 of file lmgr.c.
References LockRelId::dbId, LockAcquire(), LockInfoData::lockRelId, RelationData::rd_lockInfo, LockRelId::relId, and SET_LOCKTAG_PAGE.
Referenced by ginInsertCleanup().
Definition at line 245 of file lmgr.c.
References AcceptInvalidationMessages(), LockRelId::dbId, LOCKACQUIRE_ALREADY_CLEAR, LockAcquireExtended(), LockInfoData::lockRelId, MarkLockClear(), RelationData::rd_lockInfo, LockRelId::relId, res, and SET_LOCKTAG_RELATION.
Referenced by index_create().
Definition at line 431 of file lmgr.c.
References LockRelId::dbId, LockAcquire(), LockInfoData::lockRelId, RelationData::rd_lockInfo, LockRelId::relId, and SET_LOCKTAG_RELATION_EXTEND.
Referenced by brin_getinsertbuffer(), brin_page_cleanup(), btvacuumscan(), ExtendBufferedRelShared(), ExtendBufferedRelTo(), ginvacuumcleanup(), gistvacuumscan(), pgstat_index(), and spgvacuumscan().
Definition at line 185 of file lmgr.c.
References AcceptInvalidationMessages(), LockRelId::dbId, LOCKACQUIRE_ALREADY_CLEAR, LockAcquireExtended(), MarkLockClear(), LockRelId::relId, res, and SET_LOCKTAG_RELATION.
Referenced by CreateDatabaseUsingWalLog(), and ScanSourceDatabasePgClass().
Definition at line 398 of file lmgr.c.
References LockRelId::dbId, LockAcquire(), LockRelId::relId, and SET_LOCKTAG_RELATION.
Referenced by DefineIndex(), index_drop(), ReindexRelationConcurrently(), and vacuum_rel().
Definition at line 109 of file lmgr.c.
References AcceptInvalidationMessages(), LOCKACQUIRE_ALREADY_CLEAR, LockAcquireExtended(), MarkLockClear(), res, and SetLocktagRelationOid().
Referenced by AcquireDeletionLock(), AcquireExecutorLocks(), AlterTableMoveAll(), ATExecAttachPartition(), ATExecDetachPartition(), ATPostAlterTypeCleanup(), copy_table_data(), CreateTriggerFiringOn(), ExecRefreshMatView(), find_inheritance_children_extended(), heap_drop_with_catalog(), InitCatCachePhase2(), load_critical_index(), lock_and_open_sequence(), LockTableRecurse(), LockViewRecurse_walker(), LogicalRepSyncTableStart(), pg_replication_origin_advance(), RangeVarCallbackForAttachIndex(), RangeVarCallbackForDropRelation(), RangeVarCallbackForReindexIndex(), RangeVarGetAndCheckCreationNamespace(), RangeVarGetRelidExtended(), relation_open(), ScanQueryForLocks(), and try_relation_open().
Definition at line 1046 of file lmgr.c.
References AcceptInvalidationMessages(), InvalidOid, LockAcquire(), and SET_LOCKTAG_OBJECT.
Referenced by AcquireDeletionLock(), AddRoleMems(), AddSubscriptionRelState(), AlterSubscription(), clear_subscription_skip_lsn(), createdb(), DelRoleMems(), DisableSubscription(), DropRole(), DropSubscription(), get_db_info(), get_object_address(), InitPostgres(), PreCommit_Notify(), replorigin_drop_by_name(), shdepLockAndCheckObject(), and UpdateSubscriptionRelState().
Definition at line 1088 of file lmgr.c.
References InvalidOid, LockAcquire(), and SET_LOCKTAG_OBJECT.
Referenced by dbase_redo(), and movedb().
void LockTuple | ( | Relation | relation, |
ItemPointer | tid, | ||
LOCKMODE | lockmode | ||
) |
Definition at line 569 of file lmgr.c.
References LockRelId::dbId, ItemPointerGetBlockNumber(), ItemPointerGetOffsetNumber(), LockAcquire(), LockInfoData::lockRelId, RelationData::rd_lockInfo, LockRelId::relId, and SET_LOCKTAG_TUPLE.
int RelationExtensionLockWaiterCount | ( | Relation | relation | ) |
Definition at line 466 of file lmgr.c.
References LockRelId::dbId, LockInfoData::lockRelId, LockWaiterCount(), RelationData::rd_lockInfo, LockRelId::relId, and SET_LOCKTAG_RELATION_EXTEND.
Referenced by RelationAddBlocks().
void RelationInitLockInfo | ( | Relation | relation | ) |
Definition at line 72 of file lmgr.c.
References Assert(), LockRelId::dbId, InvalidOid, LockInfoData::lockRelId, MyDatabaseId, OidIsValid, RelationData::rd_lockInfo, RelationData::rd_rel, RelationGetRelid, RelationIsValid, and LockRelId::relId.
Referenced by formrdesc(), load_relcache_init_file(), RelationBuildDesc(), and RelationBuildLocalRelation().
Definition at line 90 of file lmgr.c.
References InvalidOid, IsSharedRelation(), MyDatabaseId, and SET_LOCKTAG_RELATION.
Referenced by ConditionalLockRelationOid(), LockRelationOid(), and UnlockRelationOid().
uint32 SpeculativeInsertionLockAcquire | ( | TransactionId | xid | ) |
Definition at line 783 of file lmgr.c.
References ExclusiveLock, LockAcquire(), SET_LOCKTAG_SPECULATIVE_INSERTION, and speculativeInsertionToken.
Referenced by ExecInsert().
void SpeculativeInsertionLockRelease | ( | TransactionId | xid | ) |
Definition at line 809 of file lmgr.c.
References ExclusiveLock, LockRelease(), SET_LOCKTAG_SPECULATIVE_INSERTION, and speculativeInsertionToken.
Referenced by ExecInsert().
void SpeculativeInsertionWait | ( | TransactionId | xid, |
uint32 | token | ||
) |
Definition at line 825 of file lmgr.c.
References Assert(), LockAcquire(), LockRelease(), SET_LOCKTAG_SPECULATIVE_INSERTION, ShareLock, token, and TransactionIdIsValid.
Referenced by _bt_doinsert(), and check_exclusion_or_unique_constraint().
void UnlockApplyTransactionForSession | ( | Oid | suboid, |
TransactionId | xid, | ||
uint16 | objid, | ||
LOCKMODE | lockmode | ||
) |
Definition at line 1146 of file lmgr.c.
References LockRelease(), MyDatabaseId, and SET_LOCKTAG_APPLY_TRANSACTION.
Referenced by pa_unlock_stream(), and pa_unlock_transaction().
Definition at line 1026 of file lmgr.c.
References LockRelease(), MyDatabaseId, and SET_LOCKTAG_OBJECT.
Referenced by get_object_address(), RangeVarGetAndCheckCreationNamespace(), and ReleaseDeletionLock().
void UnlockPage | ( | Relation | relation, |
BlockNumber | blkno, | ||
LOCKMODE | lockmode | ||
) |
Definition at line 549 of file lmgr.c.
References LockRelId::dbId, LockRelease(), LockInfoData::lockRelId, RelationData::rd_lockInfo, LockRelId::relId, and SET_LOCKTAG_PAGE.
Referenced by ginInsertCleanup().
Definition at line 311 of file lmgr.c.
References LockRelId::dbId, LockRelease(), LockInfoData::lockRelId, RelationData::rd_lockInfo, LockRelId::relId, and SET_LOCKTAG_RELATION.
Referenced by lazy_truncate_heap().
Definition at line 481 of file lmgr.c.
References LockRelId::dbId, LockRelease(), LockInfoData::lockRelId, RelationData::rd_lockInfo, LockRelId::relId, and SET_LOCKTAG_RELATION_EXTEND.
Referenced by brin_getinsertbuffer(), brin_page_cleanup(), btvacuumscan(), ExtendBufferedRelShared(), ExtendBufferedRelTo(), ginvacuumcleanup(), gistvacuumscan(), pgstat_index(), and spgvacuumscan().
Definition at line 213 of file lmgr.c.
References LockRelId::dbId, LockRelease(), LockRelId::relId, and SET_LOCKTAG_RELATION.
Referenced by CreateDatabaseUsingWalLog(), index_close(), relation_close(), and ScanSourceDatabasePgClass().
Definition at line 411 of file lmgr.c.
References LockRelId::dbId, LockRelease(), LockRelId::relId, and SET_LOCKTAG_RELATION.
Referenced by DefineIndex(), index_drop(), ReindexRelationConcurrently(), and vacuum_rel().
Definition at line 228 of file lmgr.c.
References LockRelease(), and SetLocktagRelationOid().
Referenced by AcquireExecutorLocks(), do_autovacuum(), expand_vacuum_rel(), find_inheritance_children_extended(), InitCatCachePhase2(), load_critical_index(), LockTableRecurse(), LogicalRepSyncTableStart(), pg_replication_origin_advance(), RangeVarCallbackForAttachIndex(), RangeVarCallbackForDropRelation(), RangeVarCallbackForReindexIndex(), RangeVarGetAndCheckCreationNamespace(), RangeVarGetRelidExtended(), ReleaseDeletionLock(), RenameRelation(), ScanQueryForLocks(), and try_relation_open().
Definition at line 1067 of file lmgr.c.
References InvalidOid, LockRelease(), and SET_LOCKTAG_OBJECT.
Referenced by AlterDatabaseSet(), createdb_failure_callback(), get_db_info(), get_object_address(), and replorigin_drop_by_name().
Definition at line 1106 of file lmgr.c.
References InvalidOid, LockRelease(), and SET_LOCKTAG_OBJECT.
Referenced by dbase_redo(), and movedb().
void UnlockTuple | ( | Relation | relation, |
ItemPointer | tid, | ||
LOCKMODE | lockmode | ||
) |
Definition at line 606 of file lmgr.c.
References LockRelId::dbId, ItemPointerGetBlockNumber(), ItemPointerGetOffsetNumber(), LockRelease(), LockInfoData::lockRelId, RelationData::rd_lockInfo, LockRelId::relId, and SET_LOCKTAG_TUPLE.
Definition at line 986 of file lmgr.c.
References list_free(), list_make1, progress, and WaitForLockersMultiple().
Referenced by DefineIndex(), and index_drop().
Definition at line 908 of file lmgr.c.
References VirtualTransactionId::backendId, BackendIdGetProc(), GetLockConflicts(), lappend(), lfirst, list_free_deep(), NIL, pgstat_progress_update_multi_param(), pgstat_progress_update_param(), PGPROC::pid, progress, PROGRESS_WAITFOR_CURRENT_PID, PROGRESS_WAITFOR_DONE, PROGRESS_WAITFOR_TOTAL, values, VirtualTransactionIdIsValid, and VirtualXactLock().
Referenced by ATExecDetachPartition(), ReindexRelationConcurrently(), and WaitForLockers().
void XactLockTableDelete | ( | TransactionId | xid | ) |
Definition at line 644 of file lmgr.c.
References ExclusiveLock, LockRelease(), and SET_LOCKTAG_TRANSACTION.
Referenced by CommitSubTransaction().
void XactLockTableInsert | ( | TransactionId | xid | ) |
Definition at line 627 of file lmgr.c.
References ExclusiveLock, LockAcquire(), and SET_LOCKTAG_TRANSACTION.
Referenced by AssignTransactionId().
void XactLockTableWait | ( | TransactionId | xid, |
Relation | rel, | ||
ItemPointer | ctid, | ||
XLTW_Oper | oper | ||
) |
Definition at line 668 of file lmgr.c.
References Assert(), callback(), XactLockTableWaitInfo::ctid, error_context_stack, GetTopTransactionIdIfAny(), ItemPointerIsValid(), LockAcquire(), LockRelease(), oper(), XactLockTableWaitInfo::oper, pg_usleep(), XactLockTableWaitInfo::rel, RelationIsValid, SET_LOCKTAG_TRANSACTION, ShareLock, SubTransGetTopmostTransaction(), TransactionIdEquals, TransactionIdIsInProgress(), TransactionIdIsValid, XactLockTableWaitErrorCb(), and XLTW_None.
Referenced by _bt_doinsert(), check_exclusion_or_unique_constraint(), Do_MultiXactIdWait(), heap_delete(), heap_lock_tuple(), heap_lock_updated_tuple_rec(), heap_update(), heapam_index_build_range_scan(), heapam_tuple_lock(), RelationFindReplTupleByIndex(), RelationFindReplTupleSeq(), and SnapBuildWaitSnapshot().
|
static |
Definition at line 843 of file lmgr.c.
References arg, XactLockTableWaitInfo::ctid, errcontext, gettext_noop, ItemPointerGetBlockNumber(), ItemPointerGetOffsetNumber(), ItemPointerIsValid(), XactLockTableWaitInfo::oper, XactLockTableWaitInfo::rel, RelationGetRelationName, RelationIsValid, XLTW_Delete, XLTW_FetchUpdated, XLTW_InsertIndex, XLTW_InsertIndexUnique, XLTW_Lock, XLTW_LockUpdated, XLTW_None, XLTW_RecheckExclusionConstr, and XLTW_Update.
Referenced by XactLockTableWait().
|
static |
Definition at line 47 of file lmgr.c.
Referenced by SpeculativeInsertionLockAcquire(), and SpeculativeInsertionLockRelease().