PostgreSQL Source Code git master
|
#include "postgres.h"
#include "access/subtrans.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 "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 334 of file lmgr.c.
References LockRelId::dbId, LockHeldByMe(), LockInfoData::lockRelId, RelationData::rd_lockInfo, LockRelId::relId, and SET_LOCKTAG_RELATION.
Referenced by addFkRecurseReferenced(), addFkRecurseReferencing(), addRangeTableEntryForRelation(), cluster_rel(), ExecGetRangeTableRelation(), rebuild_relation(), relation_open(), and try_relation_open().
Definition at line 351 of file lmgr.c.
References LockHeldByMe(), and SetLocktagRelationOid().
Referenced by ATRewriteTable(), build_index_value_desc(), ExecCheckPermissions(), rebuild_relation(), RefreshMatViewByOid(), ReportApplyConflict(), and SetRelationHasSubclass().
Definition at line 1026 of file lmgr.c.
References AcceptInvalidationMessages(), LOCKACQUIRE_ALREADY_CLEAR, LOCKACQUIRE_NOT_AVAIL, LockAcquireExtended(), MarkLockClear(), MyDatabaseId, and SET_LOCKTAG_OBJECT.
Referenced by do_autovacuum().
bool ConditionalLockPage | ( | Relation | relation, |
BlockNumber | blkno, | ||
LOCKMODE | lockmode | ||
) |
Definition at line 526 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 278 of file lmgr.c.
References AcceptInvalidationMessages(), LockRelId::dbId, LOCKACQUIRE_ALREADY_CLEAR, LOCKACQUIRE_NOT_AVAIL, LockAcquireExtended(), LockInfoData::lockRelId, MarkLockClear(), RelationData::rd_lockInfo, LockRelId::relId, and SET_LOCKTAG_RELATION.
Referenced by lazy_truncate_heap().
Definition at line 442 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 151 of file lmgr.c.
References AcceptInvalidationMessages(), LOCKACQUIRE_ALREADY_CLEAR, LOCKACQUIRE_NOT_AVAIL, LockAcquireExtended(), MarkLockClear(), and SetLocktagRelationOid().
Referenced by AlterTableMoveAll(), do_autovacuum(), LockTableRecurse(), LockViewRecurse_walker(), RangeVarGetRelidExtended(), and vacuum_open_relation().
Definition at line 1106 of file lmgr.c.
References AcceptInvalidationMessages(), InvalidOid, LOCKACQUIRE_ALREADY_CLEAR, LOCKACQUIRE_NOT_AVAIL, LockAcquireExtended(), MarkLockClear(), and SET_LOCKTAG_OBJECT.
Referenced by EventTriggerOnLogin().
bool ConditionalLockTuple | ( | Relation | relation, |
ItemPointer | tid, | ||
LOCKMODE | lockmode, | ||
bool | logLockFailure | ||
) |
Definition at line 582 of file lmgr.c.
References LockRelId::dbId, ItemPointerGetBlockNumber(), ItemPointerGetOffsetNumber(), LOCKACQUIRE_NOT_AVAIL, LockAcquireExtended(), LockInfoData::lockRelId, RelationData::rd_lockInfo, LockRelId::relId, and SET_LOCKTAG_TUPLE.
bool ConditionalXactLockTableWait | ( | TransactionId | xid, |
bool | logLockFailure | ||
) |
Definition at line 736 of file lmgr.c.
References Assert(), GetTopTransactionIdIfAny(), LOCKACQUIRE_NOT_AVAIL, LockAcquireExtended(), 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 1243 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(), LockAcquireExtended(), and ProcSleep().
const char * GetLockNameFromTagType | ( | uint16 | locktag_type | ) |
Definition at line 1340 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 1203 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 491 of file lmgr.c.
References LockAcquire(), MyDatabaseId, and SET_LOCKTAG_DATABASE_FROZEN_IDS.
Referenced by vac_update_datfrozenxid().
Definition at line 1002 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 367 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 507 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 246 of file lmgr.c.
References AcceptInvalidationMessages(), LockRelId::dbId, LOCKACQUIRE_ALREADY_CLEAR, LockAcquireExtended(), LockInfoData::lockRelId, MarkLockClear(), RelationData::rd_lockInfo, LockRelId::relId, and SET_LOCKTAG_RELATION.
Referenced by index_create().
Definition at line 424 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, and SET_LOCKTAG_RELATION.
Referenced by CreateDatabaseUsingWalLog(), and ScanSourceDatabasePgClass().
Definition at line 391 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 107 of file lmgr.c.
References AcceptInvalidationMessages(), LOCKACQUIRE_ALREADY_CLEAR, LockAcquireExtended(), MarkLockClear(), and SetLocktagRelationOid().
Referenced by AcquireDeletionLock(), AcquireExecutorLocks(), AlterTableMoveAll(), ATExecAttachPartition(), ATExecDetachPartition(), ATPostAlterTypeCleanup(), binary_upgrade_replorigin_advance(), copy_table_data(), CreateTriggerFiringOn(), ExecDoInitialPruning(), find_inheritance_children_extended(), heap_create_with_catalog(), heap_drop_with_catalog(), index_create(), IndexSetParentIndex(), InitCatCachePhase2(), load_critical_index(), lock_and_open_sequence(), LockTableRecurse(), LockViewRecurse_walker(), LogicalRepSyncTableStart(), pg_replication_origin_advance(), RangeVarCallbackForAttachIndex(), RangeVarCallbackForDropRelation(), RangeVarCallbackForReindexIndex(), RangeVarGetAndCheckCreationNamespace(), RangeVarGetRelidExtended(), relation_open(), ScanQueryForLocks(), SequenceChangePersistence(), and try_relation_open().
Definition at line 1082 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(), drop_local_obsolete_slots(), DropRole(), DropSubscription(), get_db_info(), get_object_address(), InitPostgres(), PreCommit_Notify(), replorigin_drop_by_name(), SetDatabaseHasLoginEventTriggers(), shdepLockAndCheckObject(), synchronize_slots(), and UpdateSubscriptionRelState().
Definition at line 1163 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 562 of file lmgr.c.
References LockRelId::dbId, ItemPointerGetBlockNumber(), ItemPointerGetOffsetNumber(), LockAcquire(), LockInfoData::lockRelId, RelationData::rd_lockInfo, LockRelId::relId, and SET_LOCKTAG_TUPLE.
Referenced by AlterDatabase(), AlterDatabaseOwner(), AlterDatabaseRefreshColl(), ExecMergeMatched(), ExecModifyTable(), ExecUpdate(), get_catalog_object_by_oid_extended(), heap_inplace_lock(), and movedb().
int RelationExtensionLockWaiterCount | ( | Relation | relation | ) |
Definition at line 459 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 70 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 88 of file lmgr.c.
References InvalidOid, IsSharedRelation(), MyDatabaseId, and SET_LOCKTAG_RELATION.
Referenced by CheckRelationOidLockedByMe(), ConditionalLockRelationOid(), LockRelationOid(), and UnlockRelationOid().
uint32 SpeculativeInsertionLockAcquire | ( | TransactionId | xid | ) |
Definition at line 780 of file lmgr.c.
References ExclusiveLock, LockAcquire(), SET_LOCKTAG_SPECULATIVE_INSERTION, and speculativeInsertionToken.
Referenced by ExecInsert().
void SpeculativeInsertionLockRelease | ( | TransactionId | xid | ) |
Definition at line 806 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 822 of file lmgr.c.
References Assert(), LockAcquire(), LockRelease(), SET_LOCKTAG_SPECULATIVE_INSERTION, ShareLock, 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 1221 of file lmgr.c.
References LockRelease(), MyDatabaseId, and SET_LOCKTAG_APPLY_TRANSACTION.
Referenced by pa_unlock_stream(), and pa_unlock_transaction().
Definition at line 1062 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 542 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 314 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 474 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 214 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 404 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 229 of file lmgr.c.
References LockRelease(), and SetLocktagRelationOid().
Referenced by AcquireExecutorLocks(), binary_upgrade_replorigin_advance(), do_autovacuum(), ExecDoInitialPruning(), 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 1142 of file lmgr.c.
References InvalidOid, LockRelease(), and SET_LOCKTAG_OBJECT.
Referenced by AddSubscriptionRelState(), AlterDatabaseSet(), createdb_failure_callback(), drop_local_obsolete_slots(), get_db_info(), get_object_address(), replorigin_drop_by_name(), and synchronize_slots().
Definition at line 1181 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 601 of file lmgr.c.
References LockRelId::dbId, ItemPointerGetBlockNumber(), ItemPointerGetOffsetNumber(), LockRelease(), LockInfoData::lockRelId, RelationData::rd_lockInfo, LockRelId::relId, and SET_LOCKTAG_TUPLE.
Referenced by AlterDatabase(), AlterDatabaseOwner(), AlterDatabaseRefreshColl(), AlterObjectOwner_internal(), AlterRelationNamespaceInternal(), ATExecSetRelOptions(), ExecGrant_common(), ExecGrant_Relation(), ExecMergeMatched(), ExecModifyTable(), ExecUpdate(), heap_inplace_lock(), heap_inplace_unlock(), heap_inplace_update_and_unlock(), movedb(), RelationSetNewRelfilenumber(), RenameDatabase(), RenameRelationInternal(), SetDatabaseHasLoginEventTriggers(), SetRelationTableSpace(), and update_relispartition().
Definition at line 983 of file lmgr.c.
References list_free(), list_make1, progress, and WaitForLockersMultiple().
Referenced by DefineIndex(), and index_drop().
Definition at line 905 of file lmgr.c.
References GetLockConflicts(), lappend(), lfirst, list_free_deep(), NIL, pgstat_progress_update_multi_param(), pgstat_progress_update_param(), PGPROC::pid, VirtualTransactionId::procNumber, ProcNumberGetProc(), 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 639 of file lmgr.c.
References ExclusiveLock, LockRelease(), and SET_LOCKTAG_TRANSACTION.
Referenced by CommitSubTransaction().
void XactLockTableInsert | ( | TransactionId | xid | ) |
Definition at line 622 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 663 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_inplace_lock(), 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 840 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 45 of file lmgr.c.
Referenced by SpeculativeInsertionLockAcquire(), and SpeculativeInsertionLockRelease().