提交 900b5667 authored 作者: Thomas Mueller's avatar Thomas Mueller

MVStore: simpler API

上级 e845504a
...@@ -23,6 +23,7 @@ Change Log ...@@ -23,6 +23,7 @@ Change Log
</li><li>Issue 73: MySQL compatibility: support REPLACE, patch by Cemo Koc. </li><li>Issue 73: MySQL compatibility: support REPLACE, patch by Cemo Koc.
</li><li>The spatial index now works in MVCC mode when using the MVStore storage. </li><li>The spatial index now works in MVCC mode when using the MVStore storage.
</li><li>MVStore: concurrency problems have been fixed. </li><li>MVStore: concurrency problems have been fixed.
The API has been simplified.
</li><li>Improve error message when dropping an index that belongs to a constraint, </li><li>Improve error message when dropping an index that belongs to a constraint,
specify constraint in error message. specify constraint in error message.
</li><li>Issue 518: java.sql.Connection.commit() freezes after LOB modification with EXCLUSIVE connection </li><li>Issue 518: java.sql.Connection.commit() freezes after LOB modification with EXCLUSIVE connection
......
...@@ -121,8 +121,7 @@ public class OffHeapStore extends FileStore { ...@@ -121,8 +121,7 @@ public class OffHeapStore extends FileStore {
@Override @Override
public void close() { public void close() {
truncate(0); // do nothing (keep the data until it is garbage collected)
freeSpace.clear();
} }
@Override @Override
......
...@@ -260,7 +260,7 @@ public class MVTableEngine implements TableEngine { ...@@ -260,7 +260,7 @@ public class MVTableEngine implements TableEngine {
public void compactFile(long maxCompactTime) { public void compactFile(long maxCompactTime) {
store.setRetentionTime(0); store.setRetentionTime(0);
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
while (store.compact(90)) { while (store.compact(99)) {
store.sync(); store.sync();
long time = System.currentTimeMillis() - start; long time = System.currentTimeMillis() - start;
if (time > maxCompactTime) { if (time > maxCompactTime) {
...@@ -280,7 +280,7 @@ public class MVTableEngine implements TableEngine { ...@@ -280,7 +280,7 @@ public class MVTableEngine implements TableEngine {
public void close(long maxCompactTime) { public void close(long maxCompactTime) {
if (!store.isClosed() && store.getFileStore() != null) { if (!store.isClosed() && store.getFileStore() != null) {
if (!store.getFileStore().isReadOnly()) { if (!store.getFileStore().isReadOnly()) {
store.store(); transactionStore.close();
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
while (store.compact(90)) { while (store.compact(90)) {
long time = System.currentTimeMillis() - start; long time = System.currentTimeMillis() - start;
......
...@@ -170,7 +170,9 @@ public class TransactionStore { ...@@ -170,7 +170,9 @@ public class TransactionStore {
public synchronized void close() { public synchronized void close() {
// to avoid losing transaction ids // to avoid losing transaction ids
settings.put(LAST_TRANSACTION_ID, "" + lastTransactionId); settings.put(LAST_TRANSACTION_ID, "" + lastTransactionId);
store.store(); if (store.getFileStore() != null) {
store.store();
}
} }
/** /**
...@@ -191,7 +193,6 @@ public class TransactionStore { ...@@ -191,7 +193,6 @@ public class TransactionStore {
private void commitIfNeeded() { private void commitIfNeeded() {
if (store.getUnsavedPageCount() > MAX_UNSAVED_PAGES) { if (store.getUnsavedPageCount() > MAX_UNSAVED_PAGES) {
if (store.getFileStore() != null) { if (store.getFileStore() != null) {
store.commit();
store.store(); store.store();
} }
} }
...@@ -354,10 +355,10 @@ public class TransactionStore { ...@@ -354,10 +355,10 @@ public class TransactionStore {
firstOpenTransaction = -1; firstOpenTransaction = -1;
} }
if (store.getWriteDelay() == 0) { if (store.getWriteDelay() == 0) {
if (store.getFileStore() == null) { if (store.getFileStore() != null) {
return; store.store();
} }
store.commit(); return;
} }
// to avoid having to store the transaction log, // to avoid having to store the transaction log,
// if there is no open transaction, // if there is no open transaction,
...@@ -1207,7 +1208,7 @@ public class TransactionStore { ...@@ -1207,7 +1208,7 @@ public class TransactionStore {
*/ */
public Iterator<K> keyIterator(K from, boolean includeUncommitted) { public Iterator<K> keyIterator(K from, boolean includeUncommitted) {
Cursor<K> it = map.keyIterator(from); Cursor<K> it = map.keyIterator(from);
return wrapIterator(it, false); return wrapIterator(it, includeUncommitted);
} }
/** /**
......
...@@ -470,18 +470,18 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1` ...@@ -470,18 +470,18 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`
prof.interval = 1; prof.interval = 1;
prof.startCollecting(); prof.startCollecting();
if (test.mvStore) { if (test.mvStore) {
TestPerformance.main("-init", "-db", "9", "-size", "10000"); TestPerformance.main("-init", "-db", "9", "-size", "1000");
} else { } else {
TestPerformance.main("-init", "-db", "1"); TestPerformance.main("-init", "-db", "1");
} }
prof.stopCollecting(); prof.stopCollecting();
System.out.println(prof.getTop(3)); System.out.println(prof.getTop(30));
if (test.mvStore) { if (test.mvStore) {
prof = new Profiler(); prof = new Profiler();
prof.depth = 16; prof.depth = 16;
prof.interval = 1; prof.interval = 1;
prof.startCollecting(); prof.startCollecting();
TestPerformance.main("-init", "-db", "1", "-size", "10000"); TestPerformance.main("-init", "-db", "1", "-size", "1000");
prof.stopCollecting(); prof.stopCollecting();
System.out.println(prof.getTop(3)); System.out.println(prof.getTop(3));
} }
......
...@@ -43,7 +43,6 @@ public class TestConcurrent extends TestMVStore { ...@@ -43,7 +43,6 @@ public class TestConcurrent extends TestMVStore {
@Override @Override
public void test() throws Exception { public void test() throws Exception {
FileUtils.deleteRecursive(getBaseDir(), true); FileUtils.deleteRecursive(getBaseDir(), true);
FileUtils.createDirectories(getBaseDir()); FileUtils.createDirectories(getBaseDir());
FileUtils.deleteRecursive("memFS:", false); FileUtils.deleteRecursive("memFS:", false);
...@@ -110,7 +109,7 @@ public class TestConcurrent extends TestMVStore { ...@@ -110,7 +109,7 @@ public class TestConcurrent extends TestMVStore {
m.clear(); m.clear();
s.removeMap(m); s.removeMap(m);
if (x % 5 == 0) { if (x % 5 == 0) {
s.incrementVersion(); s.commit();
} }
} }
task.get(); task.get();
...@@ -124,9 +123,9 @@ public class TestConcurrent extends TestMVStore { ...@@ -124,9 +123,9 @@ public class TestConcurrent extends TestMVStore {
} }
} }
assertEquals(1, chunkCount); assertEquals(1, chunkCount);
s.close(); s.close();
} }
FileUtils.deleteRecursive("memFS:", false);
} }
private void testConcurrentStoreAndRemoveMap() throws InterruptedException { private void testConcurrentStoreAndRemoveMap() throws InterruptedException {
...@@ -159,6 +158,7 @@ public class TestConcurrent extends TestMVStore { ...@@ -159,6 +158,7 @@ public class TestConcurrent extends TestMVStore {
} }
task.get(); task.get();
s.close(); s.close();
FileUtils.deleteRecursive("memFS:", false);
} }
private void testConcurrentStoreAndClose() throws InterruptedException { private void testConcurrentStoreAndClose() throws InterruptedException {
...@@ -200,6 +200,7 @@ public class TestConcurrent extends TestMVStore { ...@@ -200,6 +200,7 @@ public class TestConcurrent extends TestMVStore {
} }
s.close(); s.close();
} }
FileUtils.deleteRecursive("memFS:", false);
} }
/** /**
...@@ -249,7 +250,7 @@ public class TestConcurrent extends TestMVStore { ...@@ -249,7 +250,7 @@ public class TestConcurrent extends TestMVStore {
} }
m.get(rand.nextInt(size)); m.get(rand.nextInt(size));
} }
s.incrementVersion(); s.commit();
Thread.sleep(1); Thread.sleep(1);
} }
task.get(); task.get();
...@@ -341,7 +342,7 @@ public class TestConcurrent extends TestMVStore { ...@@ -341,7 +342,7 @@ public class TestConcurrent extends TestMVStore {
for (int k = 0; k < 10000; k++) { for (int k = 0; k < 10000; k++) {
Iterator<Integer> it = map.keyIterator(r.nextInt(len)); Iterator<Integer> it = map.keyIterator(r.nextInt(len));
long old = s.getCurrentVersion(); long old = s.getCurrentVersion();
s.incrementVersion(); s.commit();
s.setRetainVersion(old - 100); s.setRetainVersion(old - 100);
while (map.getVersion() == old) { while (map.getVersion() == old) {
Thread.yield(); Thread.yield();
...@@ -423,7 +424,7 @@ public class TestConcurrent extends TestMVStore { ...@@ -423,7 +424,7 @@ public class TestConcurrent extends TestMVStore {
notDetected.incrementAndGet(); notDetected.incrementAndGet();
} }
} }
s.incrementVersion(); s.commit();
Thread.sleep(1); Thread.sleep(1);
} }
task.get(); task.get();
...@@ -438,7 +439,7 @@ public class TestConcurrent extends TestMVStore { ...@@ -438,7 +439,7 @@ public class TestConcurrent extends TestMVStore {
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
m.put(i, x); m.put(i, x);
} }
s.incrementVersion(); s.commit();
Task task = new Task() { Task task = new Task() {
@Override @Override
public void call() throws Exception { public void call() throws Exception {
...@@ -462,7 +463,7 @@ public class TestConcurrent extends TestMVStore { ...@@ -462,7 +463,7 @@ public class TestConcurrent extends TestMVStore {
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
m.put(i, x); m.put(i, x);
} }
s.incrementVersion(); s.commit();
Thread.sleep(1); Thread.sleep(1);
} }
task.get(); task.get();
......
...@@ -148,7 +148,7 @@ public class TestMVStore extends TestBase { ...@@ -148,7 +148,7 @@ public class TestMVStore extends TestBase {
s.store(); s.store();
} }
assertTrue(1000 < offHeap.getWriteCount()); assertTrue(1000 < offHeap.getWriteCount());
// s.close(); s.close();
s = new MVStore.Builder(). s = new MVStore.Builder().
fileStore(offHeap). fileStore(offHeap).
...@@ -253,7 +253,6 @@ public class TestMVStore extends TestBase { ...@@ -253,7 +253,6 @@ public class TestMVStore extends TestBase {
m = s.openMap("data"); m = s.openMap("data");
s.getFileStore().getFile().close(); s.getFileStore().getFile().close();
m.put(1, "Hello"); m.put(1, "Hello");
s.commit();
for (int i = 0; i < 100; i++) { for (int i = 0; i < 100; i++) {
if (exRef.get() != null) { if (exRef.get() != null) {
break; break;
...@@ -330,19 +329,19 @@ public class TestMVStore extends TestBase { ...@@ -330,19 +329,19 @@ public class TestMVStore extends TestBase {
fileName(fileName). fileName(fileName).
open(); open();
m = s.openMap("data"); m = s.openMap("data");
assertFalse(m.containsKey(1)); assertTrue(m.containsKey(1));
m.put(1, data); m.put(-1, data);
s.commit(); s.store();
m.put(2, data); m.put(-2, data);
s.close(); s.close();
s = new MVStore.Builder(). s = new MVStore.Builder().
fileName(fileName). fileName(fileName).
open(); open();
m = s.openMap("data"); m = s.openMap("data");
assertTrue(m.containsKey(1)); assertTrue(m.containsKey(-1));
assertFalse(m.containsKey(2)); assertTrue(m.containsKey(-2));
s.close(); s.close();
FileUtils.delete(fileName); FileUtils.delete(fileName);
...@@ -377,7 +376,7 @@ public class TestMVStore extends TestBase { ...@@ -377,7 +376,7 @@ public class TestMVStore extends TestBase {
m.put(1, "Hello"); m.put(1, "Hello");
s.store(); s.store();
long v = s.getCurrentVersion(); long v = s.getCurrentVersion();
m.put(2, "World"); m.put(2, "World.");
Thread.sleep(5); Thread.sleep(5);
// must not store, as nothing has been committed yet // must not store, as nothing has been committed yet
s.closeImmediately(); s.closeImmediately();
...@@ -386,9 +385,11 @@ public class TestMVStore extends TestBase { ...@@ -386,9 +385,11 @@ public class TestMVStore extends TestBase {
open(); open();
s.setWriteDelay(1); s.setWriteDelay(1);
m = s.openMap("data"); m = s.openMap("data");
assertEquals(null, m.get(2)); assertEquals("World.", m.get(2));
m.put(2, "World"); m.put(2, "World");
s.commit(); s.commit();
s.store();
v = s.getCurrentVersion();
m.put(3, "!"); m.put(3, "!");
for (int i = 100; i > 0; i--) { for (int i = 100; i > 0; i--) {
...@@ -400,7 +401,7 @@ public class TestMVStore extends TestBase { ...@@ -400,7 +401,7 @@ public class TestMVStore extends TestBase {
} }
Thread.sleep(1); Thread.sleep(1);
} }
s.close(); s.closeImmediately();
s = new MVStore.Builder(). s = new MVStore.Builder().
fileName(fileName). fileName(fileName).
...@@ -408,7 +409,7 @@ public class TestMVStore extends TestBase { ...@@ -408,7 +409,7 @@ public class TestMVStore extends TestBase {
m = s.openMap("data"); m = s.openMap("data");
assertEquals("Hello", m.get(1)); assertEquals("Hello", m.get(1));
assertEquals("World", m.get(2)); assertEquals("World", m.get(2));
assertFalse(m.containsKey(3)); assertEquals("!", m.get(3));
s.close(); s.close();
FileUtils.delete(fileName); FileUtils.delete(fileName);
...@@ -517,7 +518,7 @@ public class TestMVStore extends TestBase { ...@@ -517,7 +518,7 @@ public class TestMVStore extends TestBase {
MVMap<Integer, Integer> map; MVMap<Integer, Integer> map;
map = s.openMap("hello"); map = s.openMap("hello");
map.put(1, 10); map.put(1, 10);
long old = s.incrementVersion(); long old = s.commit();
s.renameMap(map, "world"); s.renameMap(map, "world");
map.put(2, 20); map.put(2, 20);
assertEquals("world", map.getName()); assertEquals("world", map.getName());
...@@ -557,7 +558,7 @@ public class TestMVStore extends TestBase { ...@@ -557,7 +558,7 @@ public class TestMVStore extends TestBase {
s.store(); s.store();
s.close(); s.close();
int[] expectedReadsForCacheSize = { int[] expectedReadsForCacheSize = {
3405, 2590, 1924, 1440, 1103, 956, 918 3405, 2590, 1924, 1440, 1108, 956, 918
}; };
for (int cacheSize = 0; cacheSize <= 6; cacheSize += 4) { for (int cacheSize = 0; cacheSize <= 6; cacheSize += 4) {
s = new MVStore.Builder(). s = new MVStore.Builder().
...@@ -816,8 +817,10 @@ public class TestMVStore extends TestBase { ...@@ -816,8 +817,10 @@ public class TestMVStore extends TestBase {
MVStore s = MVStore.open(fileName); MVStore s = MVStore.open(fileName);
assertEquals(0, s.getCurrentVersion()); assertEquals(0, s.getCurrentVersion());
assertEquals(0, s.getStoreVersion()); assertEquals(0, s.getStoreVersion());
s.setStoreVersion(0);
s.store();
s.setStoreVersion(1); s.setStoreVersion(1);
s.close(); s.closeImmediately();
s = MVStore.open(fileName); s = MVStore.open(fileName);
assertEquals(1, s.getCurrentVersion()); assertEquals(1, s.getCurrentVersion());
assertEquals(0, s.getStoreVersion()); assertEquals(0, s.getStoreVersion());
...@@ -840,7 +843,7 @@ public class TestMVStore extends TestBase { ...@@ -840,7 +843,7 @@ public class TestMVStore extends TestBase {
map.put(i, 10 * i); map.put(i, 10 * i);
} }
Iterator<Integer> it = map.keySet().iterator(); Iterator<Integer> it = map.keySet().iterator();
s.incrementVersion(); s.commit();
for (int i = 0; i < len; i += 2) { for (int i = 0; i < len; i += 2) {
map.remove(i); map.remove(i);
} }
...@@ -916,7 +919,7 @@ public class TestMVStore extends TestBase { ...@@ -916,7 +919,7 @@ public class TestMVStore extends TestBase {
long oldVersion = s.getCurrentVersion(); long oldVersion = s.getCurrentVersion();
// from now on, the old version is read-only // from now on, the old version is read-only
s.incrementVersion(); s.commit();
// more changes, in the new version // more changes, in the new version
// changes can be rolled back if required // changes can be rolled back if required
...@@ -976,7 +979,7 @@ public class TestMVStore extends TestBase { ...@@ -976,7 +979,7 @@ public class TestMVStore extends TestBase {
if (op == 1) { if (op == 1) {
m.put("1", "" + s.getCurrentVersion()); m.put("1", "" + s.getCurrentVersion());
} }
s.incrementVersion(); s.commit();
} }
for (int j = 0; j < s.getCurrentVersion(); j++) { for (int j = 0; j < s.getCurrentVersion(); j++) {
MVMap<String, String> old = m.openVersion(j); MVMap<String, String> old = m.openVersion(j);
...@@ -997,14 +1000,14 @@ public class TestMVStore extends TestBase { ...@@ -997,14 +1000,14 @@ public class TestMVStore extends TestBase {
MVMap<String, String> m; MVMap<String, String> m;
m = s.openMap("data"); m = s.openMap("data");
long first = s.getCurrentVersion(); long first = s.getCurrentVersion();
s.incrementVersion(); s.commit();
m.put("1", "Hello"); m.put("1", "Hello");
m.put("2", "World"); m.put("2", "World");
for (int i = 10; i < 20; i++) { for (int i = 10; i < 20; i++) {
m.put("" + i, "data"); m.put("" + i, "data");
} }
long old = s.getCurrentVersion(); long old = s.getCurrentVersion();
s.incrementVersion(); s.commit();
m.put("1", "Hallo"); m.put("1", "Hallo");
m.put("2", "Welt"); m.put("2", "Welt");
MVMap<String, String> mFirst; MVMap<String, String> mFirst;
...@@ -1119,7 +1122,7 @@ public class TestMVStore extends TestBase { ...@@ -1119,7 +1122,7 @@ public class TestMVStore extends TestBase {
assertTrue(s.hasUnsavedChanges()); assertTrue(s.hasUnsavedChanges());
MVMap<String, String> m0 = s.openMap("data0"); MVMap<String, String> m0 = s.openMap("data0");
m.put("1", "Hello"); m.put("1", "Hello");
assertEquals(1, s.incrementVersion()); assertEquals(1, s.commit());
s.rollbackTo(1); s.rollbackTo(1);
assertEquals(1, s.getCurrentVersion()); assertEquals(1, s.getCurrentVersion());
assertEquals("Hello", m.get("1")); assertEquals("Hello", m.get("1"));
...@@ -1167,16 +1170,13 @@ public class TestMVStore extends TestBase { ...@@ -1167,16 +1170,13 @@ public class TestMVStore extends TestBase {
assertEquals("Hello", m.get("1")); assertEquals("Hello", m.get("1"));
assertFalse(m0.isReadOnly()); assertFalse(m0.isReadOnly());
m.put("1", "Hallo"); m.put("1", "Hallo");
s.incrementVersion(); s.commit();
long v3 = s.getCurrentVersion(); long v3 = s.getCurrentVersion();
assertEquals(3, v3); assertEquals(3, v3);
long v4 = s.store();
assertEquals(4, v4);
assertEquals(4, s.getCurrentVersion());
s.close(); s.close();
s = openStore(fileName); s = openStore(fileName);
assertEquals(4, s.getCurrentVersion()); assertEquals(3, s.getCurrentVersion());
m = s.openMap("data"); m = s.openMap("data");
m.put("1", "Hi"); m.put("1", "Hi");
s.store(); s.store();
...@@ -1185,7 +1185,7 @@ public class TestMVStore extends TestBase { ...@@ -1185,7 +1185,7 @@ public class TestMVStore extends TestBase {
s = openStore(fileName); s = openStore(fileName);
m = s.openMap("data"); m = s.openMap("data");
assertEquals("Hi", m.get("1")); assertEquals("Hi", m.get("1"));
s.rollbackTo(v4); s.rollbackTo(v3);
assertEquals("Hallo", m.get("1")); assertEquals("Hallo", m.get("1"));
s.close(); s.close();
...@@ -1212,7 +1212,7 @@ public class TestMVStore extends TestBase { ...@@ -1212,7 +1212,7 @@ public class TestMVStore extends TestBase {
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
m2.put("" + i, "Test"); m2.put("" + i, "Test");
} }
long v1 = s.incrementVersion(); long v1 = s.commit();
assertEquals(1, v1); assertEquals(1, v1);
assertEquals(1, s.getCurrentVersion()); assertEquals(1, s.getCurrentVersion());
MVMap<String, String> m1 = s.openMap("data1"); MVMap<String, String> m1 = s.openMap("data1");
......
...@@ -73,7 +73,7 @@ public class TestMVStoreBenchmark extends TestBase { ...@@ -73,7 +73,7 @@ public class TestMVStoreBenchmark extends TestBase {
} }
private static long[] getMemoryUsed(int count, int size) { private long[] getMemoryUsed(int count, int size) {
long hash, tree, mv; long hash, tree, mv;
ArrayList<Map<Integer, String>> mapList; ArrayList<Map<Integer, String>> mapList;
long mem; long mem;
...@@ -107,6 +107,10 @@ public class TestMVStoreBenchmark extends TestBase { ...@@ -107,6 +107,10 @@ public class TestMVStoreBenchmark extends TestBase {
mv = getMemory() - mem; mv = getMemory() - mem;
mapList.size(); mapList.size();
trace("hash: " + hash / 1024 / 1024 + " mb");
trace("tree: " + tree / 1024 / 1024 + " mb");
trace("mv: " + mv / 1024 / 1024 + " mb");
return new long[]{hash, tree, mv}; return new long[]{hash, tree, mv};
} }
...@@ -179,7 +183,7 @@ public class TestMVStoreBenchmark extends TestBase { ...@@ -179,7 +183,7 @@ public class TestMVStoreBenchmark extends TestBase {
} }
time = System.currentTimeMillis() - time; time = System.currentTimeMillis() - time;
} }
// System.out.println(map.getClass().getName() + ": " + time); trace(map.getClass().getName() + ": " + time);
return time; return time;
} }
......
...@@ -141,7 +141,7 @@ public class TestMVTableEngine extends TestBase { ...@@ -141,7 +141,7 @@ public class TestMVTableEngine extends TestBase {
conn.close(); conn.close();
long sizeNew = FileUtils.size(getBaseDir() + "/mvstore" long sizeNew = FileUtils.size(getBaseDir() + "/mvstore"
+ Constants.SUFFIX_MV_FILE); + Constants.SUFFIX_MV_FILE);
assertTrue(sizeNew < sizeOld); assertTrue("new: " + sizeNew + " old: " + sizeOld, sizeNew < sizeOld);
} }
private void testTwoPhaseCommit() throws Exception { private void testTwoPhaseCommit() throws Exception {
......
...@@ -59,6 +59,7 @@ public class TestTransactionStore extends TestBase { ...@@ -59,6 +59,7 @@ public class TestTransactionStore extends TestBase {
private void testStopWhileCommitting() throws Exception { private void testStopWhileCommitting() throws Exception {
String fileName = getBaseDir() + "/testStopWhileCommitting.h3"; String fileName = getBaseDir() + "/testStopWhileCommitting.h3";
FileUtils.delete(fileName); FileUtils.delete(fileName);
Random r = new Random(0);
for (int i = 0; i < 10;) { for (int i = 0; i < 10;) {
MVStore s; MVStore s;
...@@ -100,6 +101,16 @@ public class TestTransactionStore extends TestBase { ...@@ -100,6 +101,16 @@ public class TestTransactionStore extends TestBase {
task.get(); task.get();
store.close(); store.close();
s = MVStore.open(fileName); s = MVStore.open(fileName);
// roll back a bit, until we have some undo log entries
assertTrue(s.hasMap("undoLog"));
for (int back = 0; back < 100; back++) {
int minus = r.nextInt(10);
s.rollbackTo(Math.max(0, s.getCurrentVersion() - minus));
MVMap<?, ?> undo = s.openMap("undoLog");
if (undo.size() > 0) {
break;
}
}
ts = new TransactionStore(s); ts = new TransactionStore(s);
List<Transaction> list = ts.getOpenTransactions(); List<Transaction> list = ts.getOpenTransactions();
if (list.size() != 0) { if (list.size() != 0) {
...@@ -111,10 +122,6 @@ public class TestTransactionStore extends TestBase { ...@@ -111,10 +122,6 @@ public class TestTransactionStore extends TestBase {
s.close(); s.close();
FileUtils.delete(fileName); FileUtils.delete(fileName);
assertFalse(FileUtils.exists(fileName)); assertFalse(FileUtils.exists(fileName));
FileUtils.delete(fileName);
assertFalse(FileUtils.exists(fileName));
s.close();
FileUtils.delete(fileName);
} }
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论