summaryrefslogtreecommitdiff
path: root/src/include/storage/proc.h
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2000-12-22 00:51:54 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2000-12-22 00:51:54 +0000
commit6cc842abd340b6f4c3f9e5f49d59805174959f7e (patch)
tree5f92c6b6eb7fd9e556967f0e4ee1a9480fb2fd8e /src/include/storage/proc.h
parentb2145e9365ee38c68b74dae3dca803696cba69b4 (diff)
Revise lock manager to support "session level" locks as well as "transaction
level" locks. A session lock is not released at transaction commit (but it is released on transaction abort, to ensure recovery after an elog(ERROR)). In VACUUM, use a session lock to protect the master table while vacuuming a TOAST table, so that the TOAST table can be done in an independent transaction. I also took this opportunity to do some cleanup and renaming in the lock code. The previously noted bug in ProcLockWakeup, that it couldn't wake up any waiters beyond the first non-wakeable waiter, is now fixed. Also found a previously unknown bug of the same kind (failure to scan all members of a lock queue in some cases) in DeadLockCheck. This might have led to failure to detect a deadlock condition, resulting in indefinite waits, but it's difficult to characterize the conditions required to trigger a failure.
Diffstat (limited to 'src/include/storage/proc.h')
-rw-r--r--src/include/storage/proc.h30
1 files changed, 19 insertions, 11 deletions
diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h
index 41305d80831..96928eb4528 100644
--- a/src/include/storage/proc.h
+++ b/src/include/storage/proc.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: proc.h,v 1.32 2000/11/28 23:27:57 tgl Exp $
+ * $Id: proc.h,v 1.33 2000/12/22 00:51:54 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -30,7 +30,7 @@ typedef struct
/*
* Each backend has:
*/
-typedef struct proc
+struct proc
{
/* proc->links MUST BE THE FIRST ELEMENT OF STRUCT (see ProcWakeup()) */
@@ -50,16 +50,25 @@ typedef struct proc
TransactionId xmin; /* minimal running XID as it was when we
* were starting our xact: vacuum must not
* remove tuples deleted by xid >= xmin ! */
+
XLogRecPtr logRec;
- LOCK *waitLock; /* Lock we're sleeping on ... */
- int token; /* type of lock we sleeping for */
- int holdLock; /* while holding these locks */
+
+ /* Info about lock the process is currently waiting for, if any */
+ LOCK *waitLock; /* Lock object we're sleeping on ... */
+ HOLDER *waitHolder; /* Per-holder info for our lock */
+ LOCKMODE waitLockMode; /* type of lock we're waiting for */
+ LOCKMASK holdLock; /* bitmask for lock types already held */
+
int pid; /* This backend's process id */
Oid databaseId; /* OID of database this backend is using */
+
short sLocks[MAX_SPINS]; /* Spin lock stats */
SHM_QUEUE lockQueue; /* locks associated with current
* transaction */
-} PROC;
+};
+
+/* NOTE: "typedef struct proc PROC" appears in storage/lock.h. */
+
extern PROC *MyProc;
@@ -122,15 +131,14 @@ typedef struct procglobal
*/
extern void InitProcGlobal(int maxBackends);
extern void InitProcess(void);
-extern void ProcReleaseLocks(void);
+extern void ProcReleaseLocks(bool isCommit);
extern bool ProcRemove(int pid);
extern void ProcQueueInit(PROC_QUEUE *queue);
-extern int ProcSleep(PROC_QUEUE *queue, LOCKMETHODCTL *lockctl, int token,
- LOCK *lock);
+extern int ProcSleep(LOCKMETHODCTL *lockctl, LOCKMODE lockmode,
+ LOCK *lock, HOLDER *holder);
extern PROC *ProcWakeup(PROC *proc, int errType);
-extern int ProcLockWakeup(PROC_QUEUE *queue, LOCKMETHOD lockmethod,
- LOCK *lock);
+extern int ProcLockWakeup(LOCKMETHOD lockmethod, LOCK *lock);
extern void ProcAddLock(SHM_QUEUE *elem);
extern void ProcReleaseSpins(PROC *proc);
extern void LockWaitCancel(void);