Hello,
i was able to reproduce the problem and found two scenarios where the
records in the table information_schema.lob_data remains.
*First case*:
open database connection -> insert data records -> rollback -> close
database connection
*Second case*:
open database connection -> insert data records -> close database connection
at least the first case should have cleaned up the lob tables!
I've created a new database with a table test with an id (int) and
data(CLOB). Below is some quick java code i came up with to reproduce the
problem:
I got the same results by connecting directly to the database and testing
manually.
*Expected Result:*
select count(*) from test
0
select count(*) from information_schema.lob_data
0
*Actual Result:*
select count(*) from test
0
select count(*) from information_schema.lob_data
10000
Testcase wrote
> import java.sql.Connection;
> import java.sql.DriverManager;
> import java.sql.SQLException;
> import java.sql.Statement;
>
>
> public class Testcase1 {
>
> public static void main(String[] args) {
> final String dbUser = "sa";
> final String dbPassword = "sa";
> final String h2ConnectionURL =
> "jdbc:h2:D:\\workspaces\\h2testing_workspace\\h2testing\\database\\DBtest";
> final String h2Driver = "org.h2.Driver";
> final String testTable = "test";
>
> Connection con = null;
> Statement stmt = null;
>
> /*
> * create table test
> * (
> * id int,
> * data CLOB
> * )
> *
> */
>
> //open database connection
> try {
> Class.forName(h2Driver);
> con = DriverManager.getConnection(h2ConnectionURL,
> dbUser, dbPassword);
> con.setAutoCommit(false);
> }
> catch (SQLException e) {
> System.out.println("Failed to open Database connection");
> }
> catch (ClassNotFoundException e){
> System.out.println("Failed to open Database connection");
> }
>
> //create database statement
> try {
> stmt = con.createStatement();
> } catch (SQLException e) {
> System.out.println("Failed to create Statment");
> }
>
> //insert test data, 10000 data records
> int testDataRecords = 10000;
> int Id = 0;
> for (int i = 0; i < testDataRecords; i++){
>
> //generate test data
> String rdmString = "";
> for(int j = 0; j < 20; j++){
> rdmString += Long.toHexString(Double.doubleToLongBits(Math.random()));
> }
>
> //insert
> try {
> stmt.executeUpdate("insert into " + testTable + " values ('" + Id++ +
> "','" + rdmString + "')");
> } catch (SQLException e) {
> System.out.println("Failed to insert test data");
> }
>
> }
>
> //rollback
> try {
> con.rollback();
> } catch (SQLException e) {
> System.out.println("Failed to rollback the database connection");
> }
>
>
> //close connection
> try {
> stmt.close();
> con.close();
> } catch (SQLException e) {
> System.out.println("Failed to close the database connection");
> }
>
> }
>
> }
Regards,
dresa
dresa_ wrote
--
View this message in context:
http://h2-database.66688.n3.nabble.com/DB-File-growth-internal-LOB-tables-are-not-cleaned-up-tp4027264p4028456.html