Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
8b4bfee5
Unverified
提交
8b4bfee5
authored
6月 02, 2018
作者:
Andrei Tokar
提交者:
GitHub
6月 02, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1173 from h2database/background-exception
protect first background exception encountered and relate it to clients
上级
5bc2dcbb
691e8a55
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
38 行增加
和
32 行删除
+38
-32
Database.java
h2/src/main/org/h2/engine/Database.java
+35
-30
Session.java
h2/src/main/org/h2/engine/Session.java
+2
-1
MVStore.java
h2/src/main/org/h2/mvstore/MVStore.java
+1
-1
没有找到文件。
h2/src/main/org/h2/engine/Database.java
浏览文件 @
8b4bfee5
...
...
@@ -218,7 +218,7 @@ public class Database implements DataHandler {
private
MVTableEngine
.
Store
mvStore
;
private
int
retentionTime
;
private
boolean
allowBuiltinAliasOverride
;
private
DbException
backgroundException
;
private
final
AtomicReference
<
DbException
>
backgroundException
=
new
AtomicReference
<>()
;
private
JavaObjectSerializer
javaObjectSerializer
;
private
String
javaObjectSerializerName
;
private
volatile
boolean
javaObjectSerializerInitialized
;
...
...
@@ -314,23 +314,27 @@ public class Database implements DataHandler {
OnExitDatabaseCloser
.
register
(
this
);
}
}
catch
(
Throwable
e
)
{
if
(
e
instanceof
OutOfMemoryError
)
{
e
.
fillInStackTrace
();
}
boolean
alreadyOpen
=
e
instanceof
DbException
&&
((
DbException
)
e
).
getErrorCode
()
==
ErrorCode
.
DATABASE_ALREADY_OPEN_1
;
if
(
alreadyOpen
)
{
stopServer
();
}
try
{
if
(
e
instanceof
OutOfMemoryError
)
{
e
.
fillInStackTrace
();
}
boolean
alreadyOpen
=
e
instanceof
DbException
&&
((
DbException
)
e
).
getErrorCode
()
==
ErrorCode
.
DATABASE_ALREADY_OPEN_1
;
if
(
alreadyOpen
)
{
stopServer
();
}
if
(
traceSystem
!=
null
)
{
if
(
e
instanceof
DbException
&&
!
alreadyOpen
)
{
// only write if the database is not already in use
trace
.
error
(
e
,
"opening {0}"
,
databaseName
);
if
(
traceSystem
!=
null
)
{
if
(
e
instanceof
DbException
&&
!
alreadyOpen
)
{
// only write if the database is not already in use
trace
.
error
(
e
,
"opening {0}"
,
databaseName
);
}
traceSystem
.
close
();
}
traceSystem
.
close
();
closeOpenFilesAndUnlock
(
false
);
}
catch
(
Throwable
ex
)
{
e
.
addSuppressed
(
ex
);
}
closeOpenFilesAndUnlock
(
false
);
throw
DbException
.
convert
(
e
);
}
}
...
...
@@ -675,8 +679,7 @@ public class Database implements DataHandler {
if
(
readOnly
||
fileLockMethod
==
FileLockMethod
.
NO
||
fileLockMethod
==
FileLockMethod
.
SERIALIZED
||
fileLockMethod
==
FileLockMethod
.
FS
||
!
persistent
)
{
fileLockMethod
==
FileLockMethod
.
FS
)
{
throw
DbException
.
getUnsupportedException
(
"autoServerMode && (readOnly || "
+
"fileLockMethod == NO || "
+
...
...
@@ -2116,22 +2119,15 @@ public class Database implements DataHandler {
}
private
void
throwLastBackgroundException
()
{
if
(
backgroundException
!=
null
)
{
// we don't care too much about concurrency here,
// we just want to make sure the exception is _normally_
// not just logged to the .trace.db file
DbException
b
=
backgroundException
;
backgroundException
=
null
;
if
(
b
!=
null
)
{
// wrap the exception, so we see it was thrown here
throw
DbException
.
get
(
b
.
getErrorCode
(),
b
,
b
.
getMessage
());
}
DbException
b
=
backgroundException
.
getAndSet
(
null
);
if
(
b
!=
null
)
{
// wrap the exception, so we see it was thrown here
throw
DbException
.
get
(
b
.
getErrorCode
(),
b
,
b
.
getMessage
());
}
}
public
void
setBackgroundException
(
DbException
e
)
{
if
(
backgroundException
==
null
)
{
backgroundException
=
e
;
if
(
backgroundException
.
compareAndSet
(
null
,
e
))
{
TraceSystem
t
=
getTraceSystem
();
if
(
t
!=
null
)
{
t
.
getTrace
(
Trace
.
DATABASE
).
error
(
e
,
"flush"
);
...
...
@@ -2139,6 +2135,15 @@ public class Database implements DataHandler {
}
}
public
Throwable
getBackgroundException
()
{
IllegalStateException
exception
=
mvStore
.
getStore
().
getPanicException
();
if
(
exception
!=
null
)
{
return
exception
;
}
return
backgroundException
.
getAndSet
(
null
);
}
/**
* Flush all pending changes to the transaction log.
*/
...
...
@@ -2153,7 +2158,7 @@ public class Database implements DataHandler {
try
{
mvStore
.
flush
();
}
catch
(
RuntimeException
e
)
{
backgroundException
=
DbException
.
convert
(
e
);
backgroundException
.
compareAndSet
(
null
,
DbException
.
convert
(
e
)
);
throw
e
;
}
}
...
...
h2/src/main/org/h2/engine/Session.java
浏览文件 @
8b4bfee5
...
...
@@ -1676,8 +1676,9 @@ public class Session extends SessionWithState implements TransactionStore.Rollba
MVTableEngine
.
Store
store
=
database
.
getMvStore
();
if
(
store
!=
null
)
{
if
(
store
.
getStore
().
isClosed
())
{
Throwable
backgroundException
=
database
.
getBackgroundException
();
database
.
shutdownImmediately
();
throw
DbException
.
get
(
ErrorCode
.
DATABASE_IS_CLOSED
);
throw
DbException
.
get
(
ErrorCode
.
DATABASE_IS_CLOSED
,
backgroundException
);
}
transaction
=
store
.
getTransactionStore
().
begin
(
this
,
this
.
lockTimeout
,
id
);
}
...
...
h2/src/main/org/h2/mvstore/MVStore.java
浏览文件 @
8b4bfee5
...
...
@@ -292,7 +292,7 @@ public class MVStore {
private
final
Object
compactSync
=
new
Object
();
private
IllegalStateException
panicException
;
private
volatile
IllegalStateException
panicException
;
private
long
lastTimeAbsolute
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论