Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
daa433f0
提交
daa433f0
authored
6 年前
作者:
Andrei Tokar
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Exception handling improvements
Assorted minor changes
上级
f796e624
master
version-1.4.198
无相关合并请求
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
127 行增加
和
126 行删除
+127
-126
Database.java
h2/src/main/org/h2/engine/Database.java
+97
-92
MVStore.java
h2/src/main/org/h2/mvstore/MVStore.java
+11
-9
MVTableEngine.java
h2/src/main/org/h2/mvstore/db/MVTableEngine.java
+0
-15
TransactionStore.java
h2/src/main/org/h2/mvstore/tx/TransactionStore.java
+19
-10
没有找到文件。
h2/src/main/org/h2/engine/Database.java
浏览文件 @
daa433f0
...
@@ -808,7 +808,7 @@ public class Database implements DataHandler {
...
@@ -808,7 +808,7 @@ public class Database implements DataHandler {
}
}
systemSession
.
commit
(
true
);
systemSession
.
commit
(
true
);
if
(
mvStore
!=
null
)
{
if
(
mvStore
!=
null
)
{
mvStore
.
init
Transactions
();
mvStore
.
getTransactionStore
().
endLeftover
Transactions
();
mvStore
.
removeTemporaryMaps
(
objectIds
);
mvStore
.
removeTemporaryMaps
(
objectIds
);
}
}
recompileInvalidViews
(
systemSession
);
recompileInvalidViews
(
systemSession
);
...
@@ -1014,6 +1014,7 @@ public class Database implements DataHandler {
...
@@ -1014,6 +1014,7 @@ public class Database implements DataHandler {
SearchRow
r
=
meta
.
getTemplateSimpleRow
(
false
);
SearchRow
r
=
meta
.
getTemplateSimpleRow
(
false
);
r
.
setValue
(
0
,
ValueInt
.
get
(
id
));
r
.
setValue
(
0
,
ValueInt
.
get
(
id
));
boolean
wasLocked
=
lockMeta
(
session
);
boolean
wasLocked
=
lockMeta
(
session
);
try
{
Cursor
cursor
=
metaIdIndex
.
find
(
session
,
r
,
r
);
Cursor
cursor
=
metaIdIndex
.
find
(
session
,
r
,
r
);
if
(
cursor
.
next
())
{
if
(
cursor
.
next
())
{
if
(
SysProperties
.
CHECK
)
{
if
(
SysProperties
.
CHECK
)
{
...
@@ -1031,12 +1032,13 @@ public class Database implements DataHandler {
...
@@ -1031,12 +1032,13 @@ public class Database implements DataHandler {
if
(
SysProperties
.
CHECK
)
{
if
(
SysProperties
.
CHECK
)
{
checkMetaFree
(
session
,
id
);
checkMetaFree
(
session
,
id
);
}
}
}
else
if
(!
wasLocked
)
{
}
unlockMetaDebug
(
session
);
}
finally
{
if
(!
wasLocked
)
{
// must not keep the lock if it was not locked
// must not keep the lock if it was not locked
// otherwise updating sequences may cause a deadlock
// otherwise updating sequences may cause a deadlock
meta
.
unlock
(
session
);
unlockMeta
(
session
);
session
.
unlock
(
meta
);
}
}
}
objectIds
.
clear
(
id
);
objectIds
.
clear
(
id
);
}
}
...
@@ -1333,10 +1335,10 @@ public class Database implements DataHandler {
...
@@ -1333,10 +1335,10 @@ public class Database implements DataHandler {
}
}
closing
=
true
;
closing
=
true
;
}
}
}
if
(!
this
.
isReadOnly
())
{
if
(!
this
.
isReadOnly
())
{
removeOrphanedLobs
();
removeOrphanedLobs
();
}
}
}
try
{
try
{
if
(
systemSession
!=
null
)
{
if
(
systemSession
!=
null
)
{
if
(
powerOffCount
!=
-
1
)
{
if
(
powerOffCount
!=
-
1
)
{
...
@@ -1427,6 +1429,7 @@ public class Database implements DataHandler {
...
@@ -1427,6 +1429,7 @@ public class Database implements DataHandler {
* @param flush whether writing is allowed
* @param flush whether writing is allowed
*/
*/
private
synchronized
void
closeOpenFilesAndUnlock
(
boolean
flush
)
{
private
synchronized
void
closeOpenFilesAndUnlock
(
boolean
flush
)
{
try
{
stopWriter
();
stopWriter
();
if
(
pageStore
!=
null
)
{
if
(
pageStore
!=
null
)
{
if
(
flush
)
{
if
(
flush
)
{
...
@@ -1456,7 +1459,7 @@ public class Database implements DataHandler {
...
@@ -1456,7 +1459,7 @@ public class Database implements DataHandler {
}
}
}
}
reconnectModified
(
false
);
reconnectModified
(
false
);
if
(
mvStore
!=
null
&&
!
mvStore
.
getStore
().
isClosed
())
{
if
(
mvStore
!=
null
&&
mvStore
.
getStore
()
!=
null
&&
!
mvStore
.
getStore
().
isClosed
())
{
long
maxCompactTime
=
dbSettings
.
maxCompactTime
;
long
maxCompactTime
=
dbSettings
.
maxCompactTime
;
if
(
compactMode
==
CommandInterface
.
SHUTDOWN_COMPACT
)
{
if
(
compactMode
==
CommandInterface
.
SHUTDOWN_COMPACT
)
{
mvStore
.
compactFile
(
dbSettings
.
maxCompactTime
);
mvStore
.
compactFile
(
dbSettings
.
maxCompactTime
);
...
@@ -1467,6 +1470,14 @@ public class Database implements DataHandler {
...
@@ -1467,6 +1470,14 @@ public class Database implements DataHandler {
}
}
mvStore
.
close
(
maxCompactTime
);
mvStore
.
close
(
maxCompactTime
);
}
}
if
(
systemSession
!=
null
)
{
systemSession
.
close
();
systemSession
=
null
;
}
if
(
lobSession
!=
null
)
{
lobSession
.
close
();
lobSession
=
null
;
}
closeFiles
();
closeFiles
();
if
(
persistent
&&
lock
==
null
&&
if
(
persistent
&&
lock
==
null
&&
fileLockMethod
!=
FileLockMethod
.
NO
&&
fileLockMethod
!=
FileLockMethod
.
NO
&&
...
@@ -1479,14 +1490,7 @@ public class Database implements DataHandler {
...
@@ -1479,14 +1490,7 @@ public class Database implements DataHandler {
if
(
persistent
)
{
if
(
persistent
)
{
deleteOldTempFiles
();
deleteOldTempFiles
();
}
}
if
(
systemSession
!=
null
)
{
}
finally
{
systemSession
.
close
();
systemSession
=
null
;
}
if
(
lobSession
!=
null
)
{
lobSession
.
close
();
lobSession
=
null
;
}
if
(
lock
!=
null
)
{
if
(
lock
!=
null
)
{
if
(
fileLockMethod
==
FileLockMethod
.
SERIALIZED
)
{
if
(
fileLockMethod
==
FileLockMethod
.
SERIALIZED
)
{
// wait before deleting the .lock file,
// wait before deleting the .lock file,
...
@@ -1504,6 +1508,7 @@ public class Database implements DataHandler {
...
@@ -1504,6 +1508,7 @@ public class Database implements DataHandler {
lock
=
null
;
lock
=
null
;
}
}
}
}
}
private
synchronized
void
closeFiles
()
{
private
synchronized
void
closeFiles
()
{
try
{
try
{
...
@@ -1946,7 +1951,6 @@ public class Database implements DataHandler {
...
@@ -1946,7 +1951,6 @@ public class Database implements DataHandler {
t
.
getSQL
());
t
.
getSQL
());
}
}
obj
.
removeChildrenAndResources
(
session
);
obj
.
removeChildrenAndResources
(
session
);
}
}
removeMeta
(
session
,
id
);
removeMeta
(
session
,
id
);
}
}
...
@@ -2550,6 +2554,7 @@ public class Database implements DataHandler {
...
@@ -2550,6 +2554,7 @@ public class Database implements DataHandler {
* Immediately close the database.
* Immediately close the database.
*/
*/
public
void
shutdownImmediately
()
{
public
void
shutdownImmediately
()
{
closing
=
true
;
setPowerOffCount
(
1
);
setPowerOffCount
(
1
);
try
{
try
{
checkPowerOff
();
checkPowerOff
();
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/mvstore/MVStore.java
浏览文件 @
daa433f0
...
@@ -511,9 +511,12 @@ public class MVStore {
...
@@ -511,9 +511,12 @@ public class MVStore {
M
map
=
(
M
)
getMap
(
id
);
M
map
=
(
M
)
getMap
(
id
);
if
(
map
==
null
)
{
if
(
map
==
null
)
{
String
configAsString
=
meta
.
get
(
MVMap
.
getMapKey
(
id
));
String
configAsString
=
meta
.
get
(
MVMap
.
getMapKey
(
id
));
if
(
configAsString
!=
null
)
{
HashMap
<
String
,
Object
>
config
;
HashMap
<
String
,
Object
>
config
=
if
(
configAsString
!=
null
)
{
new
HashMap
<
String
,
Object
>(
DataUtils
.
parseMap
(
configAsString
));
config
=
new
HashMap
<
String
,
Object
>(
DataUtils
.
parseMap
(
configAsString
));
}
else
{
config
=
new
HashMap
<>();
}
config
.
put
(
"id"
,
id
);
config
.
put
(
"id"
,
id
);
map
=
builder
.
create
(
this
,
config
);
map
=
builder
.
create
(
this
,
config
);
map
.
init
();
map
.
init
();
...
@@ -521,7 +524,6 @@ public class MVStore {
...
@@ -521,7 +524,6 @@ public class MVStore {
map
.
setRootPos
(
root
,
lastStoredVersion
);
map
.
setRootPos
(
root
,
lastStoredVersion
);
maps
.
put
(
id
,
map
);
maps
.
put
(
id
,
map
);
}
}
}
return
map
;
return
map
;
}
finally
{
}
finally
{
storeLock
.
unlock
();
storeLock
.
unlock
();
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/mvstore/db/MVTableEngine.java
浏览文件 @
daa433f0
...
@@ -246,21 +246,6 @@ public class MVTableEngine implements TableEngine {
...
@@ -246,21 +246,6 @@ public class MVTableEngine implements TableEngine {
store
.
closeImmediately
();
store
.
closeImmediately
();
}
}
/**
* Commit all transactions that are in the committing state, and
* rollback all open transactions.
*/
public
void
initTransactions
()
{
List
<
Transaction
>
list
=
transactionStore
.
getOpenTransactions
();
for
(
Transaction
t
:
list
)
{
if
(
t
.
getStatus
()
==
Transaction
.
STATUS_COMMITTED
)
{
t
.
commit
();
}
else
if
(
t
.
getStatus
()
!=
Transaction
.
STATUS_PREPARED
)
{
t
.
rollback
();
}
}
}
/**
/**
* Remove all temporary maps.
* Remove all temporary maps.
*
*
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/mvstore/tx/TransactionStore.java
浏览文件 @
daa433f0
...
@@ -147,14 +147,6 @@ public class TransactionStore {
...
@@ -147,14 +147,6 @@ public class TransactionStore {
*/
*/
public
void
init
()
{
public
void
init
()
{
if
(!
init
)
{
if
(!
init
)
{
// remove all temporary maps
for
(
String
mapName
:
store
.
getMapNames
())
{
if
(
mapName
.
startsWith
(
"temp."
))
{
MVMap
<
Object
,
Integer
>
temp
=
openTempMap
(
mapName
);
store
.
removeMap
(
temp
);
}
}
for
(
String
mapName
:
store
.
getMapNames
())
{
for
(
String
mapName
:
store
.
getMapNames
())
{
if
(
mapName
.
startsWith
(
UNDO_LOG_NAME_PEFIX
))
{
if
(
mapName
.
startsWith
(
UNDO_LOG_NAME_PEFIX
))
{
if
(
store
.
hasData
(
mapName
))
{
if
(
store
.
hasData
(
mapName
))
{
...
@@ -165,13 +157,15 @@ public class TransactionStore {
...
@@ -165,13 +157,15 @@ public class TransactionStore {
int
status
;
int
status
;
String
name
;
String
name
;
if
(
data
==
null
)
{
if
(
data
==
null
)
{
status
=
mapName
.
charAt
(
UNDO_LOG_NAME_PEFIX
.
length
())
==
UNDO_LOG_OPEN
?
status
=
Transaction
.
STATUS_OPEN
;
Transaction
.
STATUS_OPEN
:
Transaction
.
STATUS_COMMITTED
;
name
=
null
;
name
=
null
;
}
else
{
}
else
{
status
=
(
Integer
)
data
[
0
];
status
=
(
Integer
)
data
[
0
];
name
=
(
String
)
data
[
1
];
name
=
(
String
)
data
[
1
];
}
}
if
(
mapName
.
charAt
(
UNDO_LOG_NAME_PEFIX
.
length
())
==
UNDO_LOG_COMMITTED
)
{
status
=
Transaction
.
STATUS_COMMITTED
;
}
MVMap
<
Long
,
Object
[]>
undoLog
=
store
.
openMap
(
mapName
,
undoLogBuilder
);
MVMap
<
Long
,
Object
[]>
undoLog
=
store
.
openMap
(
mapName
,
undoLogBuilder
);
undoLogs
[
transactionId
]
=
undoLog
;
undoLogs
[
transactionId
]
=
undoLog
;
Long
lastUndoKey
=
undoLog
.
lastKey
();
Long
lastUndoKey
=
undoLog
.
lastKey
();
...
@@ -187,6 +181,21 @@ public class TransactionStore {
...
@@ -187,6 +181,21 @@ public class TransactionStore {
}
}
}
}
/**
* Commit all transactions that are in the committed state, and
* rollback all open transactions.
*/
public
void
endLeftoverTransactions
()
{
List
<
Transaction
>
list
=
getOpenTransactions
();
for
(
Transaction
t
:
list
)
{
if
(
t
.
getStatus
()
==
Transaction
.
STATUS_COMMITTED
)
{
t
.
commit
();
}
else
if
(
t
.
getStatus
()
!=
Transaction
.
STATUS_PREPARED
)
{
t
.
rollback
();
}
}
}
/**
/**
* Set the maximum transaction id, after which ids are re-used. If the old
* Set the maximum transaction id, after which ids are re-used. If the old
* transaction is still in use when re-using an old id, the new transaction
* transaction is still in use when re-using an old id, the new transaction
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论