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

**URL:** <https://forum.liquibase.org/t/is-switching-sql-server-databases-during-a-liquibase-changeset-and-the-subsequent-unreleased-lock-a-bug/3843>\
**Category:** Liquibase Development\
**Created:** [June 20, 2014, 5:19pm UTC](https://forum.liquibase.org/t/is-switching-sql-server-databases-during-a-liquibase-changeset-and-the-subsequent-unreleased-lock-a-bug/3843 "2014-06-20T17:19:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![PaulPoulain](https://avatars.discourse-cdn.com/v4/letter/p/4af34b/32.png) [@PaulPoulain](https://forum.liquibase.org/u/PaulPoulain)\
**Post date:** [June 20, 2014, 5:19pm UTC](https://forum.liquibase.org/t/is-switching-sql-server-databases-during-a-liquibase-changeset-and-the-subsequent-unreleased-lock-a-bug/3843/1 "2014-06-20T17:19:00Z")

</div>

Hi,

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)
-

---

<div class="post-metadata">

**Author:** ![un1382561729492r88id](https://avatars.discourse-cdn.com/v4/letter/u/c4cdca/32.png) [@un1382561729492r88id](https://forum.liquibase.org/u/un1382561729492r88id)\
**Post date:** [June 20, 2014, 5:19pm UTC](https://forum.liquibase.org/t/is-switching-sql-server-databases-during-a-liquibase-changeset-and-the-subsequent-unreleased-lock-a-bug/3843/2 "2014-06-20T17:19:00Z")

</div>

It seems to me that you should just change the sql so that there is a “use database\_a” in the sql.&nbsp;

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. [http://www.datical.com/](http://www.datical.com/)

---

<div class="post-metadata">

**Author:** ![un1403258901131r86id](https://avatars.discourse-cdn.com/v4/letter/u/ecae2f/32.png) [@un1403258901131r86id](https://forum.liquibase.org/u/un1403258901131r86id)\
**Post date:** [June 20, 2014, 5:19pm UTC](https://forum.liquibase.org/t/is-switching-sql-server-databases-during-a-liquibase-changeset-and-the-subsequent-unreleased-lock-a-bug/3843/3 "2014-06-20T17:19:00Z")

</div>

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.&nbsp;\<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!
