Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
8abd4243
G
Gpdb
项目概览
Greenplum
/
Gpdb
通知
7
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
Gpdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
8abd4243
编写于
1月 28, 1998
作者:
B
Bruce Momjian
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
More deadlock code to check for escallation locks.
offsetof() addition to local socket size.
上级
54399bb2
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
111 addition
and
30 deletion
+111
-30
src/backend/storage/lmgr/README
src/backend/storage/lmgr/README
+9
-3
src/backend/storage/lmgr/lock.c
src/backend/storage/lmgr/lock.c
+93
-21
src/backend/storage/lmgr/proc.c
src/backend/storage/lmgr/proc.c
+5
-2
src/include/libpq/pqcomm.h
src/include/libpq/pqcomm.h
+4
-4
未找到文件。
src/backend/storage/lmgr/README
浏览文件 @
8abd4243
$Header: /cvsroot/pgsql/src/backend/storage/lmgr/README,v 1.
1.1.1 1996/07/09 06:21:55 scrappy
Exp $
$Header: /cvsroot/pgsql/src/backend/storage/lmgr/README,v 1.
2 1998/01/28 02:29:26 momjian
Exp $
This file is an attempt to save me (and future code maintainers) some
time and a lot of headaches. The existing lock manager code at the time
...
...
@@ -88,6 +88,12 @@ activeHolders -
holders, summing the values of activeHolders should total to the value
of nActive.
---------------------------------------------------------------------------
This is all I had the stomach for right now..... I will get back to this
someday. -mer 17 June 1992 12:00 am
Locks are accessed in two ways. Each PROC structure has a lockQueue,
that is a circular linked list of LOCK pointers that this process holds
or is waiting on.
Second, there is a hash table that can do a lookup by combined LOCK
address and transaction id(xid) which allows a process to see what
type of locks it holds on that table.
src/backend/storage/lmgr/lock.c
浏览文件 @
8abd4243
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lock.c,v 1.2
3 1998/01/27 15:34:49
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lock.c,v 1.2
4 1998/01/28 02:29:27
momjian Exp $
*
* NOTES
* Outside modules can create a lock table and acquire/release
...
...
@@ -755,7 +755,7 @@ LockResolveConflicts(LOCKTAB *ltable,
tmpMask
=
2
;
for
(
i
=
1
;
i
<=
nLockTypes
;
i
++
,
tmpMask
<<=
1
)
{
if
(
lock
->
activeHolders
[
i
]
-
myHolders
[
i
])
if
(
lock
->
activeHolders
[
i
]
!=
myHolders
[
i
])
{
bitmask
|=
tmpMask
;
}
...
...
@@ -1429,14 +1429,38 @@ DeadLockCheck(SHM_QUEUE *lockQueue, LOCK *findlock, bool skip_check)
XIDLookupEnt
*
tmp
=
NULL
;
SHMEM_OFFSET
end
=
MAKE_OFFSET
(
lockQueue
);
LOCK
*
lock
;
static
PROC
*
checked_procs
[
MaxBackendId
];
static
int
nprocs
;
LOCKTAB
*
ltable
;
XIDLookupEnt
*
result
,
item
;
HTAB
*
xidTable
;
bool
found
;
static
PROC
*
checked_procs
[
MaxBackendId
];
static
int
nprocs
;
static
bool
MyNHolding
;
/* initialize at start of recursion */
if
(
skip_check
)
{
/* initialize at start of recursion */
checked_procs
[
0
]
=
MyProc
;
nprocs
=
1
;
ltable
=
AllTables
[
1
];
xidTable
=
ltable
->
xidHash
;
MemSet
(
&
item
,
0
,
XID_TAGSIZE
);
TransactionIdStore
(
MyProc
->
xid
,
&
item
.
tag
.
xid
);
item
.
tag
.
lock
=
MAKE_OFFSET
(
findlock
);
#if 0
item.tag.pid = pid;
#endif
if
((
result
=
(
XIDLookupEnt
*
)
hash_search
(
xidTable
,
(
Pointer
)
&
item
,
HASH_FIND
,
&
found
))
&&
found
)
MyNHolding
=
result
->
nHolding
;
else
MyNHolding
=
0
;
}
if
(
SHMQueueEmpty
(
lockQueue
))
...
...
@@ -1469,13 +1493,7 @@ DeadLockCheck(SHM_QUEUE *lockQueue, LOCK *findlock, bool skip_check)
if
(
lock
==
findlock
&&
!
skip_check
)
return
true
;
/*
* No sense in looking at the wait queue of the lock we are
* looking for as it is MyProc's lock entry.
* If lock == findlock, and I got here, skip_check must be true.
*/
if
(
lock
!=
findlock
)
{
{
PROC_QUEUE
*
waitQueue
=
&
(
lock
->
waitProcs
);
PROC
*
proc
;
int
i
;
...
...
@@ -1484,16 +1502,70 @@ DeadLockCheck(SHM_QUEUE *lockQueue, LOCK *findlock, bool skip_check)
proc
=
(
PROC
*
)
MAKE_PTR
(
waitQueue
->
links
.
prev
);
for
(
i
=
0
;
i
<
waitQueue
->
size
;
i
++
)
{
for
(
j
=
0
;
j
<
nprocs
;
j
++
)
if
(
checked_procs
[
j
]
==
proc
)
break
;
if
(
j
>=
nprocs
)
if
(
proc
!=
MyProc
&&
lock
==
findlock
&&
/* skip_check also true */
MyNHolding
)
/* I already hold some lock on it */
{
/*
* For findlock's wait queue, we are interested in
* procs who are blocked waiting for a write-lock on the
* table we are waiting on, and already hold a lock on it.
* We first check to see if there is an escalation
* deadlock, where we hold a readlock and want a
* writelock, and someone else holds readlock on
* the same table, and wants a writelock.
*
* Basically, the test is, "Do we both hold some lock
* on findlock, and we are both waiting in the lock
* queue?"
*/
Assert
(
skip_check
);
Assert
(
MyProc
->
prio
==
2
);
ltable
=
AllTables
[
1
];
xidTable
=
ltable
->
xidHash
;
MemSet
(
&
item
,
0
,
XID_TAGSIZE
);
TransactionIdStore
(
proc
->
xid
,
&
item
.
tag
.
xid
);
item
.
tag
.
lock
=
MAKE_OFFSET
(
findlock
);
#if 0
item.tag.pid = pid;
#endif
if
((
result
=
(
XIDLookupEnt
*
)
hash_search
(
xidTable
,
(
Pointer
)
&
item
,
HASH_FIND
,
&
found
))
&&
found
)
{
if
(
result
->
nHolding
)
return
true
;
}
}
/*
* No sense in looking at the wait queue of the lock we are
* looking for.
* If lock == findlock, and I got here, skip_check must be
* true too.
*/
if
(
lock
!=
findlock
)
{
checked_procs
[
nprocs
++
]
=
proc
;
Assert
(
nprocs
<=
MaxBackendId
);
/* If we found a deadlock, we can stop right now */
if
(
DeadLockCheck
(
&
(
proc
->
lockQueue
),
findlock
,
false
))
return
true
;
for
(
j
=
0
;
j
<
nprocs
;
j
++
)
if
(
checked_procs
[
j
]
==
proc
)
break
;
if
(
j
>=
nprocs
&&
lock
!=
findlock
)
{
checked_procs
[
nprocs
++
]
=
proc
;
Assert
(
nprocs
<=
MaxBackendId
);
/*
* For non-MyProc entries, we are looking only waiters,
* not necessarily people who already hold locks and are
* waiting.
* Now we check for cases where we have two or more
* tables in a deadlock. We do this by continuing
* to search for someone holding a lock
*/
if
(
DeadLockCheck
(
&
(
proc
->
lockQueue
),
findlock
,
false
))
return
true
;
}
}
proc
=
(
PROC
*
)
MAKE_PTR
(
proc
->
links
.
prev
);
}
...
...
src/backend/storage/lmgr/proc.c
浏览文件 @
8abd4243
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.
29 1998/01/27 03:00
:29 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.
30 1998/01/28 02:29
:29 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.
29 1998/01/27 03:00
:29 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.
30 1998/01/28 02:29
:29 momjian Exp $
*/
#include <sys/time.h>
#include <unistd.h>
...
...
@@ -249,7 +249,10 @@ InitProcess(IPCKey key)
*/
SpinRelease
(
ProcStructLock
);
MyProc
->
pid
=
0
;
#if 0
MyProc->pid = MyProcPid;
#endif
MyProc
->
xid
=
InvalidTransactionId
;
/* ----------------
...
...
src/include/libpq/pqcomm.h
浏览文件 @
8abd4243
...
...
@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: pqcomm.h,v 1.2
1 1998/01/27 15:35:22
momjian Exp $
* $Id: pqcomm.h,v 1.2
2 1998/01/28 02:29:40
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -35,10 +35,10 @@ typedef union SockAddr {
#define UNIXSOCK_PATH(sun,port) \
(sprintf((sun).sun_path, "/tmp/.s.PGSQL.%d", (port)) + \
+ 1 + sizeof ((sun).sun_family
))
offsetof(struct sockaddr_un, sun_path
))
/*
*
+ 1 is for BSD-specific sizeof((sun).sun_len)
* We never actually set sun_len, and I can't think of a
*
We do this because sun_len is in BSD's struct, while others don't.
* We never actually set
BSD's
sun_len, and I can't think of a
* platform-safe way of doing it, but the code still works. bjm
*/
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录