Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
a90648e1
提交
a90648e1
authored
8月 01, 2014
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
MVStore: deal with the case that data was moved to a new chunk (work in progress)
上级
5175b741
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
44 行增加
和
41 行删除
+44
-41
Chunk.java
h2/src/main/org/h2/mvstore/Chunk.java
+1
-1
MVStore.java
h2/src/main/org/h2/mvstore/MVStore.java
+12
-13
TestConcurrent.java
h2/src/test/org/h2/test/store/TestConcurrent.java
+30
-27
TestMVStore.java
h2/src/test/org/h2/test/store/TestMVStore.java
+1
-0
没有找到文件。
h2/src/main/org/h2/mvstore/Chunk.java
浏览文件 @
a90648e1
...
...
@@ -198,7 +198,7 @@ public class Chunk {
* @return the fill rate
*/
public
int
getFillRate
()
{
if
(
maxLenLive
=
=
0
)
{
if
(
maxLenLive
<
=
0
)
{
return
0
;
}
else
if
(
maxLenLive
==
maxLen
)
{
return
100
;
...
...
h2/src/main/org/h2/mvstore/MVStore.java
浏览文件 @
a90648e1
...
...
@@ -1238,12 +1238,12 @@ public class MVStore {
// are not concurrently modified
c
.
maxLenLive
+=
f
.
maxLenLive
;
c
.
pageCountLive
+=
f
.
pageCountLive
;
if
(
c
.
pageCountLive
<
0
)
{
if
(
c
.
pageCountLive
<
0
&&
c
.
pageCountLive
>
-
Integer
.
MAX_VALUE
/
2
)
{
throw
DataUtils
.
newIllegalStateException
(
DataUtils
.
ERROR_INTERNAL
,
"Corrupt page count {0}"
,
c
.
pageCountLive
);
}
if
(
c
.
maxLenLive
<
0
)
{
if
(
c
.
maxLenLive
<
0
&&
c
.
maxLenLive
>
-
Long
.
MAX_VALUE
/
2
)
{
throw
DataUtils
.
newIllegalStateException
(
DataUtils
.
ERROR_INTERNAL
,
"Corrupt max length {0}"
,
c
.
maxLenLive
);
...
...
@@ -1258,9 +1258,9 @@ public class MVStore {
it
.
remove
();
}
for
(
Chunk
c
:
modified
)
{
if
(
c
.
maxLenLive
=
=
0
)
{
if
(
c
.
maxLenLive
<
=
0
)
{
if
(
c
.
unused
==
0
)
{
c
.
unused
=
getTime
()
;
c
.
unused
=
time
;
}
if
(
canOverwriteChunk
(
c
,
time
))
{
removedChunks
.
add
(
c
);
...
...
@@ -1461,7 +1461,7 @@ public class MVStore {
long
time
=
getTime
();
ArrayList
<
Chunk
>
free
=
New
.
arrayList
();
for
(
Chunk
c
:
chunks
.
values
())
{
if
(
c
.
maxLenLive
=
=
0
)
{
if
(
c
.
maxLenLive
<
=
0
)
{
if
(
canOverwriteChunk
(
c
,
time
))
{
free
.
add
(
c
);
}
...
...
@@ -1689,7 +1689,7 @@ public class MVStore {
for
(
Chunk
c
:
old
)
{
// a concurrent commit could free up the chunk
// so we wait for any commits to finish
if
(
c
.
maxLenLive
=
=
0
)
{
if
(
c
.
maxLenLive
<
=
0
)
{
continue
;
}
// not cleared - that means bookkeeping of live pages
...
...
@@ -1702,7 +1702,7 @@ public class MVStore {
}
}
private
void
compactFixLive
(
Chunk
chunk
)
{
private
synchronized
void
compactFixLive
(
Chunk
chunk
)
{
long
start
=
chunk
.
block
*
BLOCK_SIZE
;
int
length
=
chunk
.
len
*
BLOCK_SIZE
;
ByteBuffer
buff
=
fileStore
.
readFully
(
start
,
length
);
...
...
@@ -1747,11 +1747,9 @@ public class MVStore {
boolean
pendingChanges
=
false
;
for
(
HashMap
<
Integer
,
Chunk
>
e
:
freedPageSpace
.
values
())
{
synchronized
(
e
)
{
for
(
int
x
:
e
.
keySet
())
{
if
(
x
==
chunk
.
id
)
{
pendingChanges
=
true
;
break
;
}
if
(
e
.
containsKey
(
chunk
.
id
))
{
pendingChanges
=
true
;
break
;
}
}
}
...
...
@@ -1759,7 +1757,8 @@ public class MVStore {
// bookkeeping is broken for this chunk:
// fix it
registerFreePage
(
currentVersion
,
chunk
.
id
,
chunk
.
maxLenLive
,
chunk
.
pageCountLive
);
c
.
maxLenLive
+
Long
.
MAX_VALUE
/
2
,
c
.
pageCountLive
+
Integer
.
MAX_VALUE
/
2
);
}
}
}
...
...
h2/src/test/org/h2/test/store/TestConcurrent.java
浏览文件 @
a90648e1
...
...
@@ -66,37 +66,40 @@ public class TestConcurrent extends TestMVStore {
FileUtils
.
delete
(
fileName
);
final
MVStore
s
=
new
MVStore
.
Builder
().
fileName
(
fileName
).
open
();
s
.
setRetentionTime
(
10000
);
s
.
setAutoCommitDelay
(
1
);
Task
task
=
new
Task
()
{
@Override
public
void
call
()
throws
Exception
{
while
(!
stop
)
{
s
.
compact
(
100
,
1024
*
1024
);
try
{
s
.
setRetentionTime
(
1000
);
s
.
setAutoCommitDelay
(
1
);
Task
task
=
new
Task
()
{
@Override
public
void
call
()
throws
Exception
{
while
(!
stop
)
{
s
.
compact
(
100
,
1024
*
1024
);
}
}
}
}
;
final
MVMap
<
Integer
,
Integer
>
dataMap
=
s
.
openMap
(
"data"
);
Task
task2
=
new
Task
()
{
@Override
public
void
call
()
throws
Exception
{
int
i
=
0
;
while
(!
stop
)
{
dataMap
.
put
(
i
++,
i
);
}
;
final
MVMap
<
Integer
,
Integer
>
dataMap
=
s
.
openMap
(
"data"
)
;
Task
task2
=
new
Task
()
{
@Override
public
void
call
()
throws
Exception
{
int
i
=
0
;
while
(!
stop
)
{
dataMap
.
put
(
i
++,
i
);
}
}
};
task
.
execute
();
task2
.
execute
();
Thread
.
sleep
(
1
);
for
(
int
i
=
0
;
!
task
.
isFinished
()
&&
!
task2
.
isFinished
()
&&
i
<
1000
;
i
++)
{
MVMap
<
Integer
,
Integer
>
map
=
s
.
openMap
(
"d"
+
(
i
%
3
));
map
.
put
(
0
,
i
);
s
.
commit
();
}
};
task
.
execute
();
task2
.
execute
();
Thread
.
sleep
(
1
);
for
(
int
i
=
0
;
!
task
.
isFinished
()
&&
!
task2
.
isFinished
()
&&
i
<
1000
;
i
++)
{
MVMap
<
Integer
,
Integer
>
map
=
s
.
openMap
(
"d"
+
(
i
%
3
));
map
.
put
(
0
,
i
);
s
.
commit
();
task
.
get
();
task2
.
get
();
}
finally
{
s
.
close
();
}
task
.
get
();
task2
.
get
();
s
.
close
();
}
private
void
testConcurrentReplaceAndRead
()
throws
InterruptedException
{
...
...
h2/src/test/org/h2/test/store/TestMVStore.java
浏览文件 @
a90648e1
...
...
@@ -444,6 +444,7 @@ public class TestMVStore extends TestBase {
FileUtils
.
delete
(
fileName
);
MVStore
s
=
new
MVStore
.
Builder
().
fileName
(
fileName
).
autoCommitDisabled
().
open
();
MVMap
<
Integer
,
String
>
m
;
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论