I have an H2 db named temp.h2.db
which is accessed by two applications. The first one accesses it through embedded mode and the second one through server mode. Through the second application I load data into the database. But even when I drop the previous values and load the same data repeatedly, the db size increases. From about 200mb, it increased to about 2Gb. This happens even when I drop all tables and load a fresh set of data (which is almost of the same size as the previous set of data). Is this a bug?
I tried LOG_SIZE_LIMIT=32
, but it didn't help.
Could this be due to open transactions? How can we determine which open transactions exist? I did a recover of the db twice and it gave me some statistics. How do I interpret these:
---- Statistics ----
-- page count: 954655, free: 776787
-- page data bytes: head 13860963, empty 26006602, rows 35134291 (66% full)
-- free 91%, 876991 page(s)
-- data leaf 3%, 36622 page(s)
-- data node 0%, 268 page(s)
-- btree leaf 3%, 36567 page(s)
-- btree node 0%, 570 page(s)
-- free list 0%, 52 page(s)
-- stream trunk 0%, 8 page(s)
-- stream data 0%, 3574 page(s)
and the next set is:
---- Statistics ----
-- page count: 235708, free: 164636
-- page data bytes: head 13268512, empty 24936708, rows 33759452 (66% full)
-- free 67%, 159364 page(s)
-- data leaf 14%, 35139 page(s)
-- data node 0%, 267 page(s)
-- btree leaf 14%, 35338 page(s)
-- btree node 0%, 568 page(s)
-- free list 0%, 15 page(s)
-- stream trunk 0%, 9 page(s)
-- stream data 2%, 5005 page(s)
Would doing MAX_COMPACT_TIME
help in any way? Requesting your help here. Thanks.
--
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 h2-database...@googlegroups.com.
To post to this group, send email to h2-da...@googlegroups.com.
Visit this group at http://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/groups/opt_out.
Hi,You have sent the same question to http://stackoverflow.com/questions/17488935/continuous-increase-in-h2-db-size-after-dropping-and-loading-same-data-repeatedlPlease don't use _both_ the Google Group and StackOverflow at the same time for the same question. Use one or the other.Did you run the recover tool _before_ you restored it? To find out what is using the disk space you would need to run it _before_ that (when the database file is large).Regards,Thomas
On Mon, Jul 8, 2013 at 8:53 AM, Noel Grandin <noelg...@gmail.com> wrote:
This is pretty much guaranteed to be because of open transactions.
Unfortunately there is no easy way of finding them, short of monitoring your own code to check that it is either using AutoCommit or calling commit()/rollback() timeously.
On 2013-07-08 07:31, chandra...@gmail.com wrote:I have an H2 db named
temp.h2.db
which is accessed by two applications. The first one accesses it through embedded mode and the second one through server mode. Through the second application I load data into the database. But even when I drop the previous values and load the same data repeatedly, the db size increases. From about 200mb, it increased to about 2Gb. This happens even when I drop all tables and load a fresh set of data (which is almost of the same size as the previous set of data). Is this a bug?
--
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 h2-database+unsubscribe@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to h2-database...@googlegroups.com.
---- Statistics ----
-- page count: 954655, free: 776787
-- page data bytes: head 13860963, empty 26006602, rows 35134291 (66% full)
-- free 91%, 876991 page(s)
-- data leaf 3%, 36622 page(s)
-- data node 0%, 268 page(s)
-- btree leaf 3%, 36567 page(s)
-- btree node 0%, 570 page(s)
-- free list 0%, 52 page(s)
-- stream trunk 0%, 8 page(s)
-- stream data 0%, 3574 page(s)
and the next set is:
---- Statistics ----
-- page count: 235708, free: 164636
-- page data bytes: head 13268512, empty 24936708, rows 33759452 (66% full)
-- free 67%, 159364 page(s)
-- data leaf 14%, 35139 page(s)
-- data node 0%, 267 page(s)
-- btree leaf 14%, 35338 page(s)
-- btree node 0%, 568 page(s)
-- free list 0%, 15 page(s)
-- stream trunk 0%, 9 page(s)
-- stream data 2%, 5005 page(s)
To unsubscribe from this group and stop receiving emails from it, send an email to h2-database...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to h2-database...@googlegroups.com.
To post to this group, send email to h2-da...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to h2-database...@googlegroups.com.
To post to this group, send email to h2-da...@googlegroups.com.
Hi,How large is the database exactly, and how does it grow exactly? Are you completely sure it doesn't stop growing? If yes, could you kill the process while the database is about 10 times as big as it should be, and then run the recovery tool, and post the statistics part of the the output? And then, could you shrink the file (for example by export to SQL script / import from SQL script), run recovery again, and post the statistics of this new file?Regards,Thomas
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/groups/opt_out.
--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/groups/opt_out.
http://h2-database.66688.n3.nabble.com/h2-Continuous-Increase-in-H2-db-size-after-dropping-and-loading-same-data-repeatedly-tp4026836p4027133.htmlIf you reply to this email, your message will be added to the discussion below:To unsubscribe from [h2] Continuous Increase in H2 db size after dropping and loading same data repeatedly, click here.
NAML
All the import were executed within the same JVM instance. These are the size measurements taken after every import (with the Tomcat JVM still running):
# Size(MB) 1 755 2 1267 3 1779 4 2547 5 3059So in this scenario the db size trend seems almost linear:
Then I shut down Tomcat, and the db size slightly decreased to 2888MB. Then I ran the recovery tool on the db. These are the relevant statistics:
---- Transaction log ---- ---- Statistics ---- -- page count: 1478666, free: 1274362 -- page data bytes: head 66033313, empty 510471785, rows 773802742 (63% full) -- free 0%, 2 page(s) -- data leaf 44%, 659330 page(s) -- data node 0%, 4466 page(s) -- data overflow 0%, 2652 page(s) -- btree leaf 24%, 366293 page(s) -- btree node 0%, 4723 page(s) -- free list 0%, 91 page(s) -- stream trunk 0%, 869 page(s) -- stream data 29%, 440237 page(s)Then I exported the DB to a sql script and used RunScript to reimport it into a new one, which size in turn decreased to 471MB. Then I relaunched recovery tool that produced the following stats:
---- Transaction log ---- ---- Statistics ---- -- page count: 241351, free: 80334 -- page data bytes: head 12427119, empty 95612024, rows 147534873 (63% full) -- free 0%, 1 page(s) -- data leaf 51%, 124792 page(s) -- data node 0%, 853 page(s) -- data overflow 0%, 311 page(s) -- btree leaf 14%, 34583 page(s) -- btree node 0%, 460 page(s) -- free list 0%, 15 page(s) -- stream trunk 0%, 159 page(s) -- stream data 33%, 80174 page(s)It seems that the rows number of the huge db is nearly 5 times the shrunk one. OTOH on a raw check (comparing the number of rows for the bigger tables) it seems that the shrunk db contains the same data.
Would it be compatible with a scenario of pending transactions/sessions?
Thomas Mueller-6 wroteHi, How large is the database exactly, and how does it grow exactly? Are you completely sure it doesn't stop growing? If yes, could you kill the process while the database is about 10 times as big as it should be, and then run the recovery tool, and post the statistics part of the the output? And then, could you shrink the file (for example by export to SQL script / import from SQL script), run recovery again, and post the statistics of this new file? Regards, Thomas On Tue, Aug 13, 2013 at 6:27 PM, davide.cavestro <[hidden email]>wrote: > I didn't measure it, but it was certainly lower. I'll give you more data > asap. > > > Noel Grandin wrote > > On Tue, Aug 13, 2013 at 5:56 PM, davide.cavestro > > < > > > davide.cavestro@ > > > > wrote: > >> I've tried replacing setCharacterStream() with setString() but the db > >> size > >> still continues to increase. Is there any way to get an idea of actual > >> fragmentation of internal data-structures? > >> > > > > Sorry, no, no idea. > > But I thought we were chasing a bug where shutdown was taking too > > long, in which case making this change should make a difference. > > Did you measure your new shutdown time with this change? > > > > -- > > 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 > > > h2-database+unsubscribe@ > > > . > > To post to this group, send email to > > > h2-database@ > > > . > > Visit this group at http://groups.google.com/group/h2-database. > > For more options, visit https://groups.google.com/groups/opt_out. > > > > > > -- > View this message in context: > http://h2-database.66688.n3.nabble.com/h2-Continuous-Increase-in-H2-db-size-after-dropping-and-loading-same-data-repeatedly-tp4026836p4027132.html > Sent from the H2 Database mailing list archive at Nabble.com. > > -- > 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 [hidden email]. > To post to this group, send email to [hidden email]. > Visit this group at http://groups.google.com/group/h2-database. > For more options, visit https://groups.google.com/groups/opt_out. > > > -- 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 [hidden email]. To post to this group, send email to [hidden email]. Visit this group at http://groups.google.com/group/h2-database. For more options, visit https://groups.google.com/groups/opt_out.
To unsubscribe from this group and stop receiving emails from it, send an email to h2-database...@googlegroups.com.
To post to this group, send email to h2-da...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to h2-database...@googlegroups.com.
To post to this group, send email to h2-da...@googlegroups.com.
---- Statistics ---- -- page count: 8763710, free: 4148621 -- page data bytes: head 263443992, empty 1859617598, rows -1552023894 (-225% full) -- free 23%, 2078475 page(s) -- data leaf 27%, 2375979 page(s) -- data node 0%, 17345 page(s) -- data overflow 0%, 56 page(s) -- btree leaf 20%, 1801340 page(s) -- btree node 0%, 22636 page(s) -- free list 0%, 533 page(s) -- stream trunk 0%, 4857 page(s) -- stream data 28%, 2462486 page(s)
Hi,It seems like there is a long running transaction, because "-- stream data 29%, 440237 page(s)" means there is 860 MB of transaction log. Each page is 2048 bytes by default (unless you changed the page size).Could you verify you don't keep a connection (with autocommit disabled, and with uncommitted changes) open for a long time? When this is fixed, let's see how this changed the numbers. Maybe there is still a problem, but maybe not. Maybe this unclosed / uncommitted connection has a temporary table that is removed when the connection is closed, committed, or rolled back.
Regards,Thomas
Sent from the H2 Database mailing list archive at Nabble.com.
--
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 <a href="javascript:_e({}, 'cvml', &#[hidden email]');" target="_blank">h2-database+unsubscribe@....
To post to this group, send email to <a href="javascript:_e({}, 'cvml', &#[hidden email]');" target="_blank">h2-database@....
Visit this group at http://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/groups/opt_out.
--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/groups/opt_out.
If you reply to this email, your message will be added to the discussion below:
To unsubscribe from [h2] Continuous Increase in H2 db size after dropping and loading same data repeatedly, click here.
NAML
About the negative numbers: why don't you post which numbers where negative? I guess it's a bug in the Recover tool (using int instead of long).
--
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 h2-database...@googlegroups.com.
To post to this group, send email to h2-da...@googlegroups.com.
I suspect if you read mailing list messages from a mobile device you miss
preformatted contents... I posted the head and tail of the .sql file in my
previous post
Hi,
I suspect if you read mailing list messages from a mobile device you miss
preformatted contents... I posted the head and tail of the .sql file in my
previous post
Well, I think you didn't post the content of the transaction log (not before, and not now).
Before giving up definitively, could you please tell me if getting thepageStore: Transaction log could not be truncated; size: 16 MBwarning in the trace file indicates an error?
--
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 h2-database...@googlegroups.com.
To post to this group, send email to h2-da...@googlegroups.com.
--
You received this message because you are subscribed to a topic in the Google Groups "H2 Database" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/h2-database/i2fVBYBF3as/unsubscribe.
To unsubscribe from this group and all its topics, send an email to h2-database...@googlegroups.com.