PostgreSQL Source Code  git master
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
lmgr.h File Reference
#include "lib/stringinfo.h"
#include "storage/itemptr.h"
#include "storage/lock.h"
#include "utils/rel.h"
Include dependency graph for lmgr.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef enum XLTW_Oper XLTW_Oper
 

Enumerations

enum  XLTW_Oper {
  XLTW_None , XLTW_Update , XLTW_Delete , XLTW_Lock ,
  XLTW_LockUpdated , XLTW_InsertIndex , XLTW_InsertIndexUnique , XLTW_FetchUpdated ,
  XLTW_RecheckExclusionConstr
}
 

Functions

void RelationInitLockInfo (Relation relation)
 
void LockRelationOid (Oid relid, LOCKMODE lockmode)
 
void LockRelationId (LockRelId *relid, LOCKMODE lockmode)
 
bool ConditionalLockRelationOid (Oid relid, LOCKMODE lockmode)
 
void UnlockRelationId (LockRelId *relid, LOCKMODE lockmode)
 
void UnlockRelationOid (Oid relid, LOCKMODE lockmode)
 
void LockRelation (Relation relation, LOCKMODE lockmode)
 
bool ConditionalLockRelation (Relation relation, LOCKMODE lockmode)
 
void UnlockRelation (Relation relation, LOCKMODE lockmode)
 
bool CheckRelationLockedByMe (Relation relation, LOCKMODE lockmode, bool orstronger)
 
bool CheckRelationOidLockedByMe (Oid relid, LOCKMODE lockmode, bool orstronger)
 
bool LockHasWaitersRelation (Relation relation, LOCKMODE lockmode)
 
void LockRelationIdForSession (LockRelId *relid, LOCKMODE lockmode)
 
void UnlockRelationIdForSession (LockRelId *relid, LOCKMODE lockmode)
 
void LockRelationForExtension (Relation relation, LOCKMODE lockmode)
 
void UnlockRelationForExtension (Relation relation, LOCKMODE lockmode)
 
bool ConditionalLockRelationForExtension (Relation relation, LOCKMODE lockmode)
 
int RelationExtensionLockWaiterCount (Relation relation)
 
void LockDatabaseFrozenIds (LOCKMODE lockmode)
 
void LockPage (Relation relation, BlockNumber blkno, LOCKMODE lockmode)
 
bool ConditionalLockPage (Relation relation, BlockNumber blkno, LOCKMODE lockmode)
 
void UnlockPage (Relation relation, BlockNumber blkno, LOCKMODE lockmode)
 
void LockTuple (Relation relation, ItemPointer tid, LOCKMODE lockmode)
 
bool ConditionalLockTuple (Relation relation, ItemPointer tid, LOCKMODE lockmode)
 
void UnlockTuple (Relation relation, ItemPointer tid, LOCKMODE lockmode)
 
void XactLockTableInsert (TransactionId xid)
 
void XactLockTableDelete (TransactionId xid)
 
void XactLockTableWait (TransactionId xid, Relation rel, ItemPointer ctid, XLTW_Oper oper)
 
bool ConditionalXactLockTableWait (TransactionId xid)
 
void WaitForLockers (LOCKTAG heaplocktag, LOCKMODE lockmode, bool progress)
 
void WaitForLockersMultiple (List *locktags, LOCKMODE lockmode, bool progress)
 
uint32 SpeculativeInsertionLockAcquire (TransactionId xid)
 
void SpeculativeInsertionLockRelease (TransactionId xid)
 
void SpeculativeInsertionWait (TransactionId xid, uint32 token)
 
void LockDatabaseObject (Oid classid, Oid objid, uint16 objsubid, LOCKMODE lockmode)
 
bool ConditionalLockDatabaseObject (Oid classid, Oid objid, uint16 objsubid, LOCKMODE lockmode)
 
void UnlockDatabaseObject (Oid classid, Oid objid, uint16 objsubid, LOCKMODE lockmode)
 
void LockSharedObject (Oid classid, Oid objid, uint16 objsubid, LOCKMODE lockmode)
 
bool ConditionalLockSharedObject (Oid classid, Oid objid, uint16 objsubid, LOCKMODE lockmode)
 
void UnlockSharedObject (Oid classid, Oid objid, uint16 objsubid, LOCKMODE lockmode)
 
void LockSharedObjectForSession (Oid classid, Oid objid, uint16 objsubid, LOCKMODE lockmode)
 
void UnlockSharedObjectForSession (Oid classid, Oid objid, uint16 objsubid, LOCKMODE lockmode)
 
void LockApplyTransactionForSession (Oid suboid, TransactionId xid, uint16 objid, LOCKMODE lockmode)
 
void UnlockApplyTransactionForSession (Oid suboid, TransactionId xid, uint16 objid, LOCKMODE lockmode)
 
void DescribeLockTag (StringInfo buf, const LOCKTAG *tag)
 
const char * GetLockNameFromTagType (uint16 locktag_type)
 

Typedef Documentation

◆ XLTW_Oper

typedef enum XLTW_Oper XLTW_Oper

Enumeration Type Documentation

◆ XLTW_Oper

enum XLTW_Oper
Enumerator
XLTW_None 
XLTW_Update 
XLTW_Delete 
XLTW_Lock 
XLTW_LockUpdated 
XLTW_InsertIndex 
XLTW_InsertIndexUnique 
XLTW_FetchUpdated 
XLTW_RecheckExclusionConstr 

Definition at line 24 of file lmgr.h.

25 {
26  XLTW_None,
29  XLTW_Lock,
35 } XLTW_Oper;
XLTW_Oper
Definition: lmgr.h:25
@ XLTW_FetchUpdated
Definition: lmgr.h:33
@ XLTW_None
Definition: lmgr.h:26
@ XLTW_Lock
Definition: lmgr.h:29
@ XLTW_Delete
Definition: lmgr.h:28
@ XLTW_InsertIndex
Definition: lmgr.h:31
@ XLTW_LockUpdated
Definition: lmgr.h:30
@ XLTW_RecheckExclusionConstr
Definition: lmgr.h:34
@ XLTW_Update
Definition: lmgr.h:27
@ XLTW_InsertIndexUnique
Definition: lmgr.h:32

Function Documentation

◆ CheckRelationLockedByMe()

bool CheckRelationLockedByMe ( Relation  relation,
LOCKMODE  lockmode,
bool  orstronger 
)

Definition at line 329 of file lmgr.c.

330 {
331  LOCKTAG tag;
332 
334  relation->rd_lockInfo.lockRelId.dbId,
335  relation->rd_lockInfo.lockRelId.relId);
336 
337  return LockHeldByMe(&tag, lockmode, orstronger);
338 }
bool LockHeldByMe(const LOCKTAG *locktag, LOCKMODE lockmode, bool orstronger)
Definition: lock.c:637
#define SET_LOCKTAG_RELATION(locktag, dboid, reloid)
Definition: lock.h:181
Definition: lock.h:165
LockRelId lockRelId
Definition: rel.h:46
Oid relId
Definition: rel.h:40
Oid dbId
Definition: rel.h:41
LockInfoData rd_lockInfo
Definition: rel.h:114

References LockRelId::dbId, LockHeldByMe(), LockInfoData::lockRelId, RelationData::rd_lockInfo, LockRelId::relId, and SET_LOCKTAG_RELATION.

Referenced by addFkRecurseReferenced(), addFkRecurseReferencing(), addRangeTableEntryForRelation(), ExecGetRangeTableRelation(), relation_open(), and try_relation_open().

◆ CheckRelationOidLockedByMe()

bool CheckRelationOidLockedByMe ( Oid  relid,
LOCKMODE  lockmode,
bool  orstronger 
)

Definition at line 346 of file lmgr.c.

347 {
348  LOCKTAG tag;
349 
350  SetLocktagRelationOid(&tag, relid);
351 
352  return LockHeldByMe(&tag, lockmode, orstronger);
353 }
static void SetLocktagRelationOid(LOCKTAG *tag, Oid relid)
Definition: lmgr.c:88

References LockHeldByMe(), and SetLocktagRelationOid().

Referenced by build_index_value_desc(), ReportApplyConflict(), and SetRelationHasSubclass().

◆ ConditionalLockDatabaseObject()

bool ConditionalLockDatabaseObject ( Oid  classid,
Oid  objid,
uint16  objsubid,
LOCKMODE  lockmode 
)

Definition at line 1017 of file lmgr.c.

1019 {
1020  LOCKTAG tag;
1021  LOCALLOCK *locallock;
1023 
1024  SET_LOCKTAG_OBJECT(tag,
1025  MyDatabaseId,
1026  classid,
1027  objid,
1028  objsubid);
1029 
1030  res = LockAcquireExtended(&tag, lockmode, false, true, true, &locallock);
1031 
1032  if (res == LOCKACQUIRE_NOT_AVAIL)
1033  return false;
1034 
1035  /*
1036  * Now that we have the lock, check for invalidation messages; see notes
1037  * in LockRelationOid.
1038  */
1040  {
1042  MarkLockClear(locallock);
1043  }
1044 
1045  return true;
1046 }
Oid MyDatabaseId
Definition: globals.c:93
void AcceptInvalidationMessages(void)
Definition: inval.c:863
LockAcquireResult LockAcquireExtended(const LOCKTAG *locktag, LOCKMODE lockmode, bool sessionLock, bool dontWait, bool reportMemoryError, LOCALLOCK **locallockp)
Definition: lock.c:827
void MarkLockClear(LOCALLOCK *locallock)
Definition: lock.c:1860
#define SET_LOCKTAG_OBJECT(locktag, dboid, classoid, objoid, objsubid)
Definition: lock.h:262
LockAcquireResult
Definition: lock.h:500
@ LOCKACQUIRE_ALREADY_CLEAR
Definition: lock.h:504
@ LOCKACQUIRE_NOT_AVAIL
Definition: lock.h:501

References AcceptInvalidationMessages(), LOCKACQUIRE_ALREADY_CLEAR, LOCKACQUIRE_NOT_AVAIL, LockAcquireExtended(), MarkLockClear(), MyDatabaseId, res, and SET_LOCKTAG_OBJECT.

Referenced by do_autovacuum().

◆ ConditionalLockPage()

bool ConditionalLockPage ( Relation  relation,
BlockNumber  blkno,
LOCKMODE  lockmode 
)

Definition at line 521 of file lmgr.c.

522 {
523  LOCKTAG tag;
524 
525  SET_LOCKTAG_PAGE(tag,
526  relation->rd_lockInfo.lockRelId.dbId,
527  relation->rd_lockInfo.lockRelId.relId,
528  blkno);
529 
530  return (LockAcquire(&tag, lockmode, false, true) != LOCKACQUIRE_NOT_AVAIL);
531 }
LockAcquireResult LockAcquire(const LOCKTAG *locktag, LOCKMODE lockmode, bool sessionLock, bool dontWait)
Definition: lock.c:803
#define SET_LOCKTAG_PAGE(locktag, dboid, reloid, blocknum)
Definition: lock.h:208

References LockRelId::dbId, LockAcquire(), LOCKACQUIRE_NOT_AVAIL, LockInfoData::lockRelId, RelationData::rd_lockInfo, LockRelId::relId, and SET_LOCKTAG_PAGE.

Referenced by ginInsertCleanup().

◆ ConditionalLockRelation()

bool ConditionalLockRelation ( Relation  relation,
LOCKMODE  lockmode 
)

Definition at line 274 of file lmgr.c.

275 {
276  LOCKTAG tag;
277  LOCALLOCK *locallock;
279 
281  relation->rd_lockInfo.lockRelId.dbId,
282  relation->rd_lockInfo.lockRelId.relId);
283 
284  res = LockAcquireExtended(&tag, lockmode, false, true, true, &locallock);
285 
286  if (res == LOCKACQUIRE_NOT_AVAIL)
287  return false;
288 
289  /*
290  * Now that we have the lock, check for invalidation messages; see notes
291  * in LockRelationOid.
292  */
294  {
296  MarkLockClear(locallock);
297  }
298 
299  return true;
300 }

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().

◆ ConditionalLockRelationForExtension()

bool ConditionalLockRelationForExtension ( Relation  relation,
LOCKMODE  lockmode 
)

Definition at line 437 of file lmgr.c.

438 {
439  LOCKTAG tag;
440 
442  relation->rd_lockInfo.lockRelId.dbId,
443  relation->rd_lockInfo.lockRelId.relId);
444 
445  return (LockAcquire(&tag, lockmode, false, true) != LOCKACQUIRE_NOT_AVAIL);
446 }
#define SET_LOCKTAG_RELATION_EXTEND(locktag, dboid, reloid)
Definition: lock.h:190

References LockRelId::dbId, LockAcquire(), LOCKACQUIRE_NOT_AVAIL, LockInfoData::lockRelId, RelationData::rd_lockInfo, LockRelId::relId, and SET_LOCKTAG_RELATION_EXTEND.

◆ ConditionalLockRelationOid()

bool ConditionalLockRelationOid ( Oid  relid,
LOCKMODE  lockmode 
)

Definition at line 150 of file lmgr.c.

151 {
152  LOCKTAG tag;
153  LOCALLOCK *locallock;
155 
156  SetLocktagRelationOid(&tag, relid);
157 
158  res = LockAcquireExtended(&tag, lockmode, false, true, true, &locallock);
159 
160  if (res == LOCKACQUIRE_NOT_AVAIL)
161  return false;
162 
163  /*
164  * Now that we have the lock, check for invalidation messages; see notes
165  * in LockRelationOid.
166  */
168  {
170  MarkLockClear(locallock);
171  }
172 
173  return true;
174 }

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().

◆ ConditionalLockSharedObject()

bool ConditionalLockSharedObject ( Oid  classid,
Oid  objid,
uint16  objsubid,
LOCKMODE  lockmode 
)

Definition at line 1096 of file lmgr.c.

1098 {
1099  LOCKTAG tag;
1100  LOCALLOCK *locallock;
1102 
1103  SET_LOCKTAG_OBJECT(tag,
1104  InvalidOid,
1105  classid,
1106  objid,
1107  objsubid);
1108 
1109  res = LockAcquireExtended(&tag, lockmode, false, true, true, &locallock);
1110 
1111  if (res == LOCKACQUIRE_NOT_AVAIL)
1112  return false;
1113 
1114  /*
1115  * Now that we have the lock, check for invalidation messages; see notes
1116  * in LockRelationOid.
1117  */
1119  {
1121  MarkLockClear(locallock);
1122  }
1123 
1124  return true;
1125 }
#define InvalidOid
Definition: postgres_ext.h:36

References AcceptInvalidationMessages(), InvalidOid, LOCKACQUIRE_ALREADY_CLEAR, LOCKACQUIRE_NOT_AVAIL, LockAcquireExtended(), MarkLockClear(), res, and SET_LOCKTAG_OBJECT.

Referenced by EventTriggerOnLogin().

◆ ConditionalLockTuple()

bool ConditionalLockTuple ( Relation  relation,
ItemPointer  tid,
LOCKMODE  lockmode 
)

Definition at line 577 of file lmgr.c.

578 {
579  LOCKTAG tag;
580 
581  SET_LOCKTAG_TUPLE(tag,
582  relation->rd_lockInfo.lockRelId.dbId,
583  relation->rd_lockInfo.lockRelId.relId,
586 
587  return (LockAcquire(&tag, lockmode, false, true) != LOCKACQUIRE_NOT_AVAIL);
588 }
static OffsetNumber ItemPointerGetOffsetNumber(const ItemPointerData *pointer)
Definition: itemptr.h:124
static BlockNumber ItemPointerGetBlockNumber(const ItemPointerData *pointer)
Definition: itemptr.h:103
#define SET_LOCKTAG_TUPLE(locktag, dboid, reloid, blocknum, offnum)
Definition: lock.h:217

References LockRelId::dbId, ItemPointerGetBlockNumber(), ItemPointerGetOffsetNumber(), LockAcquire(), LOCKACQUIRE_NOT_AVAIL, LockInfoData::lockRelId, RelationData::rd_lockInfo, LockRelId::relId, and SET_LOCKTAG_TUPLE.

◆ ConditionalXactLockTableWait()

bool ConditionalXactLockTableWait ( TransactionId  xid)

Definition at line 729 of file lmgr.c.

730 {
731  LOCKTAG tag;
732  bool first = true;
733 
734  for (;;)
735  {
738 
739  SET_LOCKTAG_TRANSACTION(tag, xid);
740 
741  if (LockAcquire(&tag, ShareLock, false, true) == LOCKACQUIRE_NOT_AVAIL)
742  return false;
743 
744  LockRelease(&tag, ShareLock, false);
745 
746  if (!TransactionIdIsInProgress(xid))
747  break;
748 
749  /* See XactLockTableWait about this case */
750  if (!first)
751  pg_usleep(1000L);
752  first = false;
754  }
755 
756  return true;
757 }
#define Assert(condition)
Definition: c.h:837
bool LockRelease(const LOCKTAG *locktag, LOCKMODE lockmode, bool sessionLock)
Definition: lock.c:2011
#define SET_LOCKTAG_TRANSACTION(locktag, xid)
Definition: lock.h:226
#define ShareLock
Definition: lockdefs.h:40
bool TransactionIdIsInProgress(TransactionId xid)
Definition: procarray.c:1402
void pg_usleep(long microsec)
Definition: signal.c:53
TransactionId SubTransGetTopmostTransaction(TransactionId xid)
Definition: subtrans.c:163
#define TransactionIdEquals(id1, id2)
Definition: transam.h:43
#define TransactionIdIsValid(xid)
Definition: transam.h:41
TransactionId GetTopTransactionIdIfAny(void)
Definition: xact.c:440

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().

◆ DescribeLockTag()

void DescribeLockTag ( StringInfo  buf,
const LOCKTAG tag 
)

Definition at line 1232 of file lmgr.c.

1233 {
1234  switch ((LockTagType) tag->locktag_type)
1235  {
1236  case LOCKTAG_RELATION:
1238  _("relation %u of database %u"),
1239  tag->locktag_field2,
1240  tag->locktag_field1);
1241  break;
1244  _("extension of relation %u of database %u"),
1245  tag->locktag_field2,
1246  tag->locktag_field1);
1247  break;
1250  _("pg_database.datfrozenxid of database %u"),
1251  tag->locktag_field1);
1252  break;
1253  case LOCKTAG_PAGE:
1255  _("page %u of relation %u of database %u"),
1256  tag->locktag_field3,
1257  tag->locktag_field2,
1258  tag->locktag_field1);
1259  break;
1260  case LOCKTAG_TUPLE:
1262  _("tuple (%u,%u) of relation %u of database %u"),
1263  tag->locktag_field3,
1264  tag->locktag_field4,
1265  tag->locktag_field2,
1266  tag->locktag_field1);
1267  break;
1268  case LOCKTAG_TRANSACTION:
1270  _("transaction %u"),
1271  tag->locktag_field1);
1272  break;
1275  _("virtual transaction %d/%u"),
1276  tag->locktag_field1,
1277  tag->locktag_field2);
1278  break;
1281  _("speculative token %u of transaction %u"),
1282  tag->locktag_field2,
1283  tag->locktag_field1);
1284  break;
1285  case LOCKTAG_OBJECT:
1287  _("object %u of class %u of database %u"),
1288  tag->locktag_field3,
1289  tag->locktag_field2,
1290  tag->locktag_field1);
1291  break;
1292  case LOCKTAG_USERLOCK:
1293  /* reserved for old contrib code, now on pgfoundry */
1295  _("user lock [%u,%u,%u]"),
1296  tag->locktag_field1,
1297  tag->locktag_field2,
1298  tag->locktag_field3);
1299  break;
1300  case LOCKTAG_ADVISORY:
1302  _("advisory lock [%u,%u,%u,%u]"),
1303  tag->locktag_field1,
1304  tag->locktag_field2,
1305  tag->locktag_field3,
1306  tag->locktag_field4);
1307  break;
1310  _("remote transaction %u of subscription %u of database %u"),
1311  tag->locktag_field3,
1312  tag->locktag_field2,
1313  tag->locktag_field1);
1314  break;
1315  default:
1317  _("unrecognized locktag type %d"),
1318  (int) tag->locktag_type);
1319  break;
1320  }
1321 }
#define _(x)
Definition: elog.c:90
LockTagType
Definition: lock.h:136
@ LOCKTAG_OBJECT
Definition: lock.h:145
@ LOCKTAG_RELATION_EXTEND
Definition: lock.h:138
@ LOCKTAG_RELATION
Definition: lock.h:137
@ LOCKTAG_TUPLE
Definition: lock.h:141
@ LOCKTAG_SPECULATIVE_TOKEN
Definition: lock.h:144
@ LOCKTAG_APPLY_TRANSACTION
Definition: lock.h:148
@ LOCKTAG_USERLOCK
Definition: lock.h:146
@ LOCKTAG_DATABASE_FROZEN_IDS
Definition: lock.h:139
@ LOCKTAG_VIRTUALTRANSACTION
Definition: lock.h:143
@ LOCKTAG_TRANSACTION
Definition: lock.h:142
@ LOCKTAG_PAGE
Definition: lock.h:140
@ LOCKTAG_ADVISORY
Definition: lock.h:147
static char * buf
Definition: pg_test_fsync.c:72
void appendStringInfo(StringInfo str, const char *fmt,...)
Definition: stringinfo.c:94
uint8 locktag_type
Definition: lock.h:170
uint32 locktag_field3
Definition: lock.h:168
uint32 locktag_field1
Definition: lock.h:166
uint16 locktag_field4
Definition: lock.h:169
uint32 locktag_field2
Definition: lock.h:167

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().

◆ GetLockNameFromTagType()

const char* GetLockNameFromTagType ( uint16  locktag_type)

Definition at line 1329 of file lmgr.c.

1330 {
1331  if (locktag_type > LOCKTAG_LAST_TYPE)
1332  return "???";
1333  return LockTagTypeNames[locktag_type];
1334 }
#define LOCKTAG_LAST_TYPE
Definition: lock.h:152
const char *const LockTagTypeNames[]
Definition: lockfuncs.c:28

References LOCKTAG_LAST_TYPE, and LockTagTypeNames.

Referenced by pgstat_get_wait_event().

◆ LockApplyTransactionForSession()

void LockApplyTransactionForSession ( Oid  suboid,
TransactionId  xid,
uint16  objid,
LOCKMODE  lockmode 
)

Definition at line 1192 of file lmgr.c.

1194 {
1195  LOCKTAG tag;
1196 
1198  MyDatabaseId,
1199  suboid,
1200  xid,
1201  objid);
1202 
1203  (void) LockAcquire(&tag, lockmode, true, false);
1204 }
#define SET_LOCKTAG_APPLY_TRANSACTION(locktag, dboid, suboid, xid, objid)
Definition: lock.h:282

References LockAcquire(), MyDatabaseId, and SET_LOCKTAG_APPLY_TRANSACTION.

Referenced by pa_lock_stream(), and pa_lock_transaction().

◆ LockDatabaseFrozenIds()

void LockDatabaseFrozenIds ( LOCKMODE  lockmode)

Definition at line 486 of file lmgr.c.

487 {
488  LOCKTAG tag;
489 
491 
492  (void) LockAcquire(&tag, lockmode, false, false);
493 }
#define SET_LOCKTAG_DATABASE_FROZEN_IDS(locktag, dboid)
Definition: lock.h:199

References LockAcquire(), MyDatabaseId, and SET_LOCKTAG_DATABASE_FROZEN_IDS.

Referenced by vac_update_datfrozenxid().

◆ LockDatabaseObject()

void LockDatabaseObject ( Oid  classid,
Oid  objid,
uint16  objsubid,
LOCKMODE  lockmode 
)

Definition at line 993 of file lmgr.c.

995 {
996  LOCKTAG tag;
997 
998  SET_LOCKTAG_OBJECT(tag,
999  MyDatabaseId,
1000  classid,
1001  objid,
1002  objsubid);
1003 
1004  (void) LockAcquire(&tag, lockmode, false, false);
1005 
1006  /* Make sure syscaches are up-to-date with any changes we waited for */
1008 }

References AcceptInvalidationMessages(), LockAcquire(), MyDatabaseId, and SET_LOCKTAG_OBJECT.

Referenced by AcquireDeletionLock(), AddEnumLabel(), AlterPublication(), AlterPublicationOptions(), get_object_address(), LockSchemaList(), RangeVarGetAndCheckCreationNamespace(), and RenameEnumLabel().

◆ LockHasWaitersRelation()

bool LockHasWaitersRelation ( Relation  relation,
LOCKMODE  lockmode 
)

Definition at line 362 of file lmgr.c.

363 {
364  LOCKTAG tag;
365 
367  relation->rd_lockInfo.lockRelId.dbId,
368  relation->rd_lockInfo.lockRelId.relId);
369 
370  return LockHasWaiters(&tag, lockmode, false);
371 }
bool LockHasWaiters(const LOCKTAG *locktag, LOCKMODE lockmode, bool sessionLock)
Definition: lock.c:690

References LockRelId::dbId, LockHasWaiters(), LockInfoData::lockRelId, RelationData::rd_lockInfo, LockRelId::relId, and SET_LOCKTAG_RELATION.

Referenced by count_nondeletable_pages().

◆ LockPage()

void LockPage ( Relation  relation,
BlockNumber  blkno,
LOCKMODE  lockmode 
)

Definition at line 502 of file lmgr.c.

503 {
504  LOCKTAG tag;
505 
506  SET_LOCKTAG_PAGE(tag,
507  relation->rd_lockInfo.lockRelId.dbId,
508  relation->rd_lockInfo.lockRelId.relId,
509  blkno);
510 
511  (void) LockAcquire(&tag, lockmode, false, false);
512 }

References LockRelId::dbId, LockAcquire(), LockInfoData::lockRelId, RelationData::rd_lockInfo, LockRelId::relId, and SET_LOCKTAG_PAGE.

Referenced by ginInsertCleanup().

◆ LockRelation()

void LockRelation ( Relation  relation,
LOCKMODE  lockmode 
)

Definition at line 243 of file lmgr.c.

244 {
245  LOCKTAG tag;
246  LOCALLOCK *locallock;
248 
250  relation->rd_lockInfo.lockRelId.dbId,
251  relation->rd_lockInfo.lockRelId.relId);
252 
253  res = LockAcquireExtended(&tag, lockmode, false, false, true, &locallock);
254 
255  /*
256  * Now that we have the lock, check for invalidation messages; see notes
257  * in LockRelationOid.
258  */
260  {
262  MarkLockClear(locallock);
263  }
264 }

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().

◆ LockRelationForExtension()

void LockRelationForExtension ( Relation  relation,
LOCKMODE  lockmode 
)

◆ LockRelationId()

void LockRelationId ( LockRelId relid,
LOCKMODE  lockmode 
)

Definition at line 183 of file lmgr.c.

184 {
185  LOCKTAG tag;
186  LOCALLOCK *locallock;
188 
189  SET_LOCKTAG_RELATION(tag, relid->dbId, relid->relId);
190 
191  res = LockAcquireExtended(&tag, lockmode, false, false, true, &locallock);
192 
193  /*
194  * Now that we have the lock, check for invalidation messages; see notes
195  * in LockRelationOid.
196  */
198  {
200  MarkLockClear(locallock);
201  }
202 }

References AcceptInvalidationMessages(), LockRelId::dbId, LOCKACQUIRE_ALREADY_CLEAR, LockAcquireExtended(), MarkLockClear(), LockRelId::relId, res, and SET_LOCKTAG_RELATION.

Referenced by CreateDatabaseUsingWalLog(), and ScanSourceDatabasePgClass().

◆ LockRelationIdForSession()

void LockRelationIdForSession ( LockRelId relid,
LOCKMODE  lockmode 
)

Definition at line 386 of file lmgr.c.

387 {
388  LOCKTAG tag;
389 
390  SET_LOCKTAG_RELATION(tag, relid->dbId, relid->relId);
391 
392  (void) LockAcquire(&tag, lockmode, true, false);
393 }

References LockRelId::dbId, LockAcquire(), LockRelId::relId, and SET_LOCKTAG_RELATION.

Referenced by DefineIndex(), index_drop(), ReindexRelationConcurrently(), and vacuum_rel().

◆ LockRelationOid()

void LockRelationOid ( Oid  relid,
LOCKMODE  lockmode 
)

Definition at line 107 of file lmgr.c.

108 {
109  LOCKTAG tag;
110  LOCALLOCK *locallock;
112 
113  SetLocktagRelationOid(&tag, relid);
114 
115  res = LockAcquireExtended(&tag, lockmode, false, false, true, &locallock);
116 
117  /*
118  * Now that we have the lock, check for invalidation messages, so that we
119  * will update or flush any stale relcache entry before we try to use it.
120  * RangeVarGetRelid() specifically relies on us for this. We can skip
121  * this in the not-uncommon case that we already had the same type of lock
122  * being requested, since then no one else could have modified the
123  * relcache entry in an undesirable way. (In the case where our own xact
124  * modifies the rel, the relcache update happens via
125  * CommandCounterIncrement, not here.)
126  *
127  * However, in corner cases where code acts on tables (usually catalogs)
128  * recursively, we might get here while still processing invalidation
129  * messages in some outer execution of this function or a sibling. The
130  * "cleared" status of the lock tells us whether we really are done
131  * absorbing relevant inval messages.
132  */
134  {
136  MarkLockClear(locallock);
137  }
138 }

References AcceptInvalidationMessages(), LOCKACQUIRE_ALREADY_CLEAR, LockAcquireExtended(), MarkLockClear(), res, and SetLocktagRelationOid().

Referenced by AcquireDeletionLock(), AcquireExecutorLocks(), AlterTableMoveAll(), ATExecAttachPartition(), ATExecDetachPartition(), ATPostAlterTypeCleanup(), binary_upgrade_replorigin_advance(), copy_table_data(), CreateTriggerFiringOn(), 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(), RefreshMatViewByOid(), relation_open(), ScanQueryForLocks(), SequenceChangePersistence(), and try_relation_open().

◆ LockSharedObject()

void LockSharedObject ( Oid  classid,
Oid  objid,
uint16  objsubid,
LOCKMODE  lockmode 
)

◆ LockSharedObjectForSession()

void LockSharedObjectForSession ( Oid  classid,
Oid  objid,
uint16  objsubid,
LOCKMODE  lockmode 
)

Definition at line 1152 of file lmgr.c.

1154 {
1155  LOCKTAG tag;
1156 
1157  SET_LOCKTAG_OBJECT(tag,
1158  InvalidOid,
1159  classid,
1160  objid,
1161  objsubid);
1162 
1163  (void) LockAcquire(&tag, lockmode, true, false);
1164 }

References InvalidOid, LockAcquire(), and SET_LOCKTAG_OBJECT.

Referenced by dbase_redo(), and movedb().

◆ LockTuple()

◆ RelationExtensionLockWaiterCount()

int RelationExtensionLockWaiterCount ( Relation  relation)

Definition at line 454 of file lmgr.c.

455 {
456  LOCKTAG tag;
457 
459  relation->rd_lockInfo.lockRelId.dbId,
460  relation->rd_lockInfo.lockRelId.relId);
461 
462  return LockWaiterCount(&tag);
463 }
int LockWaiterCount(const LOCKTAG *locktag)
Definition: lock.c:4761

References LockRelId::dbId, LockInfoData::lockRelId, LockWaiterCount(), RelationData::rd_lockInfo, LockRelId::relId, and SET_LOCKTAG_RELATION_EXTEND.

Referenced by RelationAddBlocks().

◆ RelationInitLockInfo()

void RelationInitLockInfo ( Relation  relation)

Definition at line 70 of file lmgr.c.

71 {
72  Assert(RelationIsValid(relation));
74 
75  relation->rd_lockInfo.lockRelId.relId = RelationGetRelid(relation);
76 
77  if (relation->rd_rel->relisshared)
79  else
81 }
#define OidIsValid(objectId)
Definition: c.h:754
#define RelationGetRelid(relation)
Definition: rel.h:505
#define RelationIsValid(relation)
Definition: rel.h:478
Form_pg_class rd_rel
Definition: rel.h:111

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().

◆ SpeculativeInsertionLockAcquire()

uint32 SpeculativeInsertionLockAcquire ( TransactionId  xid)

Definition at line 771 of file lmgr.c.

772 {
773  LOCKTAG tag;
774 
776 
777  /*
778  * Check for wrap-around. Zero means no token is held, so don't use that.
779  */
780  if (speculativeInsertionToken == 0)
782 
784 
785  (void) LockAcquire(&tag, ExclusiveLock, false, false);
786 
788 }
static uint32 speculativeInsertionToken
Definition: lmgr.c:45
#define SET_LOCKTAG_SPECULATIVE_INSERTION(locktag, xid, token)
Definition: lock.h:247
#define ExclusiveLock
Definition: lockdefs.h:42

References ExclusiveLock, LockAcquire(), SET_LOCKTAG_SPECULATIVE_INSERTION, and speculativeInsertionToken.

Referenced by ExecInsert().

◆ SpeculativeInsertionLockRelease()

void SpeculativeInsertionLockRelease ( TransactionId  xid)

Definition at line 797 of file lmgr.c.

798 {
799  LOCKTAG tag;
800 
802 
803  LockRelease(&tag, ExclusiveLock, false);
804 }

References ExclusiveLock, LockRelease(), SET_LOCKTAG_SPECULATIVE_INSERTION, and speculativeInsertionToken.

Referenced by ExecInsert().

◆ SpeculativeInsertionWait()

void SpeculativeInsertionWait ( TransactionId  xid,
uint32  token 
)

Definition at line 813 of file lmgr.c.

814 {
815  LOCKTAG tag;
816 
818 
820  Assert(token != 0);
821 
822  (void) LockAcquire(&tag, ShareLock, false, false);
823  LockRelease(&tag, ShareLock, false);
824 }
#define token
Definition: indent_globs.h:126

References Assert, LockAcquire(), LockRelease(), SET_LOCKTAG_SPECULATIVE_INSERTION, ShareLock, token, and TransactionIdIsValid.

Referenced by _bt_doinsert(), and check_exclusion_or_unique_constraint().

◆ UnlockApplyTransactionForSession()

void UnlockApplyTransactionForSession ( Oid  suboid,
TransactionId  xid,
uint16  objid,
LOCKMODE  lockmode 
)

Definition at line 1210 of file lmgr.c.

1212 {
1213  LOCKTAG tag;
1214 
1216  MyDatabaseId,
1217  suboid,
1218  xid,
1219  objid);
1220 
1221  LockRelease(&tag, lockmode, true);
1222 }

References LockRelease(), MyDatabaseId, and SET_LOCKTAG_APPLY_TRANSACTION.

Referenced by pa_unlock_stream(), and pa_unlock_transaction().

◆ UnlockDatabaseObject()

void UnlockDatabaseObject ( Oid  classid,
Oid  objid,
uint16  objsubid,
LOCKMODE  lockmode 
)

Definition at line 1052 of file lmgr.c.

1054 {
1055  LOCKTAG tag;
1056 
1057  SET_LOCKTAG_OBJECT(tag,
1058  MyDatabaseId,
1059  classid,
1060  objid,
1061  objsubid);
1062 
1063  LockRelease(&tag, lockmode, false);
1064 }

References LockRelease(), MyDatabaseId, and SET_LOCKTAG_OBJECT.

Referenced by get_object_address(), RangeVarGetAndCheckCreationNamespace(), and ReleaseDeletionLock().

◆ UnlockPage()

void UnlockPage ( Relation  relation,
BlockNumber  blkno,
LOCKMODE  lockmode 
)

Definition at line 537 of file lmgr.c.

538 {
539  LOCKTAG tag;
540 
541  SET_LOCKTAG_PAGE(tag,
542  relation->rd_lockInfo.lockRelId.dbId,
543  relation->rd_lockInfo.lockRelId.relId,
544  blkno);
545 
546  LockRelease(&tag, lockmode, false);
547 }

References LockRelId::dbId, LockRelease(), LockInfoData::lockRelId, RelationData::rd_lockInfo, LockRelId::relId, and SET_LOCKTAG_PAGE.

Referenced by ginInsertCleanup().

◆ UnlockRelation()

void UnlockRelation ( Relation  relation,
LOCKMODE  lockmode 
)

Definition at line 309 of file lmgr.c.

310 {
311  LOCKTAG tag;
312 
314  relation->rd_lockInfo.lockRelId.dbId,
315  relation->rd_lockInfo.lockRelId.relId);
316 
317  LockRelease(&tag, lockmode, false);
318 }

References LockRelId::dbId, LockRelease(), LockInfoData::lockRelId, RelationData::rd_lockInfo, LockRelId::relId, and SET_LOCKTAG_RELATION.

Referenced by lazy_truncate_heap().

◆ UnlockRelationForExtension()

void UnlockRelationForExtension ( Relation  relation,
LOCKMODE  lockmode 
)

◆ UnlockRelationId()

void UnlockRelationId ( LockRelId relid,
LOCKMODE  lockmode 
)

Definition at line 211 of file lmgr.c.

212 {
213  LOCKTAG tag;
214 
215  SET_LOCKTAG_RELATION(tag, relid->dbId, relid->relId);
216 
217  LockRelease(&tag, lockmode, false);
218 }

References LockRelId::dbId, LockRelease(), LockRelId::relId, and SET_LOCKTAG_RELATION.

Referenced by CreateDatabaseUsingWalLog(), index_close(), relation_close(), and ScanSourceDatabasePgClass().

◆ UnlockRelationIdForSession()

void UnlockRelationIdForSession ( LockRelId relid,
LOCKMODE  lockmode 
)

Definition at line 399 of file lmgr.c.

400 {
401  LOCKTAG tag;
402 
403  SET_LOCKTAG_RELATION(tag, relid->dbId, relid->relId);
404 
405  LockRelease(&tag, lockmode, true);
406 }

References LockRelId::dbId, LockRelease(), LockRelId::relId, and SET_LOCKTAG_RELATION.

Referenced by DefineIndex(), index_drop(), ReindexRelationConcurrently(), and vacuum_rel().

◆ UnlockRelationOid()

◆ UnlockSharedObject()

void UnlockSharedObject ( Oid  classid,
Oid  objid,
uint16  objsubid,
LOCKMODE  lockmode 
)

Definition at line 1131 of file lmgr.c.

1133 {
1134  LOCKTAG tag;
1135 
1136  SET_LOCKTAG_OBJECT(tag,
1137  InvalidOid,
1138  classid,
1139  objid,
1140  objsubid);
1141 
1142  LockRelease(&tag, lockmode, false);
1143 }

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().

◆ UnlockSharedObjectForSession()

void UnlockSharedObjectForSession ( Oid  classid,
Oid  objid,
uint16  objsubid,
LOCKMODE  lockmode 
)

Definition at line 1170 of file lmgr.c.

1172 {
1173  LOCKTAG tag;
1174 
1175  SET_LOCKTAG_OBJECT(tag,
1176  InvalidOid,
1177  classid,
1178  objid,
1179  objsubid);
1180 
1181  LockRelease(&tag, lockmode, true);
1182 }

References InvalidOid, LockRelease(), and SET_LOCKTAG_OBJECT.

Referenced by dbase_redo(), and movedb().

◆ UnlockTuple()

◆ WaitForLockers()

void WaitForLockers ( LOCKTAG  heaplocktag,
LOCKMODE  lockmode,
bool  progress 
)

Definition at line 974 of file lmgr.c.

975 {
976  List *l;
977 
978  l = list_make1(&heaplocktag);
979  WaitForLockersMultiple(l, lockmode, progress);
980  list_free(l);
981 }
void list_free(List *list)
Definition: list.c:1546
void WaitForLockersMultiple(List *locktags, LOCKMODE lockmode, bool progress)
Definition: lmgr.c:896
#define list_make1(x1)
Definition: pg_list.h:212
static int progress
Definition: pgbench.c:261
Definition: pg_list.h:54

References list_free(), list_make1, progress, and WaitForLockersMultiple().

Referenced by DefineIndex(), and index_drop().

◆ WaitForLockersMultiple()

void WaitForLockersMultiple ( List locktags,
LOCKMODE  lockmode,
bool  progress 
)

Definition at line 896 of file lmgr.c.

897 {
898  List *holders = NIL;
899  ListCell *lc;
900  int total = 0;
901  int done = 0;
902 
903  /* Done if no locks to wait for */
904  if (locktags == NIL)
905  return;
906 
907  /* Collect the transactions we need to wait on */
908  foreach(lc, locktags)
909  {
910  LOCKTAG *locktag = lfirst(lc);
911  int count;
912 
913  holders = lappend(holders,
914  GetLockConflicts(locktag, lockmode,
915  progress ? &count : NULL));
916  if (progress)
917  total += count;
918  }
919 
920  if (progress)
922 
923  /*
924  * Note: GetLockConflicts() never reports our own xid, hence we need not
925  * check for that. Also, prepared xacts are reported and awaited.
926  */
927 
928  /* Finally wait for each such transaction to complete */
929  foreach(lc, holders)
930  {
931  VirtualTransactionId *lockholders = lfirst(lc);
932 
933  while (VirtualTransactionIdIsValid(*lockholders))
934  {
935  /* If requested, publish who we're going to wait for. */
936  if (progress)
937  {
938  PGPROC *holder = ProcNumberGetProc(lockholders->procNumber);
939 
940  if (holder)
942  holder->pid);
943  }
944  VirtualXactLock(*lockholders, true);
945  lockholders++;
946 
947  if (progress)
949  }
950  }
951  if (progress)
952  {
953  const int index[] = {
957  };
958  const int64 values[] = {
959  0, 0, 0
960  };
961 
963  }
964 
965  list_free_deep(holders);
966 }
void pgstat_progress_update_param(int index, int64 val)
void pgstat_progress_update_multi_param(int nparam, const int *index, const int64 *val)
static Datum values[MAXATTR]
Definition: bootstrap.c:151
List * lappend(List *list, void *datum)
Definition: list.c:339
void list_free_deep(List *list)
Definition: list.c:1560
VirtualTransactionId * GetLockConflicts(const LOCKTAG *locktag, LOCKMODE lockmode, int *countp)
Definition: lock.c:2976
bool VirtualXactLock(VirtualTransactionId vxid, bool wait)
Definition: lock.c:4650
#define VirtualTransactionIdIsValid(vxid)
Definition: lock.h:67
#define lfirst(lc)
Definition: pg_list.h:172
#define NIL
Definition: pg_list.h:68
PGPROC * ProcNumberGetProc(ProcNumber procNumber)
Definition: procarray.c:3142
#define PROGRESS_WAITFOR_DONE
Definition: progress.h:118
#define PROGRESS_WAITFOR_TOTAL
Definition: progress.h:117
#define PROGRESS_WAITFOR_CURRENT_PID
Definition: progress.h:119
Definition: proc.h:162
int pid
Definition: proc.h:182
ProcNumber procNumber
Definition: lock.h:61
Definition: type.h:96

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().

◆ XactLockTableDelete()

void XactLockTableDelete ( TransactionId  xid)

Definition at line 632 of file lmgr.c.

633 {
634  LOCKTAG tag;
635 
636  SET_LOCKTAG_TRANSACTION(tag, xid);
637 
638  LockRelease(&tag, ExclusiveLock, false);
639 }

References ExclusiveLock, LockRelease(), and SET_LOCKTAG_TRANSACTION.

Referenced by CommitSubTransaction().

◆ XactLockTableInsert()

void XactLockTableInsert ( TransactionId  xid)

Definition at line 615 of file lmgr.c.

616 {
617  LOCKTAG tag;
618 
619  SET_LOCKTAG_TRANSACTION(tag, xid);
620 
621  (void) LockAcquire(&tag, ExclusiveLock, false, false);
622 }

References ExclusiveLock, LockAcquire(), and SET_LOCKTAG_TRANSACTION.

Referenced by AssignTransactionId().

◆ XactLockTableWait()

void XactLockTableWait ( TransactionId  xid,
Relation  rel,
ItemPointer  ctid,
XLTW_Oper  oper 
)

Definition at line 656 of file lmgr.c.

658 {
659  LOCKTAG tag;
662  bool first = true;
663 
664  /*
665  * If an operation is specified, set up our verbose error context
666  * callback.
667  */
668  if (oper != XLTW_None)
669  {
670  Assert(RelationIsValid(rel));
671  Assert(ItemPointerIsValid(ctid));
672 
673  info.rel = rel;
674  info.ctid = ctid;
675  info.oper = oper;
676 
678  callback.arg = &info;
679  callback.previous = error_context_stack;
681  }
682 
683  for (;;)
684  {
687 
688  SET_LOCKTAG_TRANSACTION(tag, xid);
689 
690  (void) LockAcquire(&tag, ShareLock, false, false);
691 
692  LockRelease(&tag, ShareLock, false);
693 
694  if (!TransactionIdIsInProgress(xid))
695  break;
696 
697  /*
698  * If the Xid belonged to a subtransaction, then the lock would have
699  * gone away as soon as it was finished; for correct tuple visibility,
700  * the right action is to wait on its parent transaction to go away.
701  * But instead of going levels up one by one, we can just wait for the
702  * topmost transaction to finish with the same end result, which also
703  * incurs less locktable traffic.
704  *
705  * Some uses of this function don't involve tuple visibility -- such
706  * as when building snapshots for logical decoding. It is possible to
707  * see a transaction in ProcArray before it registers itself in the
708  * locktable. The topmost transaction in that case is the same xid,
709  * so we try again after a short sleep. (Don't sleep the first time
710  * through, to avoid slowing down the normal case.)
711  */
712  if (!first)
713  pg_usleep(1000L);
714  first = false;
716  }
717 
718  if (oper != XLTW_None)
719  error_context_stack = callback.previous;
720 }
ErrorContextCallback * error_context_stack
Definition: elog.c:94
static bool ItemPointerIsValid(const ItemPointerData *pointer)
Definition: itemptr.h:83
static void XactLockTableWaitErrorCb(void *arg)
Definition: lmgr.c:831
Operator oper(ParseState *pstate, List *opname, Oid ltypeId, Oid rtypeId, bool noError, int location)
Definition: parse_oper.c:370
ItemPointer ctid
Definition: lmgr.c:58
XLTW_Oper oper
Definition: lmgr.c:56
Relation rel
Definition: lmgr.c:57
static void callback(struct sockaddr *addr, struct sockaddr *mask, void *unused)
Definition: test_ifaddrs.c:46

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().