Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
b49019f1
提交
b49019f1
authored
12月 20, 2016
作者:
Noel Grandin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add watchdog when running tests
to give us a thread dump when they get stuck
上级
6ca8e8dd
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
31 行增加
和
6 行删除
+31
-6
ThreadDeadlockDetector.java
h2/src/main/org/h2/util/ThreadDeadlockDetector.java
+15
-5
TestAll.java
h2/src/test/org/h2/test/TestAll.java
+16
-1
没有找到文件。
h2/src/main/org/h2/util/ThreadDeadlockDetector.java
浏览文件 @
b49019f1
...
@@ -16,7 +16,6 @@ import java.util.ArrayList;
...
@@ -16,7 +16,6 @@ import java.util.ArrayList;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Timer
;
import
java.util.Timer
;
import
java.util.TimerTask
;
import
java.util.TimerTask
;
import
org.h2.mvstore.db.MVTable
;
import
org.h2.mvstore.db.MVTable
;
/**
/**
...
@@ -60,16 +59,27 @@ public class ThreadDeadlockDetector {
...
@@ -60,16 +59,27 @@ public class ThreadDeadlockDetector {
* information.
* information.
*/
*/
void
checkForDeadlocks
()
{
void
checkForDeadlocks
()
{
long
[]
i
ds
=
threadBean
.
findDeadlockedThreads
();
long
[]
deadlockedThreadI
ds
=
threadBean
.
findDeadlockedThreads
();
if
(
i
ds
==
null
)
{
if
(
deadlockedThreadI
ds
==
null
)
{
return
;
return
;
}
}
dumpThreadsAndLocks
(
"ThreadDeadlockDetector - deadlock found :"
,
threadBean
,
deadlockedThreadIds
);
}
public
static
void
dumpAllThreadsAndLocks
(
String
msg
)
{
final
ThreadMXBean
threadBean
=
ManagementFactory
.
getThreadMXBean
();
final
long
[]
allThreadIds
=
threadBean
.
getAllThreadIds
();
dumpThreadsAndLocks
(
msg
,
threadBean
,
allThreadIds
);
}
private
static
void
dumpThreadsAndLocks
(
String
msg
,
ThreadMXBean
threadBean
,
long
[]
threadIds
)
{
final
StringWriter
stringWriter
=
new
StringWriter
();
final
StringWriter
stringWriter
=
new
StringWriter
();
final
PrintWriter
print
=
new
PrintWriter
(
stringWriter
);
final
PrintWriter
print
=
new
PrintWriter
(
stringWriter
);
print
.
println
(
"ThreadDeadlockDetector - deadlock found :"
);
print
.
println
(
msg
);
final
ThreadInfo
[]
infos
=
threadBean
.
getThreadInfo
(
i
ds
,
true
,
true
);
final
ThreadInfo
[]
infos
=
threadBean
.
getThreadInfo
(
threadI
ds
,
true
,
true
);
final
HashMap
<
Long
,
String
>
tableWaitingForLockMap
=
final
HashMap
<
Long
,
String
>
tableWaitingForLockMap
=
MVTable
.
WAITING_FOR_LOCK
.
getSnapshotOfAllThreads
();
MVTable
.
WAITING_FOR_LOCK
.
getSnapshotOfAllThreads
();
final
HashMap
<
Long
,
ArrayList
<
String
>>
tableExclusiveLocksMap
=
final
HashMap
<
Long
,
ArrayList
<
String
>>
tableExclusiveLocksMap
=
...
...
h2/src/test/org/h2/test/TestAll.java
浏览文件 @
b49019f1
...
@@ -9,6 +9,7 @@ import java.lang.management.ManagementFactory;
...
@@ -9,6 +9,7 @@ import java.lang.management.ManagementFactory;
import
java.sql.SQLException
;
import
java.sql.SQLException
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Properties
;
import
java.util.Properties
;
import
java.util.TimerTask
;
import
org.h2.Driver
;
import
org.h2.Driver
;
import
org.h2.engine.Constants
;
import
org.h2.engine.Constants
;
import
org.h2.store.fs.FilePathRec
;
import
org.h2.store.fs.FilePathRec
;
...
@@ -224,6 +225,7 @@ import org.h2.util.New;
...
@@ -224,6 +225,7 @@ import org.h2.util.New;
import
org.h2.util.Profiler
;
import
org.h2.util.Profiler
;
import
org.h2.util.StringUtils
;
import
org.h2.util.StringUtils
;
import
org.h2.util.Task
;
import
org.h2.util.Task
;
import
org.h2.util.ThreadDeadlockDetector
;
import
org.h2.util.Utils
;
import
org.h2.util.Utils
;
/**
/**
...
@@ -920,7 +922,20 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`
...
@@ -920,7 +922,20 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`
// tests.add(test);
// tests.add(test);
// run directly for now, because concurrently running tests
// run directly for now, because concurrently running tests
// fails on Raspberry Pi quite often (seems to be a JVM problem)
// fails on Raspberry Pi quite often (seems to be a JVM problem)
// event queue watchdog for tests that get stuck when running in Jenkins CI
final
java
.
util
.
Timer
watchdog
=
new
java
.
util
.
Timer
();
watchdog
.
schedule
(
new
TimerTask
()
{
@Override
public
void
run
()
{
ThreadDeadlockDetector
.
dumpAllThreadsAndLocks
(
"test watchdog timed out"
);
}
},
5
*
60
*
1000
);
// 5 minutes
try
{
test
.
runTest
(
this
);
test
.
runTest
(
this
);
}
finally
{
watchdog
.
cancel
();
}
}
}
private
void
runAddedTests
()
{
private
void
runAddedTests
()
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论