Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

org.h2.jdbc.JdbcSQLException: Database may be already in use: "Lock file exists: **/db.lock.db" #2203

Open
KrutikMaheta opened this issue Oct 24, 2019 · 3 comments

Comments

@KrutikMaheta
Copy link

Hi There,

We are getting following exception "org.h2.jdbc.JdbcSQLException: Database may be already in use" because of the existence of db.lock.db file.

Observation:

As per our observation, this happens during our service failover; when abrupt killing of JVM happens. While this happens, it is not able to clear H2 DB lock file db.lock.db. This file is created by H2 DB itself internally (org.h2.engine.Database.open(int,int) method is where it opens) as a file lock.

Interestingly H2 DB already provides a JVM shutdown hook registered (see org.h2.engine.Database.openDatabase(int,int,boolean) for details) to clear these artifacts, but unfortunately even this shutdown hook is not able to take care of this lock.

Please let us know your valuable inputs on this ASAP.

Environment Details:
H2 Version: 1.3.169

Thanks,
Krutik

@grandinj
Copy link
Contributor

I am sorry, but that version is outdated and unsupported. About the only thing you can do is to delete the file yourself in your failover script/code.

@KrutikMaheta
Copy link
Author

Thanks for your quick response.
May I know with which version this issue is being fixed?

Thanks,
Krutik

@grandinj
Copy link
Contributor

How well file locking works depends on the nature of your deployment and the kind of file system at work.

You could try updating to one of the 1.4 series, which has a newer and slightly smarter file locking protocol.

Otherwise see the documentation here:
http://h2database.com/html/features.html#database_file_locking
http://h2database.com/html/advanced.html#file_locking_protocols

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants