PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
lock.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * lock.h
4  * POSTGRES low-level lock mechanism
5  *
6  *
7  * Portions Copyright (c) 1996-2014, PostgreSQL Global Development Group
8  * Portions Copyright (c) 1994, Regents of the University of California
9  *
10  * src/include/storage/lock.h
11  *
12  *-------------------------------------------------------------------------
13  */
14 #ifndef LOCK_H_
15 #define LOCK_H_
16 
17 #include "storage/backendid.h"
18 #include "storage/lwlock.h"
19 #include "storage/shmem.h"
20 
21 
22 /* struct PGPROC is declared in proc.h, but must forward-reference it */
23 typedef struct PGPROC PGPROC;
24 
25 typedef struct PROC_QUEUE
26 {
27  SHM_QUEUE links; /* head of list of PGPROC objects */
28  int size; /* number of entries in list */
29 } PROC_QUEUE;
30 
31 /* GUC variables */
32 extern int max_locks_per_xact;
33 
34 #ifdef LOCK_DEBUG
35 extern int Trace_lock_oidmin;
36 extern bool Trace_locks;
37 extern bool Trace_userlocks;
38 extern int Trace_lock_table;
39 extern bool Debug_deadlocks;
40 #endif /* LOCK_DEBUG */
41 
42 
43 /*
44  * Top-level transactions are identified by VirtualTransactionIDs comprising
45  * the BackendId of the backend running the xact, plus a locally-assigned
46  * LocalTransactionId. These are guaranteed unique over the short term,
47  * but will be reused after a database restart; hence they should never
48  * be stored on disk.
49  *
50  * Note that struct VirtualTransactionId can not be assumed to be atomically
51  * assignable as a whole. However, type LocalTransactionId is assumed to
52  * be atomically assignable, and the backend ID doesn't change often enough
53  * to be a problem, so we can fetch or assign the two fields separately.
54  * We deliberately refrain from using the struct within PGPROC, to prevent
55  * coding errors from trying to use struct assignment with it; instead use
56  * GET_VXID_FROM_PGPROC().
57  */
58 typedef struct
59 {
60  BackendId backendId; /* determined at backend startup */
61  LocalTransactionId localTransactionId; /* backend-local transaction
62  * id */
64 
65 #define InvalidLocalTransactionId 0
66 #define LocalTransactionIdIsValid(lxid) ((lxid) != InvalidLocalTransactionId)
67 #define VirtualTransactionIdIsValid(vxid) \
68  (((vxid).backendId != InvalidBackendId) && \
69  LocalTransactionIdIsValid((vxid).localTransactionId))
70 #define VirtualTransactionIdEquals(vxid1, vxid2) \
71  ((vxid1).backendId == (vxid2).backendId && \
72  (vxid1).localTransactionId == (vxid2).localTransactionId)
73 #define SetInvalidVirtualTransactionId(vxid) \
74  ((vxid).backendId = InvalidBackendId, \
75  (vxid).localTransactionId = InvalidLocalTransactionId)
76 #define GET_VXID_FROM_PGPROC(vxid, proc) \
77  ((vxid).backendId = (proc).backendId, \
78  (vxid).localTransactionId = (proc).lxid)
79 
80 
81 /*
82  * LOCKMODE is an integer (1..N) indicating a lock type. LOCKMASK is a bit
83  * mask indicating a set of held or requested lock types (the bit 1<<mode
84  * corresponds to a particular lock mode).
85  */
86 typedef int LOCKMASK;
87 typedef int LOCKMODE;
88 
89 /* MAX_LOCKMODES cannot be larger than the # of bits in LOCKMASK */
90 #define MAX_LOCKMODES 10
91 
92 #define LOCKBIT_ON(lockmode) (1 << (lockmode))
93 #define LOCKBIT_OFF(lockmode) (~(1 << (lockmode)))
94 
95 
96 /*
97  * This data structure defines the locking semantics associated with a
98  * "lock method". The semantics specify the meaning of each lock mode
99  * (by defining which lock modes it conflicts with).
100  * All of this data is constant and is kept in const tables.
101  *
102  * numLockModes -- number of lock modes (READ,WRITE,etc) that
103  * are defined in this lock method. Must be less than MAX_LOCKMODES.
104  *
105  * conflictTab -- this is an array of bitmasks showing lock
106  * mode conflicts. conflictTab[i] is a mask with the j-th bit
107  * turned on if lock modes i and j conflict. Lock modes are
108  * numbered 1..numLockModes; conflictTab[0] is unused.
109  *
110  * lockModeNames -- ID strings for debug printouts.
111  *
112  * trace_flag -- pointer to GUC trace flag for this lock method. (The
113  * GUC variable is not constant, but we use "const" here to denote that
114  * it can't be changed through this reference.)
115  */
116 typedef struct LockMethodData
117 {
120  const char *const * lockModeNames;
121  const bool *trace_flag;
123 
124 typedef const LockMethodData *LockMethod;
125 
126 /*
127  * Lock methods are identified by LOCKMETHODID. (Despite the declaration as
128  * uint16, we are constrained to 256 lockmethods by the layout of LOCKTAG.)
129  */
131 
132 /* These identify the known lock methods */
133 #define DEFAULT_LOCKMETHOD 1
134 #define USER_LOCKMETHOD 2
135 
136 /*
137  * These are the valid values of type LOCKMODE for all the standard lock
138  * methods (both DEFAULT and USER).
139  */
140 
141 /* NoLock is not a lock mode, but a flag value meaning "don't get a lock" */
142 #define NoLock 0
143 
144 #define AccessShareLock 1 /* SELECT */
145 #define RowShareLock 2 /* SELECT FOR UPDATE/FOR SHARE */
146 #define RowExclusiveLock 3 /* INSERT, UPDATE, DELETE */
147 #define ShareUpdateExclusiveLock 4 /* VACUUM (non-FULL),ANALYZE, CREATE
148  * INDEX CONCURRENTLY */
149 #define ShareLock 5 /* CREATE INDEX (WITHOUT CONCURRENTLY) */
150 #define ShareRowExclusiveLock 6 /* like EXCLUSIVE MODE, but allows ROW
151  * SHARE */
152 #define ExclusiveLock 7 /* blocks ROW SHARE/SELECT...FOR
153  * UPDATE */
154 #define AccessExclusiveLock 8 /* ALTER TABLE, DROP TABLE, VACUUM
155  * FULL, and unqualified LOCK TABLE */
156 
157 
158 /*
159  * LOCKTAG is the key information needed to look up a LOCK item in the
160  * lock hashtable. A LOCKTAG value uniquely identifies a lockable object.
161  *
162  * The LockTagType enum defines the different kinds of objects we can lock.
163  * We can handle up to 256 different LockTagTypes.
164  */
165 typedef enum LockTagType
166 {
167  LOCKTAG_RELATION, /* whole relation */
168  /* ID info for a relation is DB OID + REL OID; DB OID = 0 if shared */
169  LOCKTAG_RELATION_EXTEND, /* the right to extend a relation */
170  /* same ID info as RELATION */
171  LOCKTAG_PAGE, /* one page of a relation */
172  /* ID info for a page is RELATION info + BlockNumber */
173  LOCKTAG_TUPLE, /* one physical tuple */
174  /* ID info for a tuple is PAGE info + OffsetNumber */
175  LOCKTAG_TRANSACTION, /* transaction (for waiting for xact done) */
176  /* ID info for a transaction is its TransactionId */
177  LOCKTAG_VIRTUALTRANSACTION, /* virtual transaction (ditto) */
178  /* ID info for a virtual transaction is its VirtualTransactionId */
179  LOCKTAG_OBJECT, /* non-relation database object */
180  /* ID info for an object is DB OID + CLASS OID + OBJECT OID + SUBID */
181 
182  /*
183  * Note: object ID has same representation as in pg_depend and
184  * pg_description, but notice that we are constraining SUBID to 16 bits.
185  * Also, we use DB OID = 0 for shared objects such as tablespaces.
186  */
187  LOCKTAG_USERLOCK, /* reserved for old contrib/userlock code */
188  LOCKTAG_ADVISORY /* advisory user locks */
189 } LockTagType;
190 
191 #define LOCKTAG_LAST_TYPE LOCKTAG_ADVISORY
192 
193 /*
194  * The LOCKTAG struct is defined with malice aforethought to fit into 16
195  * bytes with no padding. Note that this would need adjustment if we were
196  * to widen Oid, BlockNumber, or TransactionId to more than 32 bits.
197  *
198  * We include lockmethodid in the locktag so that a single hash table in
199  * shared memory can store locks of different lockmethods.
200  */
201 typedef struct LOCKTAG
202 {
203  uint32 locktag_field1; /* a 32-bit ID field */
204  uint32 locktag_field2; /* a 32-bit ID field */
205  uint32 locktag_field3; /* a 32-bit ID field */
206  uint16 locktag_field4; /* a 16-bit ID field */
207  uint8 locktag_type; /* see enum LockTagType */
208  uint8 locktag_lockmethodid; /* lockmethod indicator */
209 } LOCKTAG;
210 
211 /*
212  * These macros define how we map logical IDs of lockable objects into
213  * the physical fields of LOCKTAG. Use these to set up LOCKTAG values,
214  * rather than accessing the fields directly. Note multiple eval of target!
215  */
216 #define SET_LOCKTAG_RELATION(locktag,dboid,reloid) \
217  ((locktag).locktag_field1 = (dboid), \
218  (locktag).locktag_field2 = (reloid), \
219  (locktag).locktag_field3 = 0, \
220  (locktag).locktag_field4 = 0, \
221  (locktag).locktag_type = LOCKTAG_RELATION, \
222  (locktag).locktag_lockmethodid = DEFAULT_LOCKMETHOD)
223 
224 #define SET_LOCKTAG_RELATION_EXTEND(locktag,dboid,reloid) \
225  ((locktag).locktag_field1 = (dboid), \
226  (locktag).locktag_field2 = (reloid), \
227  (locktag).locktag_field3 = 0, \
228  (locktag).locktag_field4 = 0, \
229  (locktag).locktag_type = LOCKTAG_RELATION_EXTEND, \
230  (locktag).locktag_lockmethodid = DEFAULT_LOCKMETHOD)
231 
232 #define SET_LOCKTAG_PAGE(locktag,dboid,reloid,blocknum) \
233  ((locktag).locktag_field1 = (dboid), \
234  (locktag).locktag_field2 = (reloid), \
235  (locktag).locktag_field3 = (blocknum), \
236  (locktag).locktag_field4 = 0, \
237  (locktag).locktag_type = LOCKTAG_PAGE, \
238  (locktag).locktag_lockmethodid = DEFAULT_LOCKMETHOD)
239 
240 #define SET_LOCKTAG_TUPLE(locktag,dboid,reloid,blocknum,offnum) \
241  ((locktag).locktag_field1 = (dboid), \
242  (locktag).locktag_field2 = (reloid), \
243  (locktag).locktag_field3 = (blocknum), \
244  (locktag).locktag_field4 = (offnum), \
245  (locktag).locktag_type = LOCKTAG_TUPLE, \
246  (locktag).locktag_lockmethodid = DEFAULT_LOCKMETHOD)
247 
248 #define SET_LOCKTAG_TRANSACTION(locktag,xid) \
249  ((locktag).locktag_field1 = (xid), \
250  (locktag).locktag_field2 = 0, \
251  (locktag).locktag_field3 = 0, \
252  (locktag).locktag_field4 = 0, \
253  (locktag).locktag_type = LOCKTAG_TRANSACTION, \
254  (locktag).locktag_lockmethodid = DEFAULT_LOCKMETHOD)
255 
256 #define SET_LOCKTAG_VIRTUALTRANSACTION(locktag,vxid) \
257  ((locktag).locktag_field1 = (vxid).backendId, \
258  (locktag).locktag_field2 = (vxid).localTransactionId, \
259  (locktag).locktag_field3 = 0, \
260  (locktag).locktag_field4 = 0, \
261  (locktag).locktag_type = LOCKTAG_VIRTUALTRANSACTION, \
262  (locktag).locktag_lockmethodid = DEFAULT_LOCKMETHOD)
263 
264 #define SET_LOCKTAG_OBJECT(locktag,dboid,classoid,objoid,objsubid) \
265  ((locktag).locktag_field1 = (dboid), \
266  (locktag).locktag_field2 = (classoid), \
267  (locktag).locktag_field3 = (objoid), \
268  (locktag).locktag_field4 = (objsubid), \
269  (locktag).locktag_type = LOCKTAG_OBJECT, \
270  (locktag).locktag_lockmethodid = DEFAULT_LOCKMETHOD)
271 
272 #define SET_LOCKTAG_ADVISORY(locktag,id1,id2,id3,id4) \
273  ((locktag).locktag_field1 = (id1), \
274  (locktag).locktag_field2 = (id2), \
275  (locktag).locktag_field3 = (id3), \
276  (locktag).locktag_field4 = (id4), \
277  (locktag).locktag_type = LOCKTAG_ADVISORY, \
278  (locktag).locktag_lockmethodid = USER_LOCKMETHOD)
279 
280 
281 /*
282  * Per-locked-object lock information:
283  *
284  * tag -- uniquely identifies the object being locked
285  * grantMask -- bitmask for all lock types currently granted on this object.
286  * waitMask -- bitmask for all lock types currently awaited on this object.
287  * procLocks -- list of PROCLOCK objects for this lock.
288  * waitProcs -- queue of processes waiting for this lock.
289  * requested -- count of each lock type currently requested on the lock
290  * (includes requests already granted!!).
291  * nRequested -- total requested locks of all types.
292  * granted -- count of each lock type currently granted on the lock.
293  * nGranted -- total granted locks of all types.
294  *
295  * Note: these counts count 1 for each backend. Internally to a backend,
296  * there may be multiple grabs on a particular lock, but this is not reflected
297  * into shared memory.
298  */
299 typedef struct LOCK
300 {
301  /* hash key */
302  LOCKTAG tag; /* unique identifier of lockable object */
304  /* data */
305  LOCKMASK grantMask; /* bitmask for lock types already granted */
306  LOCKMASK waitMask; /* bitmask for lock types awaited */
307  SHM_QUEUE procLocks; /* list of PROCLOCK objects assoc. with lock */
308  PROC_QUEUE waitProcs; /* list of PGPROC objects waiting on lock */
309  int requested[MAX_LOCKMODES]; /* counts of requested locks */
310  int nRequested; /* total of requested[] array */
311  int granted[MAX_LOCKMODES]; /* counts of granted locks */
312  int nGranted; /* total of granted[] array */
313 } LOCK;
314 
315 #define LOCK_LOCKMETHOD(lock) ((LOCKMETHODID) (lock).tag.locktag_lockmethodid)
316 
317 
318 /*
319  * We may have several different backends holding or awaiting locks
320  * on the same lockable object. We need to store some per-holder/waiter
321  * information for each such holder (or would-be holder). This is kept in
322  * a PROCLOCK struct.
323  *
324  * PROCLOCKTAG is the key information needed to look up a PROCLOCK item in the
325  * proclock hashtable. A PROCLOCKTAG value uniquely identifies the combination
326  * of a lockable object and a holder/waiter for that object. (We can use
327  * pointers here because the PROCLOCKTAG need only be unique for the lifespan
328  * of the PROCLOCK, and it will never outlive the lock or the proc.)
329  *
330  * Internally to a backend, it is possible for the same lock to be held
331  * for different purposes: the backend tracks transaction locks separately
332  * from session locks. However, this is not reflected in the shared-memory
333  * state: we only track which backend(s) hold the lock. This is OK since a
334  * backend can never block itself.
335  *
336  * The holdMask field shows the already-granted locks represented by this
337  * proclock. Note that there will be a proclock object, possibly with
338  * zero holdMask, for any lock that the process is currently waiting on.
339  * Otherwise, proclock objects whose holdMasks are zero are recycled
340  * as soon as convenient.
341  *
342  * releaseMask is workspace for LockReleaseAll(): it shows the locks due
343  * to be released during the current call. This must only be examined or
344  * set by the backend owning the PROCLOCK.
345  *
346  * Each PROCLOCK object is linked into lists for both the associated LOCK
347  * object and the owning PGPROC object. Note that the PROCLOCK is entered
348  * into these lists as soon as it is created, even if no lock has yet been
349  * granted. A PGPROC that is waiting for a lock to be granted will also be
350  * linked into the lock's waitProcs queue.
351  */
352 typedef struct PROCLOCKTAG
353 {
354  /* NB: we assume this struct contains no padding! */
355  LOCK *myLock; /* link to per-lockable-object information */
356  PGPROC *myProc; /* link to PGPROC of owning backend */
357 } PROCLOCKTAG;
359 typedef struct PROCLOCK
360 {
361  /* tag */
362  PROCLOCKTAG tag; /* unique identifier of proclock object */
364  /* data */
365  LOCKMASK holdMask; /* bitmask for lock types currently held */
366  LOCKMASK releaseMask; /* bitmask for lock types to be released */
367  SHM_QUEUE lockLink; /* list link in LOCK's list of proclocks */
368  SHM_QUEUE procLink; /* list link in PGPROC's list of proclocks */
369 } PROCLOCK;
370 
371 #define PROCLOCK_LOCKMETHOD(proclock) \
372  LOCK_LOCKMETHOD(*((proclock).tag.myLock))
373 
374 /*
375  * Each backend also maintains a local hash table with information about each
376  * lock it is currently interested in. In particular the local table counts
377  * the number of times that lock has been acquired. This allows multiple
378  * requests for the same lock to be executed without additional accesses to
379  * shared memory. We also track the number of lock acquisitions per
380  * ResourceOwner, so that we can release just those locks belonging to a
381  * particular ResourceOwner.
382  *
383  * When holding a lock taken "normally", the lock and proclock fields always
384  * point to the associated objects in shared memory. However, if we acquired
385  * the lock via the fast-path mechanism, the lock and proclock fields are set
386  * to NULL, since there probably aren't any such objects in shared memory.
387  * (If the lock later gets promoted to normal representation, we may eventually
388  * update our locallock's lock/proclock fields after finding the shared
389  * objects.)
390  *
391  * Caution: a locallock object can be left over from a failed lock acquisition
392  * attempt. In this case its lock/proclock fields are untrustworthy, since
393  * the shared lock object is neither held nor awaited, and hence is available
394  * to be reclaimed. If nLocks > 0 then these pointers must either be valid or
395  * NULL, but when nLocks == 0 they should be considered garbage.
396  */
397 typedef struct LOCALLOCKTAG
398 {
399  LOCKTAG lock; /* identifies the lockable object */
400  LOCKMODE mode; /* lock mode for this table entry */
401 } LOCALLOCKTAG;
402 
403 typedef struct LOCALLOCKOWNER
404 {
405  /*
406  * Note: if owner is NULL then the lock is held on behalf of the session;
407  * otherwise it is held on behalf of my current transaction.
408  *
409  * Must use a forward struct reference to avoid circularity.
410  */
412  int64 nLocks; /* # of times held by this owner */
415 typedef struct LOCALLOCK
416 {
417  /* tag */
418  LOCALLOCKTAG tag; /* unique identifier of locallock entry */
420  /* data */
421  LOCK *lock; /* associated LOCK object, if any */
422  PROCLOCK *proclock; /* associated PROCLOCK object, if any */
423  uint32 hashcode; /* copy of LOCKTAG's hash value */
424  int64 nLocks; /* total number of times lock is held */
425  int numLockOwners; /* # of relevant ResourceOwners */
426  int maxLockOwners; /* allocated size of array */
427  bool holdsStrongLockCount; /* bumped FastPathStrongRelationLocks */
428  LOCALLOCKOWNER *lockOwners; /* dynamically resizable array */
429 } LOCALLOCK;
430 
431 #define LOCALLOCK_LOCKMETHOD(llock) ((llock).tag.lock.locktag_lockmethodid)
432 
433 
434 /*
435  * These structures hold information passed from lmgr internals to the lock
436  * listing user-level functions (in lockfuncs.c).
437  */
439 typedef struct LockInstanceData
440 {
441  LOCKTAG locktag; /* locked object */
442  LOCKMASK holdMask; /* locks held by this PGPROC */
443  LOCKMODE waitLockMode; /* lock awaited by this PGPROC, if any */
444  BackendId backend; /* backend ID of this PGPROC */
445  LocalTransactionId lxid; /* local transaction ID of this PGPROC */
446  int pid; /* pid of this PGPROC */
447  bool fastpath; /* taken via fastpath? */
450 typedef struct LockData
451 {
452  int nelements; /* The length of the array */
455 
457 /* Result codes for LockAcquire() */
458 typedef enum
459 {
460  LOCKACQUIRE_NOT_AVAIL, /* lock not available, and dontWait=true */
461  LOCKACQUIRE_OK, /* lock successfully acquired */
462  LOCKACQUIRE_ALREADY_HELD /* incremented count for lock already held */
465 /* Deadlock states identified by DeadLockCheck() */
466 typedef enum
467 {
468  DS_NOT_YET_CHECKED, /* no deadlock check has run yet */
469  DS_NO_DEADLOCK, /* no deadlock detected */
470  DS_SOFT_DEADLOCK, /* deadlock avoided by queue rearrangement */
471  DS_HARD_DEADLOCK, /* deadlock, no way out but ERROR */
472  DS_BLOCKED_BY_AUTOVACUUM /* no deadlock; queue blocked by autovacuum
473  * worker */
474 } DeadLockState;
475 
476 
477 /*
478  * The lockmgr's shared hash tables are partitioned to reduce contention.
479  * To determine which partition a given locktag belongs to, compute the tag's
480  * hash code with LockTagHashCode(), then apply one of these macros.
481  * NB: NUM_LOCK_PARTITIONS must be a power of 2!
482  */
483 #define LockHashPartition(hashcode) \
484  ((hashcode) % NUM_LOCK_PARTITIONS)
485 #define LockHashPartitionLock(hashcode) \
486  (&MainLWLockArray[LOCK_MANAGER_LWLOCK_OFFSET + \
487  LockHashPartition(hashcode)].lock)
488 #define LockHashPartitionLockByIndex(i) \
489  (&MainLWLockArray[LOCK_MANAGER_LWLOCK_OFFSET + (i)].lock)
490 
491 /*
492  * function prototypes
493  */
494 extern void InitLocks(void);
495 extern LockMethod GetLocksMethodTable(const LOCK *lock);
496 extern uint32 LockTagHashCode(const LOCKTAG *locktag);
497 extern bool DoLockModesConflict(LOCKMODE mode1, LOCKMODE mode2);
498 extern LockAcquireResult LockAcquire(const LOCKTAG *locktag,
499  LOCKMODE lockmode,
500  bool sessionLock,
501  bool dontWait);
502 extern LockAcquireResult LockAcquireExtended(const LOCKTAG *locktag,
503  LOCKMODE lockmode,
504  bool sessionLock,
505  bool dontWait,
506  bool report_memory_error);
507 extern void AbortStrongLockAcquire(void);
508 extern bool LockRelease(const LOCKTAG *locktag,
509  LOCKMODE lockmode, bool sessionLock);
510 extern void LockReleaseAll(LOCKMETHODID lockmethodid, bool allLocks);
511 extern void LockReleaseSession(LOCKMETHODID lockmethodid);
512 extern void LockReleaseCurrentOwner(LOCALLOCK **locallocks, int nlocks);
513 extern void LockReassignCurrentOwner(LOCALLOCK **locallocks, int nlocks);
514 extern bool LockHasWaiters(const LOCKTAG *locktag,
515  LOCKMODE lockmode, bool sessionLock);
516 extern VirtualTransactionId *GetLockConflicts(const LOCKTAG *locktag,
517  LOCKMODE lockmode);
518 extern void AtPrepare_Locks(void);
519 extern void PostPrepare_Locks(TransactionId xid);
520 extern int LockCheckConflicts(LockMethod lockMethodTable,
521  LOCKMODE lockmode,
522  LOCK *lock, PROCLOCK *proclock);
523 extern void GrantLock(LOCK *lock, PROCLOCK *proclock, LOCKMODE lockmode);
524 extern void GrantAwaitedLock(void);
525 extern void RemoveFromWaitQueue(PGPROC *proc, uint32 hashcode);
526 extern Size LockShmemSize(void);
528 
529 extern void ReportLockTableError(bool report);
531 typedef struct xl_standby_lock
532 {
533  TransactionId xid; /* xid of holder of AccessExclusiveLock */
534  Oid dbOid;
535  Oid relOid;
537 
538 extern xl_standby_lock *GetRunningTransactionLocks(int *nlocks);
539 extern const char *GetLockmodeName(LOCKMETHODID lockmethodid, LOCKMODE mode);
540 
541 extern void lock_twophase_recover(TransactionId xid, uint16 info,
542  void *recdata, uint32 len);
543 extern void lock_twophase_postcommit(TransactionId xid, uint16 info,
544  void *recdata, uint32 len);
545 extern void lock_twophase_postabort(TransactionId xid, uint16 info,
546  void *recdata, uint32 len);
548  void *recdata, uint32 len);
549 
550 extern DeadLockState DeadLockCheck(PGPROC *proc);
551 extern PGPROC *GetBlockingAutoVacuumPgproc(void);
552 extern void DeadLockReport(void) __attribute__((noreturn));
553 extern void RememberSimpleDeadLock(PGPROC *proc1,
554  LOCKMODE lockmode,
555  LOCK *lock,
556  PGPROC *proc2);
557 extern void InitDeadLockChecking(void);
558 
559 #ifdef LOCK_DEBUG
560 extern void DumpLocks(PGPROC *proc);
561 extern void DumpAllLocks(void);
562 #endif
563 
564 /* Lock a VXID (used to wait for a transaction to finish) */
566 extern void VirtualXactLockTableCleanup(void);
567 extern bool VirtualXactLock(VirtualTransactionId vxid, bool wait);
568 
569 #endif /* LOCK_H */