mirror of
https://github.com/postgres/postgres.git
synced 2025-07-31 22:04:40 +03:00
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.
This commit is contained in:
@ -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);
|
||||
|
Reference in New Issue
Block a user