If an application crashes (OOM / power failure / kill -9) after liquibase acquired a lock, but before releasing the lock, the lock will remain in the databasechangeloglock
table forever and we'll need to manually remove it.
I wonder if it's possible to force the application with liquibase do this:
I want it to speed up application bootstrap (when there's no new migrations) and reduce chances to get stuck lock in the databasechangeloglock
.
Currently I just create a liquibase.integration.spring.SpringLiquibase
Spring bean. I assume I need to create some custom tricky @ConditionalOn... annotation
You can provide your own implementation of liquibase.lockservice.LockService
using the ServiceLoader mechanism. This allows you to implement a custom lock and unlock mechanism. For PostgreSQL, you can use the pg_try_advisory_lock
and pg_advisory_unlock
functions. When the connection is lost, the lock is automatically released, allowing another connection to acquire it. And attempt to do migration. Following library has support for following databases: