Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
d9a7cf0d
Unverified
提交
d9a7cf0d
authored
9月 23, 2018
作者:
Andrei Tokar
提交者:
GitHub
9月 23, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1465 from h2database/err-handling
Error handling improvements
上级
e8b7f57d
9aa05223
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
62 行增加
和
45 行删除
+62
-45
FileStore.java
h2/src/main/org/h2/mvstore/FileStore.java
+41
-27
MVStore.java
h2/src/main/org/h2/mvstore/MVStore.java
+21
-18
没有找到文件。
h2/src/main/org/h2/mvstore/FileStore.java
浏览文件 @
d9a7cf0d
...
@@ -168,12 +168,14 @@ public class FileStore {
...
@@ -168,12 +168,14 @@ public class FileStore {
"The file is locked: {0}"
,
fileName
,
e
);
"The file is locked: {0}"
,
fileName
,
e
);
}
}
if
(
fileLock
==
null
)
{
if
(
fileLock
==
null
)
{
try
{
close
();
}
catch
(
Exception
ignore
)
{}
throw
DataUtils
.
newIllegalStateException
(
throw
DataUtils
.
newIllegalStateException
(
DataUtils
.
ERROR_FILE_LOCKED
,
DataUtils
.
ERROR_FILE_LOCKED
,
"The file is locked: {0}"
,
fileName
);
"The file is locked: {0}"
,
fileName
);
}
}
fileSize
=
file
.
size
();
fileSize
=
file
.
size
();
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
try
{
close
();
}
catch
(
Exception
ignore
)
{}
throw
DataUtils
.
newIllegalStateException
(
throw
DataUtils
.
newIllegalStateException
(
DataUtils
.
ERROR_READING_FAILED
,
DataUtils
.
ERROR_READING_FAILED
,
"Could not open file {0}"
,
fileName
,
e
);
"Could not open file {0}"
,
fileName
,
e
);
...
@@ -184,6 +186,7 @@ public class FileStore {
...
@@ -184,6 +186,7 @@ public class FileStore {
* Close this store.
* Close this store.
*/
*/
public
void
close
()
{
public
void
close
()
{
if
(
file
!=
null
)
{
try
{
try
{
if
(
fileLock
!=
null
)
{
if
(
fileLock
!=
null
)
{
fileLock
.
release
();
fileLock
.
release
();
...
@@ -199,11 +202,13 @@ public class FileStore {
...
@@ -199,11 +202,13 @@ public class FileStore {
file
=
null
;
file
=
null
;
}
}
}
}
}
/**
/**
* Flush all changes.
* Flush all changes.
*/
*/
public
void
sync
()
{
public
void
sync
()
{
if
(
file
!=
null
)
{
try
{
try
{
file
.
force
(
true
);
file
.
force
(
true
);
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
...
@@ -212,6 +217,7 @@ public class FileStore {
...
@@ -212,6 +217,7 @@ public class FileStore {
"Could not sync file {0}"
,
fileName
,
e
);
"Could not sync file {0}"
,
fileName
,
e
);
}
}
}
}
}
/**
/**
* Get the file size.
* Get the file size.
...
@@ -228,16 +234,24 @@ public class FileStore {
...
@@ -228,16 +234,24 @@ public class FileStore {
* @param size the new file size
* @param size the new file size
*/
*/
public
void
truncate
(
long
size
)
{
public
void
truncate
(
long
size
)
{
int
attemptCount
=
0
;
while
(
true
)
{
try
{
try
{
writeCount
.
incrementAndGet
();
writeCount
.
incrementAndGet
();
file
.
truncate
(
size
);
file
.
truncate
(
size
);
fileSize
=
Math
.
min
(
fileSize
,
size
);
fileSize
=
Math
.
min
(
fileSize
,
size
);
return
;
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
if
(++
attemptCount
==
10
)
{
throw
DataUtils
.
newIllegalStateException
(
throw
DataUtils
.
newIllegalStateException
(
DataUtils
.
ERROR_WRITING_FAILED
,
DataUtils
.
ERROR_WRITING_FAILED
,
"Could not truncate file {0} to size {1}"
,
"Could not truncate file {0} to size {1}"
,
fileName
,
size
,
e
);
fileName
,
size
,
e
);
}
}
System
.
gc
();
Thread
.
yield
();
}
}
}
}
/**
/**
...
...
h2/src/main/org/h2/mvstore/MVStore.java
浏览文件 @
d9a7cf0d
...
@@ -942,6 +942,7 @@ public class MVStore {
...
@@ -942,6 +942,7 @@ public class MVStore {
stopBackgroundThread
();
stopBackgroundThread
();
closed
=
true
;
closed
=
true
;
storeLock
.
lock
();
storeLock
.
lock
();
try
{
try
{
try
{
if
(
fileStore
!=
null
&&
shrinkIfPossible
)
{
if
(
fileStore
!=
null
&&
shrinkIfPossible
)
{
shrinkFileIfPossible
(
0
);
shrinkFileIfPossible
(
0
);
...
@@ -959,9 +960,11 @@ public class MVStore {
...
@@ -959,9 +960,11 @@ public class MVStore {
}
}
chunks
.
clear
();
chunks
.
clear
();
maps
.
clear
();
maps
.
clear
();
}
finally
{
if
(
fileStore
!=
null
&&
!
fileStoreIsProvided
)
{
if
(
fileStore
!=
null
&&
!
fileStoreIsProvided
)
{
fileStore
.
close
();
fileStore
.
close
();
}
}
}
}
finally
{
}
finally
{
storeLock
.
unlock
();
storeLock
.
unlock
();
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论