Closed connection due to unexepected error

We have been using Liquibase for years and just now are confronted with an error. We use Liquibase version 4.24.0 on Windows connecting to Postgresql.

When running the liquibase deployment, it started recently erroring out when recreating a certain stored procedure. This SP has not been changed since the last successful working deployment. It deploys successfully in a virtual machine but when we deploy at our client’s lab environment it errors out.

The error is “Unexpected Error running Liquibase: This Connection has been Closed”

When adding fine logging, we see this in the log:

[2024-06-26 11:22:02] INFO [liquibase.command] Update command encountered an exception.
[2024-06-26 11:22:02] WARNING [liquibase.lockservice] Failed to release change log lock
[2024-06-26 11:22:02] WARNING [liquibase.command] Update command encountered exception
java.lang.NullPointerException
at liquibase.executor.jvm.JdbcExecutor.showSqlWarnings(JdbcExecutor.java:105)
at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:86)
at liquibase.executor.jvm.JdbcExecutor.query(JdbcExecutor.java:222)
at liquibase.executor.jvm.JdbcExecutor.query(JdbcExecutor.java:230)
at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:238)
at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:253)
at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:248)
at liquibase.database.core.DatabaseUtils.initializeDatabase(DatabaseUtils.java:41)
at liquibase.database.core.PostgresDatabase.rollback(PostgresDatabase.java:404)
at liquibase.lockservice.StandardLockService.releaseLock(StandardLockService.java:415)
at liquibase.command.core.AbstractUpdateCommandStep.doRun(AbstractUpdateCommandStep.java:125)
at liquibase.command.core.AbstractUpdateCommandStep.lambda$run$0(AbstractUpdateCommandStep.java:63)
at liquibase.Scope.lambda$child$0(Scope.java:184)
at liquibase.Scope.child(Scope.java:193)
at liquibase.Scope.child(Scope.java:183)
at liquibase.Scope.child(Scope.java:162)
at liquibase.command.core.AbstractUpdateCommandStep.run(AbstractUpdateCommandStep.java:62)
at liquibase.command.core.UpdateCommandStep.run(UpdateCommandStep.java:106)
at com.datical.liquibase.ext.command.ProUpdateCommandStep.run(Unknown Source)
at liquibase.command.CommandScope.execute(CommandScope.java:214)
at liquibase.integration.commandline.CommandRunner.call(CommandRunner.java:55)
at liquibase.integration.commandline.CommandRunner.call(CommandRunner.java:24)
at picocli.CommandLine.executeUserObject(CommandLine.java:2041)
at picocli.CommandLine.access$1500(CommandLine.java:148)
at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2461)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2453)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2415)
at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2273)
at picocli.CommandLine$RunLast.execute(CommandLine.java:2417)
at picocli.CommandLine.execute(CommandLine.java:2170)
at liquibase.integration.commandline.LiquibaseCommandLine.lambda$execute$2(LiquibaseCommandLine.java:383)
at liquibase.Scope.child(Scope.java:193)
at liquibase.Scope.child(Scope.java:169)
at liquibase.integration.commandline.LiquibaseCommandLine.lambda$execute$3(LiquibaseCommandLine.java:358)
at liquibase.Scope.child(Scope.java:193)
at liquibase.Scope.child(Scope.java:169)
at liquibase.integration.commandline.LiquibaseCommandLine.execute(LiquibaseCommandLine.java:356)
at liquibase.integration.commandline.LiquibaseCommandLine.main(LiquibaseCommandLine.java:96)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at liquibase.integration.commandline.LiquibaseLauncher.main(LiquibaseLauncher.java:133)

If we remove the Stored Procedure that causes it to stop, it runs fine for the next few SPs and then errors out again on a new SP (Always the same SPs).

Is there a way to figure out what’s going on? We are trying not to have to upgrade if possible so we can keep our test and prod environments the same.

Just an update, it appears that one of the Stored Procedures is causing the change log lock to not be released. Is there a way to figure out why this SP is causing the change log lock to stay locked? I can run the SP script separately and there are no issues.

Not sure if this helps …

You can try changing the wait time for Liquibase change log see here:

You might be able to get more information from Postgres. Have a look at the log_lock_waits and deadlock_timeout settings and be prepared to dig though loads of logs.