2

My service based on Spring 2.4.3 and use liquibase 4.3.1, deploy with Jenkins. I have next problem- liquibase lock(Kibana logs):

Application run failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'liquibase' defined in class path resource [org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfiguration$LiquibaseConfiguration.class]: Invocation of init method failed; nested exception is liquibase.exception.LockException: Could not acquire change log lock. Currently locked by my-service since 10/29/21, 3:37 PM

Unfortunatelly I have no access to DB directly to update DATABASECHANGELOCK. I tried this solution but without any result.. How to unlock liquibase without DB data loss? Thanks in advance.

Khilarian
  • 249
  • 1
  • 9
  • this is was one of the reasons we never went with liquibase (and never will), its lack of a `--force` – Eugene Oct 31 '21 at 19:00

3 Answers3

0

One of the ways to solve this problem permanently is to switch to session locking. This means that the Liquibase lock will be released automatically when the database connection used by Liquibase is closed.

If you are using one of the following DBs: MySQL, MariaDB, PostgreSQL, Oracle then you are lucky. Just use library Liquibase Session Locking and add it to your dependencies. This will replace LockServiceStandard with session locking and the problem will be gone permanently.

You can read more details in my blog post: Fix 'Liquibase Update Failed: Could not acquire change log lock' permanently and forget about it

Viktar Patotski
  • 584
  • 6
  • 20
0

If your CI system can configure the app to run the db migration, you should be able to run the release-locks command.

docker run --rm -t liquibase/liquibase release-locks \
  --url="jdbc:dbserver:1433;database=mydatabase" \
  --username=user \
  --password=password

You can also use environment variables:

  • LIQUIBASE_COMMAND_URL = SPRING_DATASOURCE_URL
  • LIQUIBASE_COMMAND_USERNAME = SPRING_DATASOURCE_USERNAME
  • LIQUIBASE_COMMAND_PASSWORD = SPRING_DATASOURCE_PASSWORD
Nicholas Albion
  • 3,096
  • 7
  • 33
  • 56
-1

If someone interesting- I solve this case.

I add entity & dto - liquibaseLock and controller, service, repo. After that comment liquibase implementation in build.gradle, push and deploy this version, unlock DB; comment out liquibase and push & deploy )

Now it works and I have proven solution )

Khilarian
  • 249
  • 1
  • 9