Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
03831ec1
提交
03831ec1
authored
2月 28, 2009
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
When the shutdown hook closed the database, the last log file was deleted too early.
上级
4d0dc0c8
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
49 行增加
和
47 行删除
+49
-47
changelog.html
h2/src/docsrc/html/changelog.html
+3
-1
Database.java
h2/src/main/org/h2/engine/Database.java
+3
-0
LogSystem.java
h2/src/main/org/h2/log/LogSystem.java
+3
-0
TestHalt.java
h2/src/test/org/h2/test/synth/TestHalt.java
+21
-35
TestHaltApp.java
h2/src/test/org/h2/test/synth/TestHaltApp.java
+19
-11
没有找到文件。
h2/src/docsrc/html/changelog.html
浏览文件 @
03831ec1
...
...
@@ -18,7 +18,9 @@ Change Log
<h1>
Change Log
</h1>
<h2>
Next Version (unreleased)
</h2>
<ul><li>
JdbcConnectionPool: it was possible to set a negative connection pool size.
<ul><li>
When the shutdown hook closed the database, the last log file
was deleted too early. This could cause uncommitted changes to be persisted.
</li><li>
JdbcConnectionPool: it was possible to set a negative connection pool size.
</li><li>
Fulltext search did not support table names with a backslash.
</li><li>
The internal IntArray class did not work correctly when initialized with a zero length array.
</li><li>
The H2 Console web application (war file) did only support ASCII characters.
...
...
h2/src/main/org/h2/engine/Database.java
浏览文件 @
03831ec1
...
...
@@ -1054,6 +1054,9 @@ public class Database implements DataHandler {
for
(
int
i
=
0
;
i
<
all
.
length
;
i
++)
{
Session
s
=
all
[
i
];
try
{
// must roll back, otherwise the session is removed and
// the log file that contains its uncommitted operations as well
s
.
rollback
();
s
.
close
();
}
catch
(
SQLException
e
)
{
traceSystem
.
getTrace
(
Trace
.
SESSION
).
error
(
"disconnecting #"
+
s
.
getId
(),
e
);
...
...
h2/src/main/org/h2/log/LogSystem.java
浏览文件 @
03831ec1
...
...
@@ -144,6 +144,9 @@ public class LogSystem {
l
.
setFirstUncommittedPos
(
LOG_WRITTEN
);
}
else
if
(
l
.
getId
()
==
firstUncommittedLog
)
{
if
(
firstUncommittedPos
==
l
.
getPos
())
{
// that means firstUncommittedPos is still
// were it was at the beginning
// and all sessions are committed
l
.
setFirstUncommittedPos
(
LOG_WRITTEN
);
}
else
{
l
.
setFirstUncommittedPos
(
firstUncommittedPos
);
...
...
h2/src/test/org/h2/test/synth/TestHalt.java
浏览文件 @
03831ec1
...
...
@@ -101,27 +101,27 @@ public abstract class TestHalt extends TestBase {
/**
* Initialize the test.
*/
abstract
void
test
Init
()
throws
SQLException
;
abstract
void
controller
Init
()
throws
SQLException
;
/**
* Check if the database is consistent after a simulated database crash.
*/
abstract
void
test
CheckAfterCrash
()
throws
SQLException
;
abstract
void
controller
CheckAfterCrash
()
throws
SQLException
;
/**
* Wait for some time after the application has been started.
*/
abstract
void
test
WaitAfterAppStart
()
throws
Exception
;
abstract
void
controller
WaitAfterAppStart
()
throws
Exception
;
/**
* Start the application.
*/
abstract
void
a
ppStart
()
throws
SQLException
;
abstract
void
processA
ppStart
()
throws
SQLException
;
/**
* Run the application.
*/
abstract
void
a
ppRun
()
throws
SQLException
;
abstract
void
processA
ppRun
()
throws
SQLException
;
public
void
test
()
throws
SQLException
{
for
(
int
i
=
0
;;
i
++)
{
...
...
@@ -129,7 +129,7 @@ public abstract class TestHalt extends TestBase {
flags
=
i
>>
4
;
// flags |= FLAG_NO_DELAY; // | FLAG_LOBS;
try
{
run
Test
();
controller
Test
();
}
catch
(
Throwable
t
)
{
System
.
out
.
println
(
"Error: "
+
t
);
t
.
printStackTrace
();
...
...
@@ -139,37 +139,23 @@ public abstract class TestHalt extends TestBase {
Connection
getConnection
()
throws
SQLException
{
org
.
h2
.
Driver
.
load
();
return
DriverManager
.
getConnection
(
"jdbc:h2:"
+
baseDir
+
"/halt"
,
"sa"
,
"sa"
);
String
url
=
"jdbc:h2:"
+
baseDir
+
"/halt"
;
// String url = "jdbc:h2:" + baseDir + "/halt;TRACE_LEVEL_FILE=3";
return
DriverManager
.
getConnection
(
url
,
"sa"
,
"sa"
);
}
/**
* Start the program.
*
* @param args the command line arguments
*/
protected
void
start
(
String
[]
args
)
throws
Exception
{
if
(
args
.
length
==
0
)
{
runTest
();
}
else
{
operations
=
Integer
.
parseInt
(
args
[
0
]);
flags
=
Integer
.
parseInt
(
args
[
1
]);
value
=
Integer
.
parseInt
(
args
[
2
]);
runRandom
();
}
}
private
void
runRandom
()
throws
SQLException
{
void
processRunRandom
()
throws
SQLException
{
connect
();
try
{
traceOperation
(
"connected, operations:"
+
operations
+
" flags:"
+
flags
+
" value:"
+
value
);
a
ppStart
();
processA
ppStart
();
System
.
out
.
println
(
"READY"
);
System
.
out
.
println
(
"READY"
);
System
.
out
.
println
(
"READY"
);
a
ppRun
();
processA
ppRun
();
traceOperation
(
"done"
);
}
catch
(
Exception
e
)
{
trace
(
"run"
,
e
);
trace
Operation
(
"run"
,
e
);
}
disconnect
();
}
...
...
@@ -179,7 +165,7 @@ public abstract class TestHalt extends TestBase {
traceOperation
(
"connecting"
);
conn
=
getConnection
();
}
catch
(
SQLException
e
)
{
trace
(
"connect"
,
e
);
trace
Operation
(
"connect"
,
e
);
e
.
printStackTrace
();
throw
e
;
}
...
...
@@ -191,7 +177,7 @@ public abstract class TestHalt extends TestBase {
* @param s the message
*/
protected
void
traceOperation
(
String
s
)
{
trace
(
s
,
null
);
trace
Operation
(
s
,
null
);
}
/**
...
...
@@ -200,7 +186,7 @@ public abstract class TestHalt extends TestBase {
* @param s the message
* @param e the exception or null
*/
protected
void
trace
(
String
s
,
Exception
e
)
{
protected
void
trace
Operation
(
String
s
,
Exception
e
)
{
FileWriter
writer
=
null
;
try
{
File
f
=
new
File
(
baseDir
+
"/"
+
TRACE_FILE_NAME
);
...
...
@@ -219,13 +205,13 @@ public abstract class TestHalt extends TestBase {
}
}
private
void
run
Test
()
throws
Exception
{
void
controller
Test
()
throws
Exception
{
traceOperation
(
"delete database -----------------------------"
);
DeleteDbFiles
.
execute
(
baseDir
,
DATABASE_NAME
,
true
);
new
File
(
baseDir
+
"/"
+
TRACE_FILE_NAME
).
delete
();
connect
();
test
Init
();
controller
Init
();
disconnect
();
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
traceOperation
(
"backing up "
+
sequenceId
);
...
...
@@ -254,7 +240,7 @@ public abstract class TestHalt extends TestBase {
}
else
if
(
s
.
startsWith
(
"READY"
))
{
traceOperation
(
"got reply: "
+
s
);
}
test
WaitAfterAppStart
();
controller
WaitAfterAppStart
();
p
.
destroy
();
try
{
traceOperation
(
"backing up "
+
sequenceId
);
...
...
@@ -262,7 +248,7 @@ public abstract class TestHalt extends TestBase {
// new File(BASE_DIR + "/haltSeq" + (sequenceId-20) +
// ".zip").delete();
connect
();
test
CheckAfterCrash
();
controller
CheckAfterCrash
();
}
catch
(
Exception
e
)
{
File
zip
=
new
File
(
baseDir
+
"/haltSeq"
+
sequenceId
+
".zip"
);
File
zipId
=
new
File
(
baseDir
+
"/haltSeq"
+
sequenceId
+
"-"
+
errorId
+
".zip"
);
...
...
@@ -285,7 +271,7 @@ public abstract class TestHalt extends TestBase {
traceOperation
(
"disconnect"
);
conn
.
close
();
}
catch
(
Exception
e
)
{
trace
(
"disconnect"
,
e
);
trace
Operation
(
"disconnect"
,
e
);
}
}
...
...
h2/src/test/org/h2/test/synth/TestHaltApp.java
浏览文件 @
03831ec1
...
...
@@ -29,7 +29,15 @@ public class TestHaltApp extends TestHalt {
public
static
void
main
(
String
[]
args
)
throws
Exception
{
SelfDestructor
.
startCountdown
(
60
);
baseDir
=
TestHalt
.
DIR
;
new
TestHaltApp
().
start
(
args
);
TestHaltApp
app
=
new
TestHaltApp
();
if
(
args
.
length
==
0
)
{
app
.
controllerTest
();
}
else
{
app
.
operations
=
Integer
.
parseInt
(
args
[
0
]);
app
.
flags
=
Integer
.
parseInt
(
args
[
1
]);
app
.
value
=
Integer
.
parseInt
(
args
[
2
]);
app
.
processRunRandom
();
}
}
private
void
execute
(
Statement
stat
,
String
sql
)
throws
SQLException
{
...
...
@@ -40,7 +48,7 @@ public class TestHaltApp extends TestHalt {
/**
* Initialize the database.
*/
protected
void
test
Init
()
throws
SQLException
{
protected
void
controller
Init
()
throws
SQLException
{
Statement
stat
=
conn
.
createStatement
();
// stat.execute("CREATE TABLE TEST(ID IDENTITY, NAME VARCHAR(255))");
for
(
int
i
=
0
;
i
<
20
;
i
++)
{
...
...
@@ -57,7 +65,7 @@ public class TestHaltApp extends TestHalt {
/**
* Wait after the application has been started.
*/
protected
void
test
WaitAfterAppStart
()
throws
Exception
{
protected
void
controller
WaitAfterAppStart
()
throws
Exception
{
int
sleep
=
10
+
random
.
nextInt
(
300
);
if
((
flags
&
FLAG_NO_DELAY
)
==
0
)
{
sleep
+=
1000
;
...
...
@@ -71,22 +79,22 @@ public class TestHaltApp extends TestHalt {
*
* @throws SQLException if the data is not consistent.
*/
protected
void
test
CheckAfterCrash
()
throws
SQLException
{
protected
void
controller
CheckAfterCrash
()
throws
SQLException
{
Statement
stat
=
conn
.
createStatement
();
ResultSet
rs
=
stat
.
executeQuery
(
"SELECT COUNT(*) FROM TEST"
);
rs
.
next
();
int
count
=
rs
.
getInt
(
1
);
System
.
out
.
println
(
"count: "
+
count
);
if
(
count
%
2
=
=
0
)
{
if
(
count
%
2
!
=
0
)
{
traceOperation
(
"row count: "
+
count
);
throw
new
SQLException
(
"Unexpected odd row count
"
);
throw
new
SQLException
(
"Unexpected odd row count
: "
+
count
);
}
}
/**
* Initialize the application.
*/
protected
void
a
ppStart
()
throws
SQLException
{
protected
void
processA
ppStart
()
throws
SQLException
{
Statement
stat
=
conn
.
createStatement
();
if
((
flags
&
FLAG_NO_DELAY
)
!=
0
)
{
execute
(
stat
,
"SET WRITE_DELAY 0"
);
...
...
@@ -95,13 +103,13 @@ public class TestHaltApp extends TestHalt {
ResultSet
rs
=
stat
.
executeQuery
(
"SELECT COUNT(*) FROM TEST"
);
rs
.
next
();
rowCount
=
rs
.
getInt
(
1
);
trace
(
"rows: "
+
rowCount
,
null
);
trace
Operation
(
"rows: "
+
rowCount
,
null
);
}
/**
* Run the application code.
*/
protected
void
a
ppRun
()
throws
SQLException
{
protected
void
processA
ppRun
()
throws
SQLException
{
conn
.
setAutoCommit
(
false
);
traceOperation
(
"setAutoCommit false"
);
int
rows
=
10000
+
value
;
...
...
@@ -146,11 +154,11 @@ public class TestHaltApp extends TestHalt {
rowCount
-=
uc
;
}
traceOperation
(
"rowCount "
+
rowCount
);
trace
(
"rows now: "
+
rowCount
,
null
);
trace
Operation
(
"rows now: "
+
rowCount
,
null
);
if
(
rowCount
%
2
==
0
)
{
traceOperation
(
"commit "
+
rowCount
);
conn
.
commit
();
trace
(
"committed: "
+
rowCount
,
null
);
trace
Operation
(
"committed: "
+
rowCount
,
null
);
}
if
((
flags
&
FLAG_NO_DELAY
)
!=
0
)
{
if
(
random
.
nextInt
(
10
)
==
0
&&
(
rowCount
%
2
==
0
))
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论