Is switching SQL Server databases during a liquibase changeset and the subsequent unreleased lock a bug?


I was using the 3.1.1 Maven Liquibase Plugin (I’ve since upgraded to 3.2.0 and still have the same problem) with SQL Server, and ran into an issue where the liquibase lock was not released due to a change of databases in the middle of a changeset.

The scenario was this:

  • Liquibase runs and successfully acquires the lock (say in database_a)
  • <span when that clearly isn't true.

    If someone can confirm whether they agree this is a bug or not, and I’ll raise a Jira :slight_smile:

    Many thanks,


It seems to me that you should just change the sql so that there is a “use database_a” in the sql. 

As to whether Liquibase should keep track of the locks that it acquires and then verify that the lock released is the same as the one acquired, it is my opinion that such a feature does have value. As you said, it would alert you to a problem earlier. I wouldn’t exactly call it a bug that Liquibase doesn’t already do this, though.

Steve Donie
Principal Software Engineer
Datical, Inc.

Thanks Steve,

The actual fix for me was that I had to remove the “use” statement altogether. It was a schoolboy cut and paste error that it was in there in the first place. <img src="/ze/images/frown.gif" when blatantly no lock had been set on database_b, and the original lock is left in place on database_a surely isn’t right?. However, I didn’t just raise a Jira straight away, as I wanted to canvas opinions such as these first, thanks!