1

I'm currently running a DDL Script using the Liquibase Java API. The whole script and the corresponding changeSet is exceuted successfully. However, after this execution Liquibase throws a LockException.

The ERROR LOG is as follows,

    21713 [main] DEBUG liquibase.ext.mssql.database.MSSQLDatabase  - Executing Statement: ALTER 
    TABLE [dbo].[VALIDATIONEXECUTORS] CHECK CONSTRAINT [FK_MSTAPPTYPE_VLDTNEXCUTORS]
    21713 [main] INFO liquibase.executor.jvm.JdbcExecutor  - ALTER TABLE [dbo].[VALIDATIONEXECUTORS] 
    CHECK CONSTRAINT [FK_MSTAPPTYPE_VLDTNEXCUTORS]
    21715 [main] DEBUG liquibase.executor.jvm.JdbcExecutor  - 0 row(s) affected
    21715 [main] DEBUG liquibase.ext.mssql.database.MSSQLDatabase  - Executing Statement: COMMIT
    21715 [main] INFO liquibase.executor.jvm.JdbcExecutor  - COMMIT
    21735 [main] DEBUG liquibase.executor.jvm.JdbcExecutor  - -1 row(s) affected
    21735 [main] INFO liquibase.changelog.ChangeSet  - SQL in file 
    E:\\LQBASE\\LiquibaseDemo\\src\\main\\resources\\db\\changelog\\ddl\\DBSchema.sql executed
    21737 [main] INFO liquibase.changelog.ChangeSet  - ChangeSet 
    src/main/resources/db/changelog/ddl_changelog.xml::Create_DB::skini ran successfully in 18064ms
    21738 [main] INFO liquibase.executor.jvm.JdbcExecutor  - select schema_name()
    21739 [main] INFO liquibase.executor.jvm.JdbcExecutor  - SELECT MAX(ORDEREXECUTED) FROM 
    IND_DEV.DATABASECHANGELOG
    21742 [main] INFO liquibase.executor.jvm.JdbcExecutor  - select schema_name()
    21744 [main] DEBUG liquibase.executor.jvm.JdbcExecutor  - Release Database Lock
    21745 [main] INFO liquibase.executor.jvm.JdbcExecutor  - select schema_name()
    21747 [main] DEBUG liquibase.executor.jvm.JdbcExecutor  - UPDATE IND_DEV.DATABASECHANGELOGLOCK 
    SET LOCKED = 0, LOCKEDBY = NULL, LOCKGRANTED = NULL WHERE ID = 1
    21749 [main] INFO liquibase.executor.jvm.JdbcExecutor  - select schema_name()
    **21751 [main] INFO liquibase.lockservice.StandardLockService  - Successfully released change log 
    lock
    21752 [main] ERROR liquibase.Liquibase  - Could not release lock
    liquibase.exception.LockException: liquibase.exception.DatabaseException: Error executing SQL 
    UPDATE IND_DEV.DATABASECHANGELOGLOCK SET LOCKED = 0, LOCKEDBY = NULL, LOCKGRANTED = NULL WHERE 
    ID = 1: Invalid object name 'IND_DEV.DATABASECHANGELOGLOCK'.**
    at liquibase.lockservice.StandardLockService.releaseLock(StandardLockService.java:357)
    at liquibase.Liquibase.update(Liquibase.java:206)
    at liquibase.Liquibase.update(Liquibase.java:179)
    at liquibase.Liquibase.update(Liquibase.java:175)
    at liquibase.Liquibase.update(Liquibase.java:168)
    at 
    com.sk.liquibase.LiquibaseDemo.LiquibaseConfig.createManageIDDatabase(LiquibaseConfig.java:34)
    at com.sk.liquibase.LiquibaseDemo.App.main(App.java:12)
    **Caused by: liquibase.exception.DatabaseException: Error executing SQL UPDATE 
    IND_DEV.DATABASECHANGELOGLOCK SET LOCKED = 0, LOCKEDBY = NULL, LOCKGRANTED = NULL WHERE ID = 1: 
    Invalid object name 'IND_DEV.DATABASECHANGELOGLOCK'.**

According to the error, IND_DEV (which is the DB username) is somehow being appended to the DATABASECHANGELOGLOCK table. Does anyone have any idea what the issue could be?

Srinivas Kini
  • 11
  • 1
  • 2
  • The error is >>>Invalid object name 'IND_DEV.DATABASECHANGELOGLOCK'<< – sepupic Nov 27 '19 at 08:50
  • Its being generated automatically – Srinivas Kini Nov 27 '19 at 10:41
  • Ok, but the error says that there is no such an object, that is why it's not possible to SET LOCKED = 0, LOCKEDBY = NULL. No object no problem, this object is not locked as it nomore exists – sepupic Nov 27 '19 at 11:11
  • What is the contents of the last SQL file executed? E:\\LQBASE\\LiquibaseDemo\\src\\main\\resources\\db\\changelog\\ddl\\DBSchema.sql – SteveDonie Nov 27 '19 at 15:28
  • The last line is the a COMMIT statement, although the error still persists regardless of it. As you can see, the changeSet is executed successfully -- src/main/resources/db/changelog/ddl_changelog.xml::Create_DB::skini ran successfully in 18064ms -- The error occurs after the database has been created successfully. – Srinivas Kini Nov 28 '19 at 03:43
  • As you can see, there is a discrepancy in these two subsequent lines 21751 [main] INFO liquibase.lockservice.StandardLockService - Successfully released change log lock 21752 [main] ERROR liquibase.Liquibase - Could not release lock – Srinivas Kini Nov 28 '19 at 04:10
  • Can you please also add the part of the log where databasechangeloglock is set before executing the changesets? The table name should be mentioned there as well. – GreenTurtle Dec 04 '19 at 17:04

1 Answers1

3

Sometimes if the update application is abruptly stopped, then the lock remains stuck. Possibly due to a killed liquibase process not releasing its lock

Then running

UPDATE DATABASECHANGELOGLOCK SET LOCKED=0, LOCKGRANTED=null, LOCKEDBY=null;

against the database helps.

Or you can simply drop the DATABASECHANGELOGLOCK table, it will be recreated. or whatever changeloglock name you have configured.

Kunal Vohra
  • 2,703
  • 2
  • 15
  • 33