提交 ac64cbc7 authored 作者: Thomas Mueller's avatar Thomas Mueller

MVStore: in some cases, CLOB/BLOB data blocks were removed incorrectly when opening a database.

上级 0cf61159
...@@ -123,6 +123,11 @@ public class LobStorageMap implements LobStorageInterface { ...@@ -123,6 +123,11 @@ public class LobStorageMap implements LobStorageInterface {
} }
dataMap.remove(last); dataMap.remove(last);
} }
// don't re-use block ids, except at the very end
Long last = dataMap.lastKey();
if (last != null) {
streamStore.setNextKey(last + 1);
}
} }
@Override @Override
......
...@@ -51,6 +51,7 @@ public class TestMVTableEngine extends TestBase { ...@@ -51,6 +51,7 @@ public class TestMVTableEngine extends TestBase {
@Override @Override
public void test() throws Exception { public void test() throws Exception {
testLobReuse();
testShutdownDuringLobCreation(); testShutdownDuringLobCreation();
testLobCreationThenShutdown(); testLobCreationThenShutdown();
testManyTransactions(); testManyTransactions();
...@@ -86,6 +87,30 @@ public class TestMVTableEngine extends TestBase { ...@@ -86,6 +87,30 @@ public class TestMVTableEngine extends TestBase {
testLocking(); testLocking();
testSimple(); testSimple();
} }
private void testLobReuse() throws Exception {
deleteDb("testLobReuse");
Connection conn = getConnection("testLobReuse");
Statement stat = conn.createStatement();
stat.execute("create table test(id identity primary key, lob clob)");
conn.close();
byte[] buffer = new byte[8192];
for (int i = 0; i < 20; i++) {
conn = getConnection("testLobReuse");
stat = conn.createStatement();
stat.execute("insert into test(lob) select space(1025) from system_range(1, 10)");
stat.execute("delete from test where random() > 0.5");
ResultSet rs = conn.createStatement().executeQuery(
"select lob from test");
while (rs.next()) {
InputStream is = rs.getBinaryStream(1);
while (is.read(buffer) != -1) {
// ignore
}
}
conn.close();
}
}
private void testShutdownDuringLobCreation() throws Exception { private void testShutdownDuringLobCreation() throws Exception {
deleteDb("testShutdownDuringLobCreation"); deleteDb("testShutdownDuringLobCreation");
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论