提交 9f1c68cc authored 作者: noelgrandin@gmail.com's avatar noelgrandin@gmail.com

Fix bug in MVStore when creating lots of temporary tables, where we could run…

Fix bug in MVStore when creating lots of temporary tables, where we could run out of transaction IDs.    
上级 9b500d89
......@@ -57,6 +57,8 @@ Change Log
so that it was effectly 1024 times smaller than it should be.
</li><li>Concurrent CREATE TABLE... IF NOT EXISTS in the presence of MULTI_THREAD=TRUE could
throw an exception.
</li><li>Fix bug in MVStore when creating lots of temporary tables, where we could run out of
transaction IDs.
</li></ul>
<h2>Version 1.4.186 Beta (2015-03-02)</h2>
......
......@@ -71,8 +71,9 @@ public class MVPrimaryIndex extends BaseIndex {
ValueDataType valueType = new ValueDataType(db.getCompareMode(), db,
sortTypes);
mapName = "table." + getId();
dataMap = mvTable.getTransaction(null).openMap(mapName, keyType,
valueType);
Transaction t = mvTable.getTransaction(null);
dataMap = t.openMap(mapName, keyType, valueType);
t.commit();
if (!table.isPersistData()) {
dataMap.map.setVolatile(true);
}
......
......@@ -68,8 +68,9 @@ public class MVSecondaryIndex extends BaseIndex implements MVIndex {
ValueDataType keyType = new ValueDataType(
db.getCompareMode(), db, sortTypes);
ValueDataType valueType = new ValueDataType(null, null, null);
dataMap = mvTable.getTransaction(null).openMap(
mapName, keyType, valueType);
Transaction t = mvTable.getTransaction(null);
dataMap = t.openMap(mapName, keyType, valueType);
t.commit();
if (!keyType.equals(dataMap.getKeyType())) {
throw DbException.throwInternalError("Incompatible key type");
}
......
......@@ -102,7 +102,9 @@ public class MVSpatialIndex extends BaseIndex implements SpatialIndex, MVIndex {
new MVRTreeMap.Builder<VersionedValue>().
valueType(valueType);
spatialMap = db.getMvStore().getStore().openMap(mapName, mapBuilder);
dataMap = mvTable.getTransaction(null).openMap(spatialMap);
Transaction t = mvTable.getTransaction(null);
dataMap = t.openMap(spatialMap);
t.commit();
}
@Override
......
......@@ -45,6 +45,7 @@ public class TestTempTables extends TestBase {
testIndexes(c1, c2);
c1.close();
c2.close();
testLotsOfTables();
deleteDb("tempTables");
}
......@@ -293,4 +294,16 @@ public class TestTempTables extends TestBase {
executeQuery("select * from test_temp");
}
/** There was a bug where creating lots of tables would overflow the transaction table in the MVStore
*/
private void testLotsOfTables() throws SQLException {
deleteDb("tempTables");
Connection conn = getConnection("tempTables");
Statement stat = conn.createStatement();
for (int i = 0; i < 100000; i++) {
stat.executeUpdate("create local temporary table t(id int)");
stat.executeUpdate("drop table t");
}
conn.close();
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论