Lock file absent by default ?

90 views
Skip to first unread message

Francois Marot

unread,
Nov 8, 2023, 5:04:38 AM11/8/23
to H2 Database
Hello,
I've recently switched from an old v 1.3.167 to a recent 2.2.x and it seems like there is no lock file anymore by default (with nothing set specifically in my connection url, as before). Is it normal ?

I also find out to my greatest surprise that it seems like I can rename the .mv.db file at runtime ant it causes no problem at all. I can still save my data and they are correctly saved.

Is it normal ? Is there some king of black magic voodoo inside H2 ?! Or did I simply made errors in my tests ?

Best regards
François

Evgenij Ryazanov

unread,
Nov 20, 2023, 10:11:02 AM11/20/23
to H2 Database
Hello!

1. H2 uses file system locks by default for a very long time, so there is no additional file. In few special cases file systems (usually virtual or remote ones) don't support locks well. In these cases you can add ;FILE_LOCK=FILE to JDBC URL to use that old method instead of modern one.
2. Operating systems usually can rename files even when they are accessed, if application doesn't try to re-open these files under old names it shouldn't produce any problems. But this is a bad idea anyway, it still can break some commands, such as SHUTDOWN COMPACT and others.

Francois Marot

unread,
Nov 20, 2023, 10:17:04 AM11/20/23
to H2 Database
Thanks Evgenij, seems like I have to refresh my system knowledge and I have been using veeeeery old version of H2 for too long ;)
Have a good day !

François
Reply all
Reply to author
Forward
0 new messages