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;
...
@@ -49,6 +49,7 @@ import org.h2.value.Value;
*/
*/
public
class
MVTable
extends
TableBase
{
public
class
MVTable
extends
TableBase
{
// lock event types for tracing...
private
static
final
String
TRACE_LOCK_OK
=
"ok"
;
private
static
final
String
TRACE_LOCK_OK
=
"ok"
;
private
static
final
String
TRACE_LOCK_WAITING_FOR
=
"waiting for"
;
private
static
final
String
TRACE_LOCK_WAITING_FOR
=
"waiting for"
;
private
static
final
String
TRACE_LOCK_REQUESTING_FOR
=
"requesting 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
...
@@ -41,7 +41,7 @@ public class TestGeneralCommonTableQueries extends AbstractBaseForCommonTableExp
testMerge
();
testMerge
();
testCreateTable
();
testCreateTable
();
testNestedSQL
();
testNestedSQL
();
test
LazyQueryExecutionAndRecursiveTable
();
test
Simple4RowRecursiveQuery
();
}
}
private
void
testSimpleSelect
()
throws
Exception
{
private
void
testSimpleSelect
()
throws
Exception
{
...
@@ -470,20 +470,18 @@ public class TestGeneralCommonTableQueries extends AbstractBaseForCommonTableExp
...
@@ -470,20 +470,18 @@ public class TestGeneralCommonTableQueries extends AbstractBaseForCommonTableExp
deleteDb
(
"commonTableExpressionQueries"
);
deleteDb
(
"commonTableExpressionQueries"
);
}
}
private
void
test
LazyQueryExecutionAndRecursiveTable
()
throws
Exception
{
private
void
test
Simple4RowRecursiveQuery
()
throws
Exception
{
String
[]
expectedRowData
=
new
String
[]{
"|1"
,
"|2"
,
"|3"
};
String
[]
expectedRowData
=
new
String
[]{
"|1"
,
"|2"
,
"|3"
};
String
[]
expectedColumnTypes
=
new
String
[]{
"INTEGER"
};
String
[]
expectedColumnTypes
=
new
String
[]{
"INTEGER"
};
String
[]
expectedColumnNames
=
new
String
[]{
"N"
};
String
[]
expectedColumnNames
=
new
String
[]{
"N"
};
//Test lazy mvStore memory mvcc multiThreaded
String
SETUP_SQL
=
"SET LAZY_QUERY_EXECUTION 1;\n"
String
SETUP_SQL
=
"-- do nothing"
;
//+ "SET MEMORY 1;SET MV_STORE true; SET MVCC TRUE;"
String
WITH_QUERY
=
"with recursive r(n) as (\n"
+
//+ "SET MULTI_THREADED TRUE;"
"(select 1) union all (select n+1 from r where n < 3)\n"
+
;
")\n"
+
String
WITH_QUERY
=
"with recursive r(n) as (\n"
+
"select n from r"
;
"(select 1) union all (select n+1 from r where n < 3)\n"
+
")\n"
+
"select n from r"
;
int
maxRetries
=
3
;
int
maxRetries
=
3
;
int
expectedNumberOfRows
=
expectedRowData
.
length
;
int
expectedNumberOfRows
=
expectedRowData
.
length
;
...
...
h2/src/test/org/h2/test/mvcc/TestMvccMultiThreaded2.java
浏览文件 @
a361c578
...
@@ -20,6 +20,10 @@ import org.h2.util.IOUtils;
...
@@ -20,6 +20,10 @@ import org.h2.util.IOUtils;
*/
*/
public
class
TestMvccMultiThreaded2
extends
TestBase
{
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"
;
private
static
final
String
URL
=
";MVCC=TRUE;LOCK_TIMEOUT=120000;MULTI_THREADED=TRUE"
;
/**
/**
...
@@ -62,14 +66,36 @@ public class TestMvccMultiThreaded2 extends TestBase {
...
@@ -62,14 +66,36 @@ public class TestMvccMultiThreaded2 extends TestBase {
conn
.
commit
();
conn
.
commit
();
ArrayList
<
SelectForUpdate
>
threads
=
new
ArrayList
<>();
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
();
SelectForUpdate
sfu
=
new
SelectForUpdate
();
sfu
.
setName
(
"Test SelectForUpdate Thread#"
+
i
);
threads
.
add
(
sfu
);
threads
.
add
(
sfu
);
sfu
.
start
();
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
)
{
for
(
SelectForUpdate
sfu
:
threads
)
{
sfu
.
join
();
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
);
IOUtils
.
closeSilently
(
conn
);
...
@@ -77,6 +103,8 @@ public class TestMvccMultiThreaded2 extends TestBase {
...
@@ -77,6 +103,8 @@ public class TestMvccMultiThreaded2 extends TestBase {
}
}
private
class
SelectForUpdate
extends
Thread
{
private
class
SelectForUpdate
extends
Thread
{
public
int
interationsProcessed
=
0
;
@Override
@Override
public
void
run
()
{
public
void
run
()
{
...
@@ -86,6 +114,10 @@ public class TestMvccMultiThreaded2 extends TestBase {
...
@@ -86,6 +114,10 @@ public class TestMvccMultiThreaded2 extends TestBase {
try
{
try
{
conn
=
getConnection
(
getTestName
()
+
URL
);
conn
=
getConnection
(
getTestName
()
+
URL
);
conn
.
setAutoCommit
(
false
);
conn
.
setAutoCommit
(
false
);
// give the other threads a chance to start up before going into our work loop
Thread
.
yield
();
while
(!
done
)
{
while
(!
done
)
{
try
{
try
{
PreparedStatement
ps
=
conn
.
prepareStatement
(
PreparedStatement
ps
=
conn
.
prepareStatement
(
...
@@ -97,17 +129,23 @@ public class TestMvccMultiThreaded2 extends TestBase {
...
@@ -97,17 +129,23 @@ public class TestMvccMultiThreaded2 extends TestBase {
assertTrue
(
rs
.
getInt
(
2
)
==
100
);
assertTrue
(
rs
.
getInt
(
2
)
==
100
);
conn
.
commit
();
conn
.
commit
();
interationsProcessed
++;
long
now
=
System
.
currentTimeMillis
();
long
now
=
System
.
currentTimeMillis
();
if
(
now
-
start
>
1000
*
60
)
if
(
now
-
start
>
1000
*
TEST_TIME_SECONDS
){
done
=
true
;
done
=
true
;
}
}
catch
(
JdbcSQLException
e1
)
{
}
catch
(
JdbcSQLException
e1
)
{
throw
e1
;
throw
e1
;
}
}
}
}
}
catch
(
SQLException
e
)
{
}
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
);
IOUtils
.
closeSilently
(
conn
);
}
}
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论