Releasing H2 lock that prevents startup

We have a small keycloak instance in development that would not start after a VM failure. We ended up restoring the filesystem on which it lives, which resolved the issue. After that fact, I drilled in to determine how to resolve this without a restore and wanted to provide my findings. These are shown below.

The exception on startup…

Caused by: liquibase.exception.LockException: Could not acquire change log lock.  Currently locked by cmhlqauthapi01.expdev.local ( since 10/31/17 11:19 AM

…and a query using the H2 shell against the problematic install…

-bash-4.1$ java -cp /media/nfs/keycloak/keycloak-1.9.1.Final/modules/system/layers/base/com/h2database/h2/main/h2-1.3.173.jar -url "jdbc:h2:file:/media/nfs/keycloak/keycloak-1.9.1.Final/standalone/data/keycloak" -driver "org.h2.Driver" -user "sa" -password "sa"

Welcome to H2 Shell 1.3.173 (2013-07-28)
Exit with Ctrl+C
Commands are case insensitive; SQL statements end with ';'
help or ?      Display this help
list           Toggle result list / stack trace mode
maxwidth       Set maximum column width (default is 100)
autocommit     Enable or disable autocommit
history        Show the last 20 statements
quit or exit   Close the connection and exit

sql> select * from public.DATABASECHANGELOGLOCK;
1  | TRUE   | 2017-10-31 11:19:36.775 | cmhlqauthapi01.expdev.local (
(1 row, 3 ms)

We could have simply deleted this row, and the problem would have been resolved.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.