Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
e72272df
提交
e72272df
authored
8月 05, 2014
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix bookkeeping of live pages
上级
c9f55a5b
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
55 行增加
和
12 行删除
+55
-12
Chunk.java
h2/src/main/org/h2/mvstore/Chunk.java
+5
-0
MVStore.java
h2/src/main/org/h2/mvstore/MVStore.java
+2
-1
Page.java
h2/src/main/org/h2/mvstore/Page.java
+6
-4
MVTableEngine.java
h2/src/main/org/h2/mvstore/db/MVTableEngine.java
+7
-3
TestBackup.java
h2/src/test/org/h2/test/db/TestBackup.java
+3
-4
TestMVStore.java
h2/src/test/org/h2/test/store/TestMVStore.java
+32
-0
没有找到文件。
h2/src/main/org/h2/mvstore/Chunk.java
浏览文件 @
e72272df
...
@@ -154,6 +154,11 @@ public class Chunk {
...
@@ -154,6 +154,11 @@ public class Chunk {
while
(
buff
.
position
()
-
pos
<
minLength
-
1
)
{
while
(
buff
.
position
()
-
pos
<
minLength
-
1
)
{
buff
.
put
((
byte
)
' '
);
buff
.
put
((
byte
)
' '
);
}
}
if
(
minLength
!=
0
&&
buff
.
position
()
>
minLength
)
{
throw
DataUtils
.
newIllegalStateException
(
DataUtils
.
ERROR_INTERNAL
,
"Chunk metadata too long"
);
}
buff
.
put
((
byte
)
'\n'
);
buff
.
put
((
byte
)
'\n'
);
}
}
...
...
h2/src/main/org/h2/mvstore/MVStore.java
浏览文件 @
e72272df
...
@@ -1844,7 +1844,8 @@ public class MVStore {
...
@@ -1844,7 +1844,8 @@ public class MVStore {
version
=
currentStoreVersion
;
version
=
currentStoreVersion
;
}
}
}
}
registerFreePage
(
version
,
c
.
id
,
DataUtils
.
getPageMaxLength
(
pos
),
1
);
registerFreePage
(
version
,
c
.
id
,
DataUtils
.
getPageMaxLength
(
pos
),
1
);
}
}
private
void
registerFreePage
(
long
version
,
int
chunkId
,
private
void
registerFreePage
(
long
version
,
int
chunkId
,
...
...
h2/src/main/org/h2/mvstore/Page.java
浏览文件 @
e72272df
...
@@ -918,12 +918,14 @@ public class Page {
...
@@ -918,12 +918,14 @@ public class Page {
store
.
cachePage
(
pos
,
this
,
getMemory
());
store
.
cachePage
(
pos
,
this
,
getMemory
());
long
max
=
DataUtils
.
getPageMaxLength
(
pos
);
long
max
=
DataUtils
.
getPageMaxLength
(
pos
);
chunk
.
maxLen
+=
max
;
chunk
.
maxLen
+=
max
;
chunk
.
maxLenLive
+=
max
;
chunk
.
pageCount
++;
chunk
.
pageCount
++;
if
(!
removedInMemory
)
{
chunk
.
pageCountLive
++;
if
(
removedInMemory
)
{
// if the page was removed _before_ the position was assigned, we
// if the page was removed _before_ the position was assigned, we
//
must not increase the live fields.
//
need to mark it removed here, so the fields are updated
chunk
.
maxLenLive
+=
max
;
// when the next chunk is stored
chunk
.
pageCountLive
++
;
map
.
removePage
(
pos
,
memory
)
;
}
}
return
typePos
+
1
;
return
typePos
+
1
;
}
}
...
...
h2/src/main/org/h2/mvstore/db/MVTableEngine.java
浏览文件 @
e72272df
...
@@ -342,14 +342,18 @@ public class MVTableEngine implements TableEngine {
...
@@ -342,14 +342,18 @@ public class MVTableEngine implements TableEngine {
}
}
String
fileName
=
store
.
getFileStore
().
getFileName
();
String
fileName
=
store
.
getFileStore
().
getFileName
();
store
.
close
();
store
.
close
();
if
(
compactFully
)
{
if
(
compactFully
&&
FileUtils
.
exists
(
fileName
))
{
// the file could have been deleted concurrently,
// so only compact if the file still exists
MVStoreTool
.
compact
(
fileName
,
true
);
MVStoreTool
.
compact
(
fileName
,
true
);
}
}
}
}
}
catch
(
IllegalStateException
e
)
{
}
catch
(
IllegalStateException
e
)
{
i
f
(
DataUtils
.
getErrorCode
(
e
.
getMessage
())
==
i
nt
errorCode
=
DataUtils
.
getErrorCode
(
e
.
getMessage
());
DataUtils
.
ERROR_WRITING_FAILED
)
{
if
(
errorCode
==
DataUtils
.
ERROR_WRITING_FAILED
)
{
// disk full - ok
// disk full - ok
}
else
if
(
errorCode
==
DataUtils
.
ERROR_FILE_CORRUPT
)
{
// wrong encryption key - ok
}
else
{
}
else
{
// TODO
// TODO
;
;
...
...
h2/src/test/org/h2/test/db/TestBackup.java
浏览文件 @
e72272df
...
@@ -85,9 +85,8 @@ public class TestBackup extends TestBase {
...
@@ -85,9 +85,8 @@ public class TestBackup extends TestBase {
updateEnd
.
set
(
System
.
currentTimeMillis
()
+
2000
);
updateEnd
.
set
(
System
.
currentTimeMillis
()
+
2000
);
stat2
.
execute
(
"backup to '"
+
getBaseDir
()+
"/backup.zip'"
);
stat2
.
execute
(
"backup to '"
+
getBaseDir
()+
"/backup.zip'"
);
stat2
.
execute
(
"checkpoint"
);
stat2
.
execute
(
"checkpoint"
);
Restore
.
execute
(
getBaseDir
()
+
"/backup.zip"
,
getBaseDir
()
+
"/t2"
,
"backup"
);
Restore
.
execute
(
getBaseDir
()
+
"/backup.zip"
,
getBaseDir
()
+
"/t"
+
i
,
"backup"
);
Connection
conn3
;
Connection
conn3
=
getConnection
(
"t"
+
i
+
"/backup"
);
conn3
=
getConnection
(
"t2/backup"
);
Statement
stat3
=
conn3
.
createStatement
();
Statement
stat3
=
conn3
.
createStatement
();
stat3
.
execute
(
"script"
);
stat3
.
execute
(
"script"
);
ResultSet
rs
=
stat3
.
executeQuery
(
ResultSet
rs
=
stat3
.
executeQuery
(
...
@@ -98,9 +97,9 @@ public class TestBackup extends TestBase {
...
@@ -98,9 +97,9 @@ public class TestBackup extends TestBase {
conn3
.
close
();
conn3
.
close
();
}
}
task
.
get
();
task
.
get
();
conn2
.
close
();
conn
.
close
();
conn
.
close
();
conn1
.
close
();
conn1
.
close
();
conn2
.
close
();
}
}
/**
/**
...
...
h2/src/test/org/h2/test/store/TestMVStore.java
浏览文件 @
e72272df
...
@@ -52,6 +52,7 @@ public class TestMVStore extends TestBase {
...
@@ -52,6 +52,7 @@ public class TestMVStore extends TestBase {
public
void
test
()
throws
Exception
{
public
void
test
()
throws
Exception
{
FileUtils
.
deleteRecursive
(
getBaseDir
(),
true
);
FileUtils
.
deleteRecursive
(
getBaseDir
(),
true
);
FileUtils
.
createDirectories
(
getBaseDir
());
FileUtils
.
createDirectories
(
getBaseDir
());
testRemoveMapRollback
();
testProvidedFileStoreNotOpenedAndClosed
();
testProvidedFileStoreNotOpenedAndClosed
();
testVolatileMap
();
testVolatileMap
();
testEntrySet
();
testEntrySet
();
...
@@ -112,6 +113,37 @@ public class TestMVStore extends TestBase {
...
@@ -112,6 +113,37 @@ public class TestMVStore extends TestBase {
testLargerThan2G
();
testLargerThan2G
();
}
}
private
void
testRemoveMapRollback
()
{
MVStore
store
=
new
MVStore
.
Builder
().
open
();
MVMap
<
String
,
String
>
map
=
store
.
openMap
(
"test"
);
map
.
put
(
"1"
,
"Hello"
);
store
.
commit
();
store
.
removeMap
(
map
);
store
.
rollback
();
assertTrue
(
store
.
hasMap
(
"test"
));
map
=
store
.
openMap
(
"test"
);
// TODO the data should get back alive
assertNull
(
map
.
get
(
"1"
));
store
.
close
();
String
fileName
=
getBaseDir
()
+
"/testRemoveMapRollback.h3"
;
store
=
new
MVStore
.
Builder
().
autoCommitDisabled
().
fileName
(
fileName
).
open
();
map
=
store
.
openMap
(
"test"
);
map
.
put
(
"1"
,
"Hello"
);
store
.
commit
();
store
.
removeMap
(
map
);
store
.
rollback
();
assertTrue
(
store
.
hasMap
(
"test"
));
map
=
store
.
openMap
(
"test"
);
// TODO the data should get back alive
assertNull
(
map
.
get
(
"1"
));
store
.
close
();
}
private
void
testProvidedFileStoreNotOpenedAndClosed
()
{
private
void
testProvidedFileStoreNotOpenedAndClosed
()
{
final
AtomicInteger
openClose
=
new
AtomicInteger
();
final
AtomicInteger
openClose
=
new
AtomicInteger
();
FileStore
fileStore
=
new
OffHeapStore
()
{
FileStore
fileStore
=
new
OffHeapStore
()
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论