Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
79cad4d1
提交
79cad4d1
authored
3月 23, 2017
作者:
Noel Grandin
提交者:
GitHub
3月 23, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #468 from andreitokar/Issue#467
Fixes h2database/h2database#467 Deadlock between Sequence.flush() and…
上级
840bfed4
7abf17d8
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
53 行增加
和
63 行删除
+53
-63
Database.java
h2/src/main/org/h2/engine/Database.java
+36
-34
Sequence.java
h2/src/main/org/h2/schema/Sequence.java
+17
-19
TestKillRestart.java
h2/src/test/org/h2/test/synth/TestKillRestart.java
+0
-5
TestKillRestartMulti.java
h2/src/test/org/h2/test/synth/TestKillRestartMulti.java
+0
-5
没有找到文件。
h2/src/main/org/h2/engine/Database.java
浏览文件 @
79cad4d1
...
@@ -1216,45 +1216,47 @@ public class Database implements DataHandler {
...
@@ -1216,45 +1216,47 @@ public class Database implements DataHandler {
* @param fromShutdownHook true if this method is called from the shutdown
* @param fromShutdownHook true if this method is called from the shutdown
* hook
* hook
*/
*/
synchronized
void
close
(
boolean
fromShutdownHook
)
{
void
close
(
boolean
fromShutdownHook
)
{
if
(
closing
)
{
synchronized
(
this
)
{
return
;
if
(
closing
)
{
}
throwLastBackgroundException
();
if
(
fileLockMethod
==
FileLock
.
LOCK_SERIALIZED
&&
!
reconnectChangePending
)
{
// another connection may have written something - don't write
try
{
closeOpenFilesAndUnlock
(
false
);
}
catch
(
DbException
e
)
{
// ignore
}
traceSystem
.
close
();
Engine
.
getInstance
().
close
(
databaseName
);
return
;
}
closing
=
true
;
stopServer
();
if
(
userSessions
.
size
()
>
0
)
{
if
(!
fromShutdownHook
)
{
return
;
return
;
}
}
trace
.
info
(
"closing {0} from shutdown hook"
,
databaseName
);
throwLastBackgroundException
();
closeAllSessionsException
(
null
);
if
(
fileLockMethod
==
FileLock
.
LOCK_SERIALIZED
&&
}
!
reconnectChangePending
)
{
trace
.
info
(
"closing {0}"
,
databaseName
);
// another connection may have written something - don't write
if
(
eventListener
!=
null
)
{
try
{
// allow the event listener to connect to the database
closeOpenFilesAndUnlock
(
false
);
closing
=
false
;
}
catch
(
DbException
e
)
{
DatabaseEventListener
e
=
eventListener
;
// ignore
// set it to null, to make sure it's called only once
}
eventListener
=
null
;
traceSystem
.
close
();
e
.
closingDatabase
();
Engine
.
getInstance
().
close
(
databaseName
);
if
(
userSessions
.
size
()
>
0
)
{
// if a connection was opened, we can't close the database
return
;
return
;
}
}
closing
=
true
;
closing
=
true
;
stopServer
();
if
(
userSessions
.
size
()
>
0
)
{
if
(!
fromShutdownHook
)
{
return
;
}
trace
.
info
(
"closing {0} from shutdown hook"
,
databaseName
);
closeAllSessionsException
(
null
);
}
trace
.
info
(
"closing {0}"
,
databaseName
);
if
(
eventListener
!=
null
)
{
// allow the event listener to connect to the database
closing
=
false
;
DatabaseEventListener
e
=
eventListener
;
// set it to null, to make sure it's called only once
eventListener
=
null
;
e
.
closingDatabase
();
if
(
userSessions
.
size
()
>
0
)
{
// if a connection was opened, we can't close the database
return
;
}
closing
=
true
;
}
}
}
removeOrphanedLobs
();
removeOrphanedLobs
();
try
{
try
{
...
...
h2/src/main/org/h2/schema/Sequence.java
浏览文件 @
79cad4d1
...
@@ -32,7 +32,7 @@ public class Sequence extends SchemaObjectBase {
...
@@ -32,7 +32,7 @@ public class Sequence extends SchemaObjectBase {
private
long
maxValue
;
private
long
maxValue
;
private
boolean
cycle
;
private
boolean
cycle
;
private
boolean
belongsToTable
;
private
boolean
belongsToTable
;
private
Object
flushSync
=
new
Object
();
private
final
Object
flushSync
=
new
Object
();
private
boolean
writeWithMargin
;
private
boolean
writeWithMargin
;
/**
/**
...
@@ -294,32 +294,30 @@ public class Sequence extends SchemaObjectBase {
...
@@ -294,32 +294,30 @@ public class Sequence extends SchemaObjectBase {
// locked it) because it must be committed immediately, otherwise
// locked it) because it must be committed immediately, otherwise
// other threads can not access the sys table.
// other threads can not access the sys table.
Session
sysSession
=
database
.
getSystemSession
();
Session
sysSession
=
database
.
getSystemSession
();
synchronized
(
sysSession
)
{
synchronized
(
database
.
isMultiThreaded
()
?
sysSession
:
database
)
{
synchronized
(
flushSync
)
{
flushInternal
(
sysSession
);
flushInternal
(
sysSession
);
}
sysSession
.
commit
(
false
);
sysSession
.
commit
(
false
);
}
}
}
else
{
}
else
{
synchronized
(
session
)
{
synchronized
(
database
.
isMultiThreaded
()
?
session
:
database
)
{
synchronized
(
flushSync
)
{
flushInternal
(
session
);
flushInternal
(
session
);
}
}
}
}
}
}
}
private
void
flushInternal
(
Session
session
)
{
private
void
flushInternal
(
Session
session
)
{
final
boolean
metaWasLocked
=
database
.
lockMeta
(
session
);
synchronized
(
flushSync
)
{
// just for this case, use the value with the margin
final
boolean
metaWasLocked
=
database
.
lockMeta
(
session
);
try
{
// just for this case, use the value with the margin
writeWithMargin
=
true
;
try
{
database
.
updateMeta
(
session
,
this
);
writeWithMargin
=
true
;
}
finally
{
database
.
updateMeta
(
session
,
this
);
writeWithMargin
=
false
;
}
finally
{
}
writeWithMargin
=
false
;
if
(!
metaWasLocked
)
{
}
database
.
unlockMeta
(
session
);
if
(!
metaWasLocked
)
{
database
.
unlockMeta
(
session
);
}
}
}
}
}
...
...
h2/src/test/org/h2/test/synth/TestKillRestart.java
浏览文件 @
79cad4d1
...
@@ -26,11 +26,6 @@ public class TestKillRestart extends TestBase {
...
@@ -26,11 +26,6 @@ public class TestKillRestart extends TestBase {
if
(
config
.
networked
)
{
if
(
config
.
networked
)
{
return
;
return
;
}
}
if
(
config
.
fast
)
{
// using fast as a proxy for "running on Jenkins CI" where this test
// gets stuck waiting for the sub-process after killing it
return
;
}
if
(
getBaseDir
().
indexOf
(
':'
)
>
0
)
{
if
(
getBaseDir
().
indexOf
(
':'
)
>
0
)
{
return
;
return
;
}
}
...
...
h2/src/test/org/h2/test/synth/TestKillRestartMulti.java
浏览文件 @
79cad4d1
...
@@ -39,11 +39,6 @@ public class TestKillRestartMulti extends TestBase {
...
@@ -39,11 +39,6 @@ public class TestKillRestartMulti extends TestBase {
if
(
config
.
networked
)
{
if
(
config
.
networked
)
{
return
;
return
;
}
}
if
(
config
.
fast
)
{
// using fast as a proxy for "running on Jenkins CI" where this test
// gets stuck waiting for the sub-process after killing it
return
;
}
if
(
getBaseDir
().
indexOf
(
':'
)
>
0
)
{
if
(
getBaseDir
().
indexOf
(
':'
)
>
0
)
{
return
;
return
;
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论