H2.db file continues to grow

We use the H2 database (persistent) built into our application.

Even after deleting the tables, the h2.db file continues to grow.

We tried to turn off transaction isolation (LOCK_MODE = 0), turned off the query log (TRACE_LEVE_FILE = 0), turned off the cancellation log, but nothing helps.

Is compacting the only option? For compaction, you will need to restart the database, which we cannot do.

0
h2
source share
2 answers

This issue has been resolved. The problem was that we were using a connection stored in the servlet context . This connection has never been closed. We changed the code to independently manage the connections and close the connections after the tables are dropped (and opened again).

+1
source share

Using TRACE_LEVE_FILE=0 only affects the {databaseName}.trace.db , I suggest not using disable tracing. The {databaseName}.trace.db contains human error messages and warnings and should usually be empty. If it is not empty, you may have a bug in your application.

The most common cause of growing database files is uncommitted transactions. Have you completed all transactions? With the latest version of H2 (1.3.168), the message "Transaction log cannot be truncated" is written to the {databaseName}.trace.db . But this requires that you do not use TRACE_LEVE_FILE=0 .

Note that the empty space in the file is reused, but the file is not compressed when the database is open.

+2
source share

All Articles