Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb4564a9

Browse files
committed
Deadlock ceallnup.
(void) change for aix and hp compilers.protocol cleanup.
1 parentf49d413 commitb4564a9

File tree

8 files changed

+62
-22
lines changed

8 files changed

+62
-22
lines changed

‎src/backend/parser/parse_func.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.8 1998/01/20 22:11:55 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.9 1998/01/27 15:34:39 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -728,7 +728,7 @@ func_get_detail(char *funcname,
728728
funcname);
729729
elog(NOTICE,"that satisfies the given argument types. you will have to");
730730
elog(NOTICE,"retype your query using explicit typecasts.");
731-
func_error("func_get_detail",funcname,nargs,oid_array);
731+
func_error("",funcname,nargs,oid_array);
732732
}
733733
else
734734
{
@@ -758,7 +758,7 @@ func_get_detail(char *funcname,
758758
elog(ERROR,"no such attribute or function \"%s\"",
759759
funcname);
760760
}
761-
func_error("func_get_detail",funcname,nargs,oid_array);
761+
func_error("",funcname,nargs,oid_array);
762762
}
763763
else
764764
{

‎src/backend/postmaster/postmaster.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.71 1998/01/2703:11:46 momjian Exp $
13+
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.72 1998/01/2715:34:43 momjian Exp $
1414
*
1515
* NOTES
1616
*
@@ -473,7 +473,7 @@ pmdaemonize(void)
473473
inti;
474474

475475
if (fork())
476-
exit(0);
476+
_exit(0);
477477
/* GH: If there's no setsid(), we hopefully don't need silent mode.
478478
* Until there's a better solution.
479479
*/

‎src/backend/storage/lmgr/lock.c

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lock.c,v 1.22 1998/01/2703:00:28 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lock.c,v 1.23 1998/01/2715:34:49 momjian Exp $
1111
*
1212
* NOTES
1313
* Outside modules can create a lock table and acquire/release
1414
* locks. A lock table is a shared memory hash table. When
15-
* a process tries to acquire a lock of a type thatconflicts
15+
* a process tries to acquire a lock of a type thatconflictRs
1616
* with existing locks, it is put to sleep using the routines
1717
* in storage/lmgr/proc.c.
1818
*
@@ -39,6 +39,7 @@
3939
#include"postgres.h"
4040
#include"miscadmin.h"
4141
#include"storage/shmem.h"
42+
#include"storage/sinvaladt.h"
4243
#include"storage/spin.h"
4344
#include"storage/proc.h"
4445
#include"storage/lock.h"
@@ -1415,7 +1416,8 @@ LockingDisabled()
14151416
*
14161417
* This code takes a list of locks a process holds, and the lock that
14171418
* the process is sleeping on, and tries to find if any of the processes
1418-
* waiting on its locks hold the lock it is waiting for.
1419+
* waiting on its locks hold the lock it is waiting for. If no deadlock
1420+
* is found, it goes on to look at all the processes waiting on their locks.
14191421
*
14201422
* We have already locked the master lock before being called.
14211423
*/
@@ -1427,7 +1429,16 @@ DeadLockCheck(SHM_QUEUE *lockQueue, LOCK *findlock, bool skip_check)
14271429
XIDLookupEnt*tmp=NULL;
14281430
SHMEM_OFFSETend=MAKE_OFFSET(lockQueue);
14291431
LOCK*lock;
1432+
staticPROC*checked_procs[MaxBackendId];
1433+
staticintnprocs;
14301434

1435+
if (skip_check)
1436+
{
1437+
/* initialize at start of recursion */
1438+
checked_procs[0]=MyProc;
1439+
nprocs=1;
1440+
}
1441+
14311442
if (SHMQueueEmpty(lockQueue))
14321443
return false;
14331444

@@ -1457,18 +1468,29 @@ DeadLockCheck(SHM_QUEUE *lockQueue, LOCK *findlock, bool skip_check)
14571468
*/
14581469
if (lock==findlock&& !skip_check)
14591470
return true;
1460-
elseif (lock!=findlock|| !skip_check)
1471+
1472+
/*
1473+
*No sense in looking at the wait queue of the lock we are
1474+
*looking for as it is MyProc's lock entry.
1475+
* If lock == findlock, and I got here, skip_check must be true.
1476+
*/
1477+
if (lock!=findlock)
14611478
{
14621479
PROC_QUEUE*waitQueue=&(lock->waitProcs);
14631480
PROC*proc;
14641481
inti;
1482+
intj;
14651483

14661484
proc= (PROC*)MAKE_PTR(waitQueue->links.prev);
14671485
for (i=0;i<waitQueue->size;i++)
14681486
{
1469-
/* prevent endless loops */
1470-
if (proc!=MyProc&&skip_check)
1487+
for (j=0;j<nprocs;j++)
1488+
if (checked_procs[j]==proc)
1489+
break;
1490+
if (j >=nprocs)
14711491
{
1492+
checked_procs[nprocs++]=proc;
1493+
Assert(nprocs <=MaxBackendId);
14721494
/* If we found a deadlock, we can stop right now */
14731495
if (DeadLockCheck(&(proc->lockQueue),findlock, false))
14741496
return true;

‎src/include/access/heapam.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: heapam.h,v 1.24 1998/01/25 05:04:21 scrappy Exp $
9+
* $Id: heapam.h,v 1.25 1998/01/27 15:35:18 momjian Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -101,10 +101,10 @@ typedef HeapAccessStatisticsData *HeapAccessStatistics;
101101
#defineheap_getattr(tup,b,attnum,tupleDesc,isnull) \
102102
(AssertMacro((tup) != NULL) ? \
103103
((attnum) > (int) (tup)->t_natts) ? \
104-
(((isnull) ? (*(isnull) = true) :(void)NULL), (Datum)NULL) : \
104+
(((isnull) ? (*(isnull) = true) :dummyretNULL), (Datum)NULL) : \
105105
((attnum) > 0) ? \
106106
fastgetattr((tup), (attnum), (tupleDesc), (isnull)) : \
107-
(((isnull) ? (*(isnull) = false) :(void)NULL), heap_getsysattr((tup), (b), (attnum))) : \
107+
(((isnull) ? (*(isnull) = false) :dummyretNULL), heap_getsysattr((tup), (b), (attnum))) : \
108108
(Datum)NULL)
109109

110110
externHeapAccessStatisticsheap_access_stats;/* in stats.c */

‎src/include/c.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
* Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: c.h,v 1.29 1998/01/26 01:41:49 scrappy Exp $
10+
* $Id: c.h,v 1.30 1998/01/27 15:35:00 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -181,8 +181,18 @@ typedef char *Pointer;
181181

182182
#endif/* !HAVE_ANSI_CPP */
183183

184+
#ifndef__GNUC__/* GNU cc */
185+
#endif
186+
184187
#ifndef__GNUC__/* GNU cc */
185188
#defineinline
189+
/*
190+
* dummyret is used to set return values in macros that use ?: to make
191+
* assignments. gcc wants these to be void, other compilers like char
192+
*/
193+
#definedummyretchar
194+
#else
195+
#definedummyretvoid
186196
#endif
187197

188198
#if defined(NEED_STD_HDRS)
@@ -693,7 +703,7 @@ typedef struct Exception
693703
*/
694704
/* we do this so if the macro is used in an if action, it will work */
695705
#defineStrNCpy(dst,src,len)\
696-
(strncpy((dst),(src),(len)),(len > 0) ? *((dst)+(len)-1)='\0' : (void)NULL,(void)(dst))
706+
(strncpy((dst),(src),(len)),(len > 0) ? *((dst)+(len)-1)='\0' : (dummyret)NULL,(void)(dst))
697707

698708
/* Get a bit mask of the bits set in non-int32 aligned addresses */
699709
#defineINT_ALIGN_MASK (sizeof(int32) - 1)

‎src/include/config.h.in

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,6 @@ extern void srandom(int seed);
216216
* number of seconds.
217217
* We don't check for deadlocks just before sleeping because a deadlock is
218218
* a rare event, and checking is an expensive operation.
219-
* We only detect deadlocks between two processes, not three or more, but
220-
* these are the most common.
221219
*/
222220
#defineDEADLOCK_CHECK_TIMER 60
223221

‎src/include/libpq/pqcomm.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: pqcomm.h,v 1.20 1998/01/2704:08:28 momjian Exp $
9+
* $Id: pqcomm.h,v 1.21 1998/01/2715:35:22 momjian Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -35,8 +35,12 @@ typedef union SockAddr {
3535

3636
#defineUNIXSOCK_PATH(sun,port) \
3737
(sprintf((sun).sun_path, "/tmp/.s.PGSQL.%d", (port)) + \
38-
sizeof ((sun).sun_len) + sizeof ((sun).sun_family))
39-
38+
+ 1 + sizeof ((sun).sun_family))
39+
/*
40+
*+ 1 is for BSD-specific sizeof((sun).sun_len)
41+
*We never actually set sun_len, and I can't think of a
42+
*platform-safe way of doing it, but the code still works. bjm
43+
*/
4044

4145
/*
4246
* These manipulate the frontend/backend protocol version number.

‎src/man/lock.l

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.\" This is -*-nroff-*-
22
.\" XXX standard disclaimer belongs here....
3-
.\" $Header: /cvsroot/pgsql/src/man/Attic/lock.l,v 1.1 1998/01/23 06:01:36 momjian Exp $
3+
.\" $Header: /cvsroot/pgsql/src/man/Attic/lock.l,v 1.2 1998/01/27 15:35:30 momjian Exp $
44
.TH FETCH SQL 01/23/93 PostgreSQL PostgreSQL
55
.SH NAME
66
lock - exclusive lock a table
@@ -17,6 +17,12 @@ inside a transaction. If you don't exclusive lock the table before the
1717
and do their own\fBupdate\fP, causing a deadlock while you both wait
1818
for the other to release the\fBselect\fP-induced shared lock so you can
1919
get an exclusive lock to do the\fBupdate.\fP
20+
.PP
21+
Another example of deadlock is where one user locks one table, and
22+
another user locks a second table. While both keep their existing
23+
locks, the first user tries to lock the second user's table, and the
24+
second user tries to lock the first user's table. Both users deadlock
25+
waiting for the tables to become available.
2026
.SH EXAMPLES
2127
.nf
2228
--

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp