From 661bb388123420d70a8a78c55cc6fc81705b77c0 Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Fri, 23 Jan 1998 06:01:36 +0000 Subject: [PATCH] Cleanup deadlock message. --- src/backend/storage/lmgr/lock.c | 5 ++--- src/backend/storage/lmgr/proc.c | 7 ++++--- src/include/storage/proc.h | 5 ++--- src/man/lock.l | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 41 insertions(+), 9 deletions(-) create mode 100644 src/man/lock.l diff --git a/src/backend/storage/lmgr/lock.c b/src/backend/storage/lmgr/lock.c index 2057329222..640c36e5d1 100644 --- a/src/backend/storage/lmgr/lock.c +++ b/src/backend/storage/lmgr/lock.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lock.c,v 1.18 1998/01/07 21:05:32 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lock.c,v 1.19 1998/01/23 06:01:03 momjian Exp $ * * NOTES * Outside modules can create a lock table and acquire/release @@ -48,8 +48,7 @@ #include "access/xact.h" #include "access/transam.h" -static int -WaitOnLock(LOCKTAB *ltable, LockTableId tableId, LOCK *lock, +static int WaitOnLock(LOCKTAB *ltable, LockTableId tableId, LOCK *lock, LOCKT lockt); /*#define LOCK_MGR_DEBUG*/ diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 7d91398b22..1df06815bf 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.25 1998/01/07 21:05:36 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.26 1998/01/23 06:01:05 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -46,7 +46,7 @@ * This is so that we can support more backends. (system-wide semaphore * sets run out pretty fast.) -ay 4/95 * - * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.25 1998/01/07 21:05:36 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.26 1998/01/23 06:01:05 momjian Exp $ */ #include #include @@ -729,7 +729,8 @@ HandleDeadLock(int sig) */ UnlockLockTable(); - elog(NOTICE, "Timeout -- possible deadlock"); + elog(NOTICE, "Timeout interval reached -- possible deadlock."); + elog(NOTICE, "See the lock(l) manual page for a possible cause."); return; } diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 5a7c85b0b1..e58758a8c6 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: proc.h,v 1.8 1997/09/08 21:54:32 momjian Exp $ + * $Id: proc.h,v 1.9 1998/01/23 06:01:25 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -102,8 +102,7 @@ extern bool ProcRemove(int pid); /* make static in storage/lmgr/proc.c -- jolly */ extern void ProcQueueInit(PROC_QUEUE *queue); -extern int -ProcSleep(PROC_QUEUE *queue, SPINLOCK spinlock, int token, +extern int ProcSleep(PROC_QUEUE *queue, SPINLOCK spinlock, int token, int prio, LOCK *lock); extern int ProcLockWakeup(PROC_QUEUE *queue, char *ltable, char *lock); extern void ProcAddLock(SHM_QUEUE *elem); diff --git a/src/man/lock.l b/src/man/lock.l new file mode 100644 index 0000000000..8882cf15fb --- /dev/null +++ b/src/man/lock.l @@ -0,0 +1,33 @@ +.\" This is -*-nroff-*- +.\" XXX standard disclaimer belongs here.... +.\" $Header: /cvsroot/pgsql/src/man/Attic/lock.l,v 1.1 1998/01/23 06:01:36 momjian Exp $ +.TH FETCH SQL 01/23/93 PostgreSQL PostgreSQL +.SH NAME +lock - exclusive lock a table +.SH SYNOPSIS +.nf +\fBlock\fR classname +.fi +.SH DESCRIPTION +.BR lock +exclusive locks a table inside a transaction. The classic use for this +is the case where you want to \fBselect\fP some data, then update it +inside a transaction. If you don't exclusive lock the table before the +\fBselect\fP, some other user may also read the selected data, and try +and do their own \fBupdate\fP, causing a deadlock while you both wait +for the other to release the \fBselect\fP-induced shared lock so you can +get an exclusive lock to do the \fBupdate.\fP +.SH EXAMPLES +.nf +-- +-- Proper locking to prevent deadlock +-- +begin work; +lock mytable; +select * from mytable; +update mytable set (x = 100); +end work; +.SH "SEE ALSO" +begin(l), +end(l), +select(l). -- 2.11.0