Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
a361c578
提交
a361c578
authored
12月 01, 2017
作者:
Owner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added more logging for TestMvccMultiThreaded2 test
上级
7ec44b57
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
51 行增加
和
14 行删除
+51
-14
MVTable.java
h2/src/main/org/h2/mvstore/db/MVTable.java
+1
-0
TestGeneralCommonTableQueries.java
...rc/test/org/h2/test/db/TestGeneralCommonTableQueries.java
+9
-11
TestMvccMultiThreaded2.java
h2/src/test/org/h2/test/mvcc/TestMvccMultiThreaded2.java
+41
-3
没有找到文件。
h2/src/main/org/h2/mvstore/db/MVTable.java
浏览文件 @
a361c578
...
...
@@ -49,6 +49,7 @@ import org.h2.value.Value;
*/
public
class
MVTable
extends
TableBase
{
// lock event types for tracing...
private
static
final
String
TRACE_LOCK_OK
=
"ok"
;
private
static
final
String
TRACE_LOCK_WAITING_FOR
=
"waiting for"
;
private
static
final
String
TRACE_LOCK_REQUESTING_FOR
=
"requesting for"
;
...
...
h2/src/test/org/h2/test/db/TestGeneralCommonTableQueries.java
浏览文件 @
a361c578
...
...
@@ -41,7 +41,7 @@ public class TestGeneralCommonTableQueries extends AbstractBaseForCommonTableExp
testMerge
();
testCreateTable
();
testNestedSQL
();
test
LazyQueryExecutionAndRecursiveTable
();
test
Simple4RowRecursiveQuery
();
}
private
void
testSimpleSelect
()
throws
Exception
{
...
...
@@ -470,20 +470,18 @@ public class TestGeneralCommonTableQueries extends AbstractBaseForCommonTableExp
deleteDb
(
"commonTableExpressionQueries"
);
}
private
void
test
LazyQueryExecutionAndRecursiveTable
()
throws
Exception
{
private
void
test
Simple4RowRecursiveQuery
()
throws
Exception
{
String
[]
expectedRowData
=
new
String
[]{
"|1"
,
"|2"
,
"|3"
};
String
[]
expectedColumnTypes
=
new
String
[]{
"INTEGER"
};
String
[]
expectedColumnNames
=
new
String
[]{
"N"
};
//Test lazy mvStore memory mvcc multiThreaded
String
SETUP_SQL
=
"SET LAZY_QUERY_EXECUTION 1;\n"
//+ "SET MEMORY 1;SET MV_STORE true; SET MVCC TRUE;"
//+ "SET MULTI_THREADED TRUE;"
;
String
SETUP_SQL
=
"-- do nothing"
;
String
WITH_QUERY
=
"with recursive r(n) as (\n"
+
"(select 1) union all (select n+1 from r where n < 3)\n"
+
")\n"
+
"select n from r"
;
int
maxRetries
=
3
;
int
expectedNumberOfRows
=
expectedRowData
.
length
;
...
...
h2/src/test/org/h2/test/mvcc/TestMvccMultiThreaded2.java
浏览文件 @
a361c578
...
...
@@ -20,6 +20,10 @@ import org.h2.util.IOUtils;
*/
public
class
TestMvccMultiThreaded2
extends
TestBase
{
private
static
final
int
TEST_THREAD_COUNT
=
100
;
private
static
final
int
TEST_TIME_SECONDS
=
60
;
private
static
final
boolean
DISPLAY_STATS
=
false
;
private
static
final
String
URL
=
";MVCC=TRUE;LOCK_TIMEOUT=120000;MULTI_THREADED=TRUE"
;
/**
...
...
@@ -62,14 +66,36 @@ public class TestMvccMultiThreaded2 extends TestBase {
conn
.
commit
();
ArrayList
<
SelectForUpdate
>
threads
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
100
;
i
++)
{
for
(
int
i
=
0
;
i
<
TEST_THREAD_COUNT
;
i
++)
{
SelectForUpdate
sfu
=
new
SelectForUpdate
();
sfu
.
setName
(
"Test SelectForUpdate Thread#"
+
i
);
threads
.
add
(
sfu
);
sfu
.
start
();
}
// give any of the 100 threads a chance to start by yielding the processor to them
Thread
.
yield
();
// make sure all threads have stopped by joining with them
@SuppressWarnings
(
"unused"
)
int
minProcessed
=
Integer
.
MAX_VALUE
,
maxProcessed
=
0
,
totalProcessed
=
0
;
for
(
SelectForUpdate
sfu
:
threads
)
{
sfu
.
join
();
totalProcessed
+=
sfu
.
interationsProcessed
;
if
(
sfu
.
interationsProcessed
>
maxProcessed
){
maxProcessed
=
sfu
.
interationsProcessed
;
}
if
(
sfu
.
interationsProcessed
<
minProcessed
){
minProcessed
=
sfu
.
interationsProcessed
;
}
}
if
(
DISPLAY_STATS
){
System
.
out
.
println
(
String
.
format
(
"+ INFO: TestMvccMultiThreaded2 RUN STATS threads=%d, minProcessed=%d, maxProcessed=%d, "
+
"totalProcessed=%d, averagePerThread=%d, averagePerThreadPerSecond=%d\n"
,
TEST_THREAD_COUNT
,
minProcessed
,
maxProcessed
,
totalProcessed
,
totalProcessed
/
TEST_THREAD_COUNT
,
totalProcessed
/(
TEST_THREAD_COUNT
*
TEST_TIME_SECONDS
)));
}
IOUtils
.
closeSilently
(
conn
);
...
...
@@ -78,6 +104,8 @@ public class TestMvccMultiThreaded2 extends TestBase {
private
class
SelectForUpdate
extends
Thread
{
public
int
interationsProcessed
=
0
;
@Override
public
void
run
()
{
final
long
start
=
System
.
currentTimeMillis
();
...
...
@@ -86,6 +114,10 @@ public class TestMvccMultiThreaded2 extends TestBase {
try
{
conn
=
getConnection
(
getTestName
()
+
URL
);
conn
.
setAutoCommit
(
false
);
// give the other threads a chance to start up before going into our work loop
Thread
.
yield
();
while
(!
done
)
{
try
{
PreparedStatement
ps
=
conn
.
prepareStatement
(
...
...
@@ -97,16 +129,22 @@ public class TestMvccMultiThreaded2 extends TestBase {
assertTrue
(
rs
.
getInt
(
2
)
==
100
);
conn
.
commit
();
interationsProcessed
++;
long
now
=
System
.
currentTimeMillis
();
if
(
now
-
start
>
1000
*
60
)
if
(
now
-
start
>
1000
*
TEST_TIME_SECONDS
){
done
=
true
;
}
}
catch
(
JdbcSQLException
e1
)
{
throw
e1
;
}
}
}
catch
(
SQLException
e
)
{
TestBase
.
logError
(
"error"
,
e
);
TestBase
.
logError
(
"SQL error from thread "
+
getName
(),
e
);
}
catch
(
Exception
e
)
{
TestBase
.
logError
(
"General error from thread "
+
getName
(),
e
);
throw
e
;
}
IOUtils
.
closeSilently
(
conn
);
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论