提交 ade0f58b authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Try to complete database close operation before throwing of background exception

上级 ba586579
...@@ -1410,12 +1410,27 @@ public class Database implements DataHandler { ...@@ -1410,12 +1410,27 @@ public class Database implements DataHandler {
* hook * hook
*/ */
void close(boolean fromShutdownHook) { void close(boolean fromShutdownHook) {
DbException b = backgroundException.getAndSet(null);
try {
closeImpl(fromShutdownHook);
} catch (Throwable t) {
if (b != null) {
t.addSuppressed(b);
}
throw t;
}
if (b != null) {
// wrap the exception, so we see it was thrown here
throw DbException.get(b.getErrorCode(), b, b.getMessage());
}
}
private void closeImpl(boolean fromShutdownHook) {
try { try {
synchronized (this) { synchronized (this) {
if (closing) { if (closing) {
return; return;
} }
throwLastBackgroundException();
if (fileLockMethod == FileLockMethod.SERIALIZED && if (fileLockMethod == FileLockMethod.SERIALIZED &&
!reconnectChangePending) { !reconnectChangePending) {
// another connection may have written something - don't write // another connection may have written something - don't write
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论