Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
670b4e10
提交
670b4e10
authored
11月 17, 2017
作者:
Noel Grandin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add some debugging for meta locking
上级
14d4d8ee
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
31 行增加
和
5 行删除
+31
-5
Database.java
h2/src/main/org/h2/engine/Database.java
+27
-0
Session.java
h2/src/main/org/h2/engine/Session.java
+4
-5
没有找到文件。
h2/src/main/org/h2/engine/Database.java
浏览文件 @
670b4e10
...
...
@@ -899,6 +899,9 @@ public class Database implements DataHandler {
}
}
private
static
final
ThreadLocal
<
Session
>
metaLockDebugging
=
new
ThreadLocal
<
Session
>();
private
static
final
ThreadLocal
<
Throwable
>
metaLockDebuggingStack
=
new
ThreadLocal
<
Throwable
>();
/**
* Lock the metadata table for updates.
*
...
...
@@ -913,6 +916,19 @@ public class Database implements DataHandler {
if
(
meta
==
null
)
{
return
true
;
}
if
(
SysProperties
.
CHECK2
)
{
final
Session
prev
=
metaLockDebugging
.
get
();
if
(
prev
==
null
)
{
metaLockDebugging
.
set
(
session
);
metaLockDebuggingStack
.
set
(
new
Throwable
());
}
else
if
(
prev
!=
session
)
{
metaLockDebuggingStack
.
get
().
printStackTrace
();
throw
new
IllegalStateException
(
"meta currently locked by "
+
prev
+
" and trying to be locked by different session, "
+
session
+
" on same thread"
);
}
}
boolean
wasLocked
=
meta
.
lock
(
session
,
true
,
true
);
return
wasLocked
;
}
...
...
@@ -923,10 +939,20 @@ public class Database implements DataHandler {
* @param session the session
*/
public
void
unlockMeta
(
Session
session
)
{
unlockMetaDebug
(
session
);
meta
.
unlock
(
session
);
session
.
unlock
(
meta
);
}
public
void
unlockMetaDebug
(
Session
session
)
{
if
(
SysProperties
.
CHECK2
)
{
if
(
metaLockDebugging
.
get
()
==
session
)
{
metaLockDebugging
.
set
(
null
);
metaLockDebuggingStack
.
set
(
null
);
}
}
}
/**
* Remove the given object from the meta data.
*
...
...
@@ -956,6 +982,7 @@ public class Database implements DataHandler {
checkMetaFree
(
session
,
id
);
}
}
else
if
(!
wasLocked
)
{
unlockMetaDebug
(
session
);
// must not keep the lock if it was not locked
// otherwise updating sequences may cause a deadlock
meta
.
unlock
(
session
);
...
...
h2/src/main/org/h2/engine/Session.java
浏览文件 @
670b4e10
...
...
@@ -856,6 +856,9 @@ public class Session extends SessionWithState {
removeTemporaryLobs
(
false
);
cleanTempTables
(
true
);
// sometimes Table#removeChildrenAndResources
// will take the meta lock
database
.
unlockMeta
(
this
);
undoLog
.
clear
();
database
.
removeSession
(
this
);
}
finally
{
...
...
@@ -965,6 +968,7 @@ public class Session extends SessionWithState {
}
locks
.
clear
();
}
database
.
unlockMetaDebug
(
this
);
savepoints
=
null
;
sessionStateChanged
=
true
;
}
...
...
@@ -991,11 +995,6 @@ public class Session extends SessionWithState {
table
.
truncate
(
this
);
}
}
// sometimes Table#removeChildrenAndResources
// will take the meta lock
if
(
closeSession
)
{
database
.
unlockMeta
(
this
);
}
}
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论