提交 51c10b97 authored 作者: Thomas Mueller's avatar Thomas Mueller

MVStore: deal with the case that data was moved to a new chunk (work in progress)

上级 0b2f0e40
......@@ -795,16 +795,25 @@ public class MVMap<K, V> extends AbstractMap<K, V>
* @return whether rewriting was successful
*/
boolean rewrite(Set<Integer> set) {
if (root.getVersion() < createVersion) {
// read from old version, to avoid concurrent reads
long previousVersion = store.getCurrentVersion() - 1;
if (previousVersion < createVersion) {
// a new map
return true;
}
// read from old version, to avoid concurrent reads
MVMap<K, V> readMap = openVersion(root.getVersion() - 1);
MVMap<K, V> readMap;
try {
readMap = openVersion(previousVersion);
} catch (IllegalArgumentException e) {
// unknown version: ok
// TODO should not rely on exception handling
return true;
}
try {
rewrite(readMap.root, set);
return true;
} catch (IllegalStateException e) {
// TODO should not rely on exception handling
if (DataUtils.getErrorCode(e.getMessage()) == DataUtils.ERROR_CHUNK_NOT_FOUND) {
// ignore
return false;
......
......@@ -65,7 +65,7 @@ public class TestConcurrent extends TestMVStore {
String fileName = "memFS:testConcurrentChangeAndBackgroundCompact";
FileUtils.delete(fileName);
final MVStore s = new MVStore.Builder().
fileName(fileName).pageSplitSize(100).
fileName(fileName).pageSplitSize(1000).
open();
try {
s.setRetentionTime(1000);
......
......@@ -871,7 +871,8 @@ public class TestMVStore extends TestBase {
private void testFileHeaderCorruption() throws Exception {
String fileName = getBaseDir() + "/testFileHeader.h3";
MVStore s = openStore(fileName);
MVStore s = new MVStore.Builder().
fileName(fileName).pageSplitSize(1000).autoCommitDisabled().open();
s.setRetentionTime(0);
MVMap<Integer, byte[]> map;
map = s.openMap("test");
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论