The client I'm working with is running H2 in an embedded device. The device is an industrial control device that will be hard wired for power on a factory floor. Thus, there is no state where the device cleanly shuts down the JVM. It gets power and starts the JVM, the application and H2, the device runs and then power will be lost at some point. There will be no opportunity for JVM shutdown hooks to run.
We have a power cycle test that powers the device, starts H2 and the application and then cuts power. We run this test for hours cycling power every minute. We have a H2 database with three tables and a small number of rows, maybe a thousand rows total. This db is 99% reads. When we start the power cycle test this db is around 1MB. After a few hours the .db file grows many times larger. The largest I've seen is 200 MB. This is a problem as this is an embedded device with a small amount of storage. The Java code that is accessing this database is using an Apache dbcp BasicDatasource backed by a connection pool. The BasicDatasource is configured to auto commit, so there are not open transactions. There are, however, open connections in the pool at the time of power loss. I've tried pulling the .db file off of the device, connecting to the db, running SHUTDOWN COMPRESS and then properly shutting down the JVM, but this does not reduce the size of the file. Here is the end of the Recovery Tool output: ---- Transaction log ---- ---- Statistics ---- -- page count: 74785, free: 1 -- page data bytes: head 4910, empty 65722, rows 89112 (59% full) -- free 99%, 74668 page(s) -- data leaf 0%, 78 page(s) -- data node 0%, 3 page(s) -- btree leaf 0%, 17 page(s) -- btree node 0%, 2 page(s) -- free list 0%, 5 page(s) -- stream data 0%, 9 page(s) If I'm reading this correctly, this show 74,668 pages that are 99% free. I'm assuming that this is what is consuming all the file space. What can I do at runtime on the device to free up this space? I'm running: ARM processor MontaVista Linux Java 1.6 H2 1.3.160 Connection String: jdbc:h2:/etc/cache/db/events/EventDefinitions;TRACE_LEVEL_FILE=0;TRACE_LEVEL_SYSTEM_OUT=0;FILE_LOCK=NO;CACHE_SIZE=4096;MAX_LOG_SIZE=2;DB_CLOSE_DELAY=-1 Thanks for your help, Steve -- You received this message because you are subscribed to the Google Groups "H2 Database" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/h2-database. For more options, visit https://groups.google.com/groups/opt_out.
