Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
d744354c
提交
d744354c
authored
13 年前
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
New experimental system property "h2.modifyOnWrite".
上级
56466880
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
43 行增加
和
10 行删除
+43
-10
Database.java
h2/src/main/org/h2/engine/Database.java
+37
-9
TestFileLockSerialized.java
h2/src/test/org/h2/test/unit/TestFileLockSerialized.java
+6
-1
没有找到文件。
h2/src/main/org/h2/engine/Database.java
浏览文件 @
d744354c
...
@@ -543,13 +543,37 @@ public class Database implements DataHandler {
...
@@ -543,13 +543,37 @@ public class Database implements DataHandler {
}
}
}
}
}
}
if
(
SysProperties
.
MODIFY_ON_WRITE
)
{
while
(
isReconnectNeeded
())
{
// wait until others stopped writing
}
}
else
{
while
(
isReconnectNeeded
()
&&
!
beforeWriting
())
{
while
(
isReconnectNeeded
()
&&
!
beforeWriting
())
{
// wait until others stopped writing and
// wait until others stopped writing and
// until we can write (file are not open - no need to re-connect)
// until we can write (the file is not yet open -
// no need to re-connect)
}
}
}
deleteOldTempFiles
();
deleteOldTempFiles
();
starting
=
true
;
starting
=
true
;
if
(
SysProperties
.
MODIFY_ON_WRITE
)
{
try
{
getPageStore
();
}
catch
(
DbException
e
)
{
if
(
e
.
getErrorCode
()
!=
ErrorCode
.
DATABASE_IS_READ_ONLY
)
{
throw
e
;
}
pageStore
=
null
;
while
(!
beforeWriting
())
{
// wait until others stopped writing and
// until we can write (the file is not yet open -
// no need to re-connect)
}
getPageStore
();
}
}
else
{
getPageStore
();
getPageStore
();
}
starting
=
false
;
starting
=
false
;
writer
=
WriterThread
.
create
(
this
,
writeDelay
);
writer
=
WriterThread
.
create
(
this
,
writeDelay
);
}
else
{
}
else
{
...
@@ -630,8 +654,10 @@ public class Database implements DataHandler {
...
@@ -630,8 +654,10 @@ public class Database implements DataHandler {
getLobStorage
().
init
();
getLobStorage
().
init
();
systemSession
.
commit
(
true
);
systemSession
.
commit
(
true
);
trace
.
info
(
"opened {0}"
,
databaseName
);
trace
.
info
(
"opened {0}"
,
databaseName
);
if
(
checkpointAllowed
>
0
)
{
afterWriting
();
afterWriting
();
}
}
}
private
void
startServer
(
String
key
)
{
private
void
startServer
(
String
key
)
{
try
{
try
{
...
@@ -1203,12 +1229,14 @@ public class Database implements DataHandler {
...
@@ -1203,12 +1229,14 @@ public class Database implements DataHandler {
if
(
fileLockMethod
==
FileLock
.
LOCK_SERIALIZED
)
{
if
(
fileLockMethod
==
FileLock
.
LOCK_SERIALIZED
)
{
// wait before deleting the .lock file,
// wait before deleting the .lock file,
// otherwise other connections can not detect that
// otherwise other connections can not detect that
if
(
lock
.
load
().
containsKey
(
"changePending"
))
{
try
{
try
{
Thread
.
sleep
((
int
)
(
reconnectCheckDelay
*
1.1
));
Thread
.
sleep
((
int
)
(
reconnectCheckDelay
*
1.1
));
}
catch
(
InterruptedException
e
)
{
}
catch
(
InterruptedException
e
)
{
trace
.
error
(
e
,
"close"
);
trace
.
error
(
e
,
"close"
);
}
}
}
}
}
lock
.
unlock
();
lock
.
unlock
();
lock
=
null
;
lock
=
null
;
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/unit/TestFileLockSerialized.java
浏览文件 @
d744354c
...
@@ -576,9 +576,14 @@ public class TestFileLockSerialized extends TestBase {
...
@@ -576,9 +576,14 @@ public class TestFileLockSerialized extends TestBase {
assertTrue
(
rs
.
next
());
assertTrue
(
rs
.
next
());
assertEquals
(
500
,
rs
.
getInt
(
1
));
assertEquals
(
500
,
rs
.
getInt
(
1
));
rs
.
close
();
rs
.
close
();
// wait until the task finished
importUpdate
.
get
();
importUpdate
.
get
();
Thread
.
sleep
(
1000
);
Thread
.
sleep
(
1000
);
rs
=
stat
.
executeQuery
(
"select id2 from test where id=500"
);
// can't use the exact same query, otherwise it would use
// the query cache
rs
=
stat
.
executeQuery
(
"select id2 from test where id=500+0"
);
assertTrue
(
rs
.
next
());
assertTrue
(
rs
.
next
());
assertEquals
(
999
,
rs
.
getInt
(
1
));
assertEquals
(
999
,
rs
.
getInt
(
1
));
rs
.
close
();
rs
.
close
();
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论