Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
bf0a4bb5
提交
bf0a4bb5
authored
15 年前
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Server-less multi-connection mode: more bugs are fixed.
上级
b8f74f1b
master
noel-pr1
plus33-master
pr/267
stumc-Issue#576
version-1.1.x
version-1.4.198
version-1.4.197
version-1.4.196
version-1.4.195
version-1.4.194
version-1.4.193
version-1.4.192
version-1.4.191
version-1.4.190
version-1.4.188
version-1.4.187
version-1.4.186
version-1.4.185
version-1.4.184
version-1.4.183
version-1.4.182
version-1.4.181
version-1.4.178
version-1.4.177
version-1.3
version-1.2
version-1.1
version-1.0
无相关合并请求
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
22 行增加
和
15 行删除
+22
-15
TestFileLockSerialized.java
h2/src/test/org/h2/test/unit/TestFileLockSerialized.java
+22
-15
没有找到文件。
h2/src/test/org/h2/test/unit/TestFileLockSerialized.java
浏览文件 @
bf0a4bb5
...
...
@@ -33,13 +33,19 @@ public class TestFileLockSerialized extends TestBase {
}
public
void
test
()
throws
Exception
{
Class
.
forName
(
"org.h2.Driver
"
);
println
(
"testThreeMostlyReaders true
"
);
testThreeMostlyReaders
(
true
);
println
(
"testThreeMostlyReaders false"
);
testThreeMostlyReaders
(
false
);
println
(
"testTwoReaders"
);
testTwoReaders
();
println
(
"testTwoWriters"
);
testTwoWriters
();
println
(
"testPendingWrite"
);
testPendingWrite
();
println
(
"testKillWriter"
);
testKillWriter
();
println
(
"testConcurrentReadWrite"
);
testConcurrentReadWrite
();
}
...
...
@@ -62,13 +68,13 @@ public class TestFileLockSerialized extends TestBase {
try
{
PreparedStatement
p
=
c
.
prepareStatement
(
"select * from test where id = ?"
);
while
(!
stop
[
0
])
{
Thread
.
sleep
(
100
);
if
(
write
)
{
if
(
Math
.
random
()
>
0.9
)
{
c
.
createStatement
().
execute
(
"update test set id = id"
);
}
}
p
.
setInt
(
1
,
1
);
Thread
.
sleep
(
10
);
p
.
executeQuery
();
p
.
clearParameters
();
}
...
...
@@ -81,7 +87,7 @@ public class TestFileLockSerialized extends TestBase {
t
.
start
();
threads
[
i
]
=
t
;
}
Thread
.
sleep
(
10
00
);
Thread
.
sleep
(
4
00
);
stop
[
0
]
=
true
;
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
threads
[
i
].
join
();
...
...
@@ -118,17 +124,18 @@ public class TestFileLockSerialized extends TestBase {
public
void
run
()
{
while
(!
stop
[
0
])
{
try
{
Thread
.
sleep
(
10
);
Connection
conn
=
DriverManager
.
getConnection
(
writeUrl
,
"sa"
,
"sa"
);
conn
.
createStatement
().
execute
(
"select * from test"
);
conn
.
close
();
}
catch
(
SQL
Exception
e
)
{
}
catch
(
Exception
e
)
{
// ignore
}
}
}
}.
start
();
Thread
.
sleep
(
10
0
);
for
(
int
i
=
0
;
i
<
3
;
i
++)
{
Thread
.
sleep
(
2
0
);
for
(
int
i
=
0
;
i
<
2
;
i
++)
{
conn
=
DriverManager
.
getConnection
(
writeUrl
,
"sa"
,
"sa"
);
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"drop table test"
);
...
...
@@ -151,7 +158,7 @@ public class TestFileLockSerialized extends TestBase {
Connection
conn
=
DriverManager
.
getConnection
(
writeUrl
,
"sa"
,
"sa"
);
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"create table test(id int primary key)"
);
Thread
.
sleep
(
5
00
);
Thread
.
sleep
(
1
00
);
String
propFile
=
baseDir
+
"/fileLockSerialized.lock.db"
;
SortedProperties
p
=
SortedProperties
.
loadProperties
(
propFile
);
p
.
setProperty
(
"changePending"
,
"true"
);
...
...
@@ -162,7 +169,7 @@ public class TestFileLockSerialized extends TestBase {
}
finally
{
out
.
close
();
}
Thread
.
sleep
(
5
00
);
Thread
.
sleep
(
1
00
);
stat
.
execute
(
"select * from test"
);
conn
.
close
();
}
...
...
@@ -199,7 +206,7 @@ public class TestFileLockSerialized extends TestBase {
// ;TRACE_LEVEL_SYSTEM_OUT=3
// String readUrl = writeUrl + ";ACCESS_MODE_LOG=R;ACCESS_MODE_DATA=R";
trace
(
"create database"
);
trace
(
"
create database"
);
Class
.
forName
(
"org.h2.Driver"
);
Connection
conn
=
DriverManager
.
getConnection
(
writeUrl
,
"sa"
,
"sa"
);
Statement
stat
=
conn
.
createStatement
();
...
...
@@ -212,12 +219,12 @@ public class TestFileLockSerialized extends TestBase {
Statement
stat2
=
conn2
.
createStatement
();
printResult
(
stat2
,
"select * from test"
);
stat2
.
execute
(
"create local temporary table temp(name varchar)"
);
stat2
.
execute
(
"create local temporary table temp(name varchar)
not persistent
"
);
printResult
(
stat2
,
"select * from temp"
);
trace
(
"insert row 1"
);
trace
(
"
insert row 1"
);
stat
.
execute
(
"insert into test values(1)"
);
trace
(
"insert row 2"
);
trace
(
"
insert row 2"
);
prep3
.
setInt
(
1
,
2
);
prep3
.
execute
();
printResult
(
stat2
,
"select * from test"
);
...
...
@@ -229,13 +236,13 @@ public class TestFileLockSerialized extends TestBase {
}
private
void
printResult
(
Statement
stat
,
String
sql
)
throws
SQLException
{
trace
(
"query: "
+
sql
);
trace
(
"
query: "
+
sql
);
ResultSet
rs
=
stat
.
executeQuery
(
sql
);
int
rowCount
=
0
;
while
(
rs
.
next
())
{
trace
(
" "
+
rs
.
getString
(
1
));
trace
(
"
"
+
rs
.
getString
(
1
));
rowCount
++;
}
trace
(
" "
+
rowCount
+
" row(s)"
);
trace
(
"
"
+
rowCount
+
" row(s)"
);
}
}
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论