# DATABASECHANGELOGLOCK is created twice on case-sensitive MS SQL database

**URL:** <https://forum.liquibase.org/t/databasechangeloglock-is-created-twice-on-case-sensitive-ms-sql-database/872>\
**Category:** General Discussion\
**Created:** [October 20, 2010, 12:02am UTC](https://forum.liquibase.org/t/databasechangeloglock-is-created-twice-on-case-sensitive-ms-sql-database/872 "2010-10-20T00:02:00Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![tschmidt\_lb](https://avatars.discourse-cdn.com/v4/letter/t/ee7513/32.png) [@tschmidt\_lb](https://forum.liquibase.org/u/tschmidt_lb)\
**Post date:** [October 20, 2010, 12:02am UTC](https://forum.liquibase.org/t/databasechangeloglock-is-created-twice-on-case-sensitive-ms-sql-database/872/1 "2010-10-20T00:02:00Z")

</div>

Hi,  
When I run Liquibase 2.0 RC7 (revision 1786) against a database that has not been managed by Liquibase yet, it errors out early in the process (log snippet below). Subsequent runs error out in different ways, depending on whether the tables exist and what command is used, so I’ll just focus on the simplest case.

My setup:

- I’ve built a recent snapshot of 2.0 RC7 (revision 1786) using Maven 3.0 (command at end of post).
- The database and server are case-sensitive (SQL Server 2008 SP1, database and server collation set to Latin1\_General\_BIN)
- The database in this test does not have a DATABASECHANGELOG or DATABASECHANGELOGLOCK table.
- When I run Liquibase with the “status” command against my testing XML files, it errors out with:

liquibase:INFO: Successfully acquired change log lock  
liquibase:INFO: Creating database history table with name: [dbo].[DATABASECHANGELOG]  
liquibase:INFO: There is already an object named ‘DATABASECHANGELOGLOCK’ in the database.

- Looking at a SQL trace, I see that the “DATABASECHANGELOGLOCK” table is created early on, but then a prepared SQL statement is run, using the sp\_tables procedure to check for the existence of “databasechangeloglock”. A subsequent attempt to create “DATABASECHANGELOGLOCK” again fails with the error.
- Based on some ad-hoc testing, I believe the same situation will occur for the DATABASECHANGELOG table.
- If I run modifications like the following, these errors go away and the app works as expected. I’m guessing the app consistently reads/writes with the capitalized table names but just checks for existence with the lower-case names.

select \*  
into databasechangeloglock  
from DATABASECHANGELOGLOCK  
where 1 = 0  
go

select \*  
into databasechangelog  
from DATABASECHANGELOG  
where 1 = 0  
go

delete DATABASECHANGELOGLOCK where 1 = 1  
go

INSERT INTO [dbo].[DATABASECHANGELOGLOCK] ([ID], [LOCKED]) VALUES (1, 0)  
go

Thanks for your attention, I am looking forward to 2.0 🙂  
Trevor

p.s. I built 2.0 RC7 using the command:&nbsp; mvn install -Dmaven.test.skip.exec=true  
…which I found on one forum posting. Hope that was the correct way to do it and isn’t causing this problem. I did receive some Maven warnings, although the process completed and Liquibase JAR runs.

---

<div class="post-metadata">

**Author:** ![brainertrev](https://avatars.discourse-cdn.com/v4/letter/b/838e76/32.png) [@brainertrev](https://forum.liquibase.org/u/brainertrev)\
**Post date:** [October 20, 2010, 12:02am UTC](https://forum.liquibase.org/t/databasechangeloglock-is-created-twice-on-case-sensitive-ms-sql-database/872/2 "2010-10-20T00:02:00Z")

</div>

Since it sounds like RC7 is coming soon, I’m bumping this issue to hear if it’s still around. Thoughts?

(I have the workaround mentioned but it looks better to colleagues/clients if I didn’t need it to get RC7 to launch)

Thanks again!

---

<div class="post-metadata">

**Author:** ![nvoxland](https://avatars.discourse-cdn.com/v4/letter/n/87869e/32.png) [@nvoxland](https://forum.liquibase.org/u/nvoxland)\
**Post date:** [October 20, 2010, 12:02am UTC](https://forum.liquibase.org/t/databasechangeloglock-is-created-twice-on-case-sensitive-ms-sql-database/872/3 "2010-10-20T00:02:00Z")

</div>

I think it should be resolved in RC7.&nbsp; I’ve gotten some patches around case sensitivity and consistency, but I haven’t gotten a chance to install a case sensitive sqlserver instance and test it personally yet.

Nathan

---

<div class="post-metadata">

**Author:** ![brainertrev](https://avatars.discourse-cdn.com/v4/letter/b/838e76/32.png) [@brainertrev](https://forum.liquibase.org/u/brainertrev)\
**Post date:** [October 20, 2010, 12:02am UTC](https://forum.liquibase.org/t/databasechangeloglock-is-created-twice-on-case-sensitive-ms-sql-database/872/4 "2010-10-20T00:02:00Z")

</div>

Hi Nathan,

Unfortunately the error is still occurring on RC7, but the symptoms have changed.

If the LB tables do not exist, then exactly one run of either the “status” or “update” command will work (finishes successfully as long as I do my change sets correctly, and both tables are created. “update” command will log to the DATABASECHANGELOG table correctly)

But a subsequent run of either the “status” or “update” command will fail with the same error:

Liquibase Update Failed: Error executing SQL CREATE TABLE [dbo].[DATABASECHANGELOGLOCK] ([ID] INT NOT NULL, [LOCKED] BIT NOT NULL, [LOCKGRANTED] DATETIME, [LOCK…

Unless I create lower-case named LB tables.

The “updatesql” command appears to always work.

---

<div class="post-metadata">

**Author:** ![nvoxland](https://avatars.discourse-cdn.com/v4/letter/n/87869e/32.png) [@nvoxland](https://forum.liquibase.org/u/nvoxland)\
**Post date:** [October 20, 2010, 12:02am UTC](https://forum.liquibase.org/t/databasechangeloglock-is-created-twice-on-case-sensitive-ms-sql-database/872/5 "2010-10-20T00:02:00Z")

</div>

This is fixed for the upcoming 2.0.1 release.

Nathan

---

<div class="post-metadata">

**Author:** ![Guest](https://avatars.discourse-cdn.com/v4/letter/g/8dc957/32.png) [@Guest](https://forum.liquibase.org/u/Guest)\
**Post date:** [October 20, 2010, 12:02am UTC](https://forum.liquibase.org/t/databasechangeloglock-is-created-twice-on-case-sensitive-ms-sql-database/872/6 "2010-10-20T00:02:00Z")

</div>

Hi,  
  
I’m facing a similar issue on Sybase ASE12.5 using Liquibase version 2.0.1. The first time I run Liquibase on my DB, it works fine and creates the DATABASECHANGELOG and DATABASECHANGELOGLOCK tables properly. The second time I run it, Liquibase attempts to re-create the lock table, thus failing with the below error:  
  
liquibase.exception.LockException: liquibase.exception.DatabaseException: Error executing SQL CREATE TABLE [DATABASECHANGELOGLOCK] ([ID] INT NOT NULL, [LOCKED] BIT NOT NULL, [LOCKGRANTED] D  
ATETIME NULL, [LOCKEDBY] VARCHAR(255) NULL, CONSTRAINT [PK\_DATABASECHANGELOGLOCK] PRIMARY KEY ([ID])); on [] INSERT INTO [DATABASECHANGELOGLOCK] ([ID], [LOCKED]) VALUES (1, 0): There is already an object named ‘DATABASECHANGELOGLOCK’ in the database.  
  
Thanks,  
Sarah

---

<div class="post-metadata">

**Author:** ![taranenko](https://avatars.discourse-cdn.com/v4/letter/t/ee7513/32.png) [@taranenko](https://forum.liquibase.org/u/taranenko)\
**Post date:** [October 20, 2010, 12:02am UTC](https://forum.liquibase.org/t/databasechangeloglock-is-created-twice-on-case-sensitive-ms-sql-database/872/7 "2010-10-20T00:02:00Z")

</div>

Sarah,

it is not&nbsp;definitely case-sensitives issue, it could also be the schema mess. Could you log in to your database using Sybase Central and check whether in the schema exists a table with some other user name?&nbsp;&nbsp;Usually the main schema in Sybase is **dba**. But it could variate if you use some kind of connection / user / role setting applied to server/database&nbsp;instance. Please try to investigate more in the your current environment.

Oleg

---

<div class="post-metadata">

**Author:** ![Guest](https://avatars.discourse-cdn.com/v4/letter/g/8dc957/32.png) [@Guest](https://forum.liquibase.org/u/Guest)\
**Post date:** [October 20, 2010, 12:02am UTC](https://forum.liquibase.org/t/databasechangeloglock-is-created-twice-on-case-sensitive-ms-sql-database/872/8 "2010-10-20T00:02:00Z")

</div>

Hello,  
  
You were right Oleg. It was indeed schema related.  
  
After some investigation, I found a workaround which consists of passing the defaultSchemaName property. Pass here the name of the user role associated with your schema (a list of these is found in the table sysusers).  
  
Thanks,  
Sarah

---

<div class="post-metadata">

**Author:** ![Guest](https://avatars.discourse-cdn.com/v4/letter/g/8dc957/32.png) [@Guest](https://forum.liquibase.org/u/Guest)\
**Post date:** [October 20, 2010, 12:02am UTC](https://forum.liquibase.org/t/databasechangeloglock-is-created-twice-on-case-sensitive-ms-sql-database/872/9 "2010-10-20T00:02:00Z")

</div>

I had the same problem running Liquibase 2.0.1 and it was resolved by adding the defaultSchemaName property.  
Thanks!

---

<div class="post-metadata">

**Author:** ![un1486026392087r20id](https://avatars.discourse-cdn.com/v4/letter/u/3e96dc/32.png) [@un1486026392087r20id](https://forum.liquibase.org/u/un1486026392087r20id)\
**Post date:** [October 20, 2010, 12:02am UTC](https://forum.liquibase.org/t/databasechangeloglock-is-created-twice-on-case-sensitive-ms-sql-database/872/10 "2010-10-20T00:02:00Z")

</div>

Hi,

I am having exact problem.

Can you please tell, which defaultSchemaName you have used? I have tried dbo, db\_owner and database name.

As per Sarah, sysusers has quite a list but not sure which one is associated with my database and login. How can I find that?

Thank you for your help in advance.
