Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
670b4e10
提交
670b4e10
authored
7 年前
作者:
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 {
...
@@ -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.
* Lock the metadata table for updates.
*
*
...
@@ -913,6 +916,19 @@ public class Database implements DataHandler {
...
@@ -913,6 +916,19 @@ public class Database implements DataHandler {
if
(
meta
==
null
)
{
if
(
meta
==
null
)
{
return
true
;
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
);
boolean
wasLocked
=
meta
.
lock
(
session
,
true
,
true
);
return
wasLocked
;
return
wasLocked
;
}
}
...
@@ -923,10 +939,20 @@ public class Database implements DataHandler {
...
@@ -923,10 +939,20 @@ public class Database implements DataHandler {
* @param session the session
* @param session the session
*/
*/
public
void
unlockMeta
(
Session
session
)
{
public
void
unlockMeta
(
Session
session
)
{
unlockMetaDebug
(
session
);
meta
.
unlock
(
session
);
meta
.
unlock
(
session
);
session
.
unlock
(
meta
);
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.
* Remove the given object from the meta data.
*
*
...
@@ -956,6 +982,7 @@ public class Database implements DataHandler {
...
@@ -956,6 +982,7 @@ public class Database implements DataHandler {
checkMetaFree
(
session
,
id
);
checkMetaFree
(
session
,
id
);
}
}
}
else
if
(!
wasLocked
)
{
}
else
if
(!
wasLocked
)
{
unlockMetaDebug
(
session
);
// must not keep the lock if it was not locked
// must not keep the lock if it was not locked
// otherwise updating sequences may cause a deadlock
// otherwise updating sequences may cause a deadlock
meta
.
unlock
(
session
);
meta
.
unlock
(
session
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/engine/Session.java
浏览文件 @
670b4e10
...
@@ -856,6 +856,9 @@ public class Session extends SessionWithState {
...
@@ -856,6 +856,9 @@ public class Session extends SessionWithState {
removeTemporaryLobs
(
false
);
removeTemporaryLobs
(
false
);
cleanTempTables
(
true
);
cleanTempTables
(
true
);
// sometimes Table#removeChildrenAndResources
// will take the meta lock
database
.
unlockMeta
(
this
);
undoLog
.
clear
();
undoLog
.
clear
();
database
.
removeSession
(
this
);
database
.
removeSession
(
this
);
}
finally
{
}
finally
{
...
@@ -965,6 +968,7 @@ public class Session extends SessionWithState {
...
@@ -965,6 +968,7 @@ public class Session extends SessionWithState {
}
}
locks
.
clear
();
locks
.
clear
();
}
}
database
.
unlockMetaDebug
(
this
);
savepoints
=
null
;
savepoints
=
null
;
sessionStateChanged
=
true
;
sessionStateChanged
=
true
;
}
}
...
@@ -991,11 +995,6 @@ public class Session extends SessionWithState {
...
@@ -991,11 +995,6 @@ public class Session extends SessionWithState {
table
.
truncate
(
this
);
table
.
truncate
(
this
);
}
}
}
}
// sometimes Table#removeChildrenAndResources
// will take the meta lock
if
(
closeSession
)
{
database
.
unlockMeta
(
this
);
}
}
}
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论