Database continues to grow and does not reclaim deleted space

58 views
Skip to first unread message

Michael Earl

unread,
Jul 14, 2025, 7:54:38 PMJul 14
to H2 Database
Hello Everyone,

We are using the current H2 version.

We have a purge process that deletes old data every 5 minutes. However, the database size on disk continues to grow until all space is used up. We are running on an embedded Linux system with only about 80GB free. But, we store lots and lots of data.

We are using the following connection parameters: DB_CLOSE_DELAY=-1;MV_STORE=true;RETENTION_TIME=0;AUTO_SERVER=TRUE;DEFRAG_ALWAYS=TRUE

We are currently shutting down our application once a week only to give h2 a chance to reclaim the deleted data space.

We are running h2 inside of Spring and thus the database connection handling is handled by the framework. We have tried performing an occasional SHUTDOWN COMPACT but that jacked up the Spring connection pool.

Our next step is to ditch h2 and go to Postgres.  H2 is sufficient for what we are using it for excluding the database growth issue. We would like to solve this problem with H2.

Any help would be greatly appreciated.
Thanks,
Mike.

Noel Grandin

unread,
Jul 15, 2025, 5:44:58 AMJul 15
to h2-da...@googlegroups.com

Normally that means something is opening a transaction and not closing the transaction.

Or you have some very very long running transaction, perhaps some kind of report.


Michael Earl

unread,
Jul 15, 2025, 11:05:48 AMJul 15
to H2 Database
No, the transactions are very short.

Are you saying that the space reclaiming should be working as I have it configured?

Andreas Reichel

unread,
Jul 15, 2025, 11:07:41 AMJul 15
to h2-da...@googlegroups.com
Michael,

also please double check that you are really on the latest greatest version of H2 since there was a massive fix in the regard before 232.

Best regards
Andreas
--
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 view this discussion visit https://groups.google.com/d/msgid/h2-database/9adf311b-4c63-429b-be7f-37e73f4b9246n%40googlegroups.com.

Michael Earl

unread,
Jul 15, 2025, 11:18:23 AMJul 15
to h2-da...@googlegroups.com
Hello Andreas,

We are on the latest version: 

2.3.232

Is there something else that I need to do? 
Does H2 actually replace deleted row space while the database is open?

Thank you,
Mike.

Andreas Reichel

unread,
Jul 15, 2025, 11:21:26 AMJul 15
to h2-da...@googlegroups.com
On Tue, 2025-07-15 at 08:18 -0700, Michael Earl wrote:

We are on the latest version: 

2.3.232

All good then, just double checking. Although you could still "compile from source" latest github repository.

Best regards
Andreas

Michael Earl

unread,
Jul 15, 2025, 11:26:26 AMJul 15
to h2-da...@googlegroups.com
Adreas,
All good, but the database continues to grow while it's open. The database is not reclaiming deleted row space or it is not release the disk space when doing so. 
What do I need to do to get this fixed?

Your responses are much appreciated!!!!!!!!!!!!!

Mike.

--
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.

Andreas Reichel

unread,
Jul 15, 2025, 11:29:41 AMJul 15
to h2-da...@googlegroups.com
On Tue, 2025-07-15 at 08:26 -0700, Michael Earl wrote:
Adreas,
All good, but the database continues to grow while it's open. The database is not reclaiming deleted row space or it is not release the disk space when doing so. 
What do I need to do to get this fixed?

Your responses are much appreciated!!!!!!!!!!!!!

Michael,

we are pretty much power users of H2, with running 20+ large instances in production (reporting applications).

I know about this "continuous grow issue" but experienced it only before 232. I also remember, that some serious issues got fixed in the source only after 232. 
We are running Latest Snapshot compiled from source for this reason and I do not observe that issue anymore.

Unfortunately this is all the help I can render.
Good luck and best

Andreas

Michael Earl

unread,
Jul 15, 2025, 11:35:34 AMJul 15
to h2-da...@googlegroups.com
Thanks Andreas,
We have also used h2 in production for about 15 years now. But, we have recently started using h2 with Spring and not managed directly by our application. Could it be that when running in Spring with a Connection pool that H2 doesn't reclaim it's deleted row space?

Answer me this if you can, what are the conditions/states when h2 reclamins the delete row space?

Thanks,
MIke.

--
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.

Andreas Reichel

unread,
Jul 15, 2025, 11:38:50 AMJul 15
to h2-da...@googlegroups.com
On Tue, 2025-07-15 at 08:35 -0700, Michael Earl wrote:
We have also used h2 in production for about 15 years now. But, we have recently started using h2 with Spring and not managed directly by our application. Could it be that when running in Spring with a Connection pool that H2 doesn't reclaim it's deleted row space?

On our side, we speak to H2 directly. No layers inbetween.


Answer me this if you can, what are the conditions/states when h2 reclamins the delete row space?

I can not answer that.

Best regards
Andreas

Reply all
Reply to author
Forward
0 new messages