0

In our application there are four SQL Server databases:

db1
db2
db3
db4

While connecting to SQL Server using liquibase we use db2 in connection string and then perform deployment.

As db2 is used in connection string DATABASECHANGELOGLOCK and DATABASECHANGELOG are created in db2 database.

As a part of deployment, every SQL script has database name at the start like

Script1.sql

USE db1
GO

—update/delete statements

GO

Script2.sql

USE db2
GO

—update/delete statements

GO

Script3.sql

USE db3
GO

—update/delete statements

GO

Script4.sql

USE db4
GO

—update/delete statements

GO

If the last script in the deployment is db2 (as it is specified in the connection string and the DATABASECHANGELOGLOCK and DATABASECHANGELOG) are created in db2 database. Then the deployment succeeds

But if the last script is of some other database (other than db2) I get an error:

liquibase.exception.LockException: liquibase.exception.LockException: Did not update change log lock correctly.

Seems it goes to search the DATABASECHANGELOGLOCK and DATABASECHANGELOG in the database in which last script is deployed.

How I can handle this?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Dinesh
  • 15
  • 4

1 Answers1

0

Found in: Liquibase lock - reasons?

Sometimes if the update application is abruptly stopped, then the lock remains stuck.

Then running

UPDATE DATABASECHANGELOGLOCK SET LOCKED=0, LOCKGRANTED=null, LOCKEDBY=null where ID=1;

against the database helps.

You may also need to replace LOCKED=0 with LOCKED=FALSE.

Or you can simply drop the DATABASECHANGELOGLOCK table, it will be recreated.

tabbyfoo
  • 355
  • 1
  • 8