Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Liquibase lock - reasons?

I get this when running a lot of liquibase-scripts against a Oracle-server. SomeComputer is me.

Waiting for changelog lock.... Waiting for changelog lock.... Waiting for changelog lock.... Waiting for changelog lock.... Waiting for changelog lock.... Waiting for changelog lock.... Waiting for changelog lock.... Liquibase Update Failed: Could not acquire change log lock.  Currently locked by SomeComputer (192.168.15.X) since 2013-03-20 13:39 SEVERE 2013-03-20 16:59:liquibase: Could not acquire change log lock.  Currently locked by SomeComputer (192.168.15.X) since 2013-03-20 13:39 liquibase.exception.LockException: Could not acquire change log lock.  Currently locked by SomeComputer (192.168.15.X) since 2013-03-20 13:39         at liquibase.lockservice.LockService.waitForLock(LockService.java:81)         at liquibase.Liquibase.tag(Liquibase.java:507)         at liquibase.integration.commandline.Main.doMigration(Main.java:643)         at liquibase.integration.commandline.Main.main(Main.java:116) 

Could it be that the number of simultaneous sessions/transactions are reached? Anyone has any ideas?

like image 885
Peter Avatar asked Mar 20 '13 16:03

Peter


2 Answers

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.

like image 94
Adrian Ber Avatar answered Sep 17 '22 20:09

Adrian Ber


Edit june 2020

Don't follow this advice. It's caused trouble to many people over the years. It worked for me a long time ago and I posted it in good faith, but it's clearly not the way to do it. The DATABASECHANGELOCK table needs to have stuff in it, so it's a bad idea to just delete everything from it without dropping the table.

Leos Literak, for instance, followed these instructions and the server failed to start.

Original answer

It's possibly due to a killed liquibase process not releasing its lock on the DATABASECHANGELOGLOCK table. Then,

DELETE FROM DATABASECHANGELOGLOCK; 

might help you.

Edit: @Adrian Ber's answer provides a better solution than this. Only do this if you have any problems doing his solution.

like image 32
e18r Avatar answered Sep 17 '22 20:09

e18r