Lock problem on the base + Springboot

Asked

Viewed 34 times

0

Good morning,

I created a Spring Boot application and through the properties I enabled the file base to check if it is necessary to upgrade the database structure.

The problem is that the first step is to check if there is a lock in the database in order to make the changes. If it does not have it crashes the database to check if it is necessary to apply some update. It happened that a few times the application crashed before releasing the lock and I had to manually remove this lock.

When the application finds a lock, is there any way for it to ignore the quibase execution instead of not being able to climb? Or simply remove the lock after a few attempts?

Taking advantage of the question, using the base to automatically update the database is a good or bad practice to put into production?

1 answer

0


First of all, is not possible automatically remove the lock.

The liquibase lock is a mechanism created precisely to prevent two bank updates from being performed at the same time.

Forcing the removal of this flag during an execution could cause an inconsistency, since the base file itself does not know if there is any other execution updating the base at that time (re-ranking operations of tables take a long time depending on the size of the table), or, if an error occurred and the lock was left as a leftover execution. In this second case you proceeded correctly by removing the lock manually.

On your other question, using the term good practice or bad practice may be controversial, but there is no problem in using it in production, however if you have problems with the instance that runs the script, it may (and will) cause you several problems (the lock is one of them for example).

It is important to have a consistent environment before anything else, for sure follow with solving the termination problem of your instance during the execution process would be the first thing to do.

  • 1

    I understand why the lock exists, is that in this particular case I’m sure that this is the only application that moves this bench. Would it be possible then if he could not lock at least the application go up without running Liquibase? 'Cause today, if she tries to take the lock from the bank and she can’t get the app, she won’t go up.

  • Natively from liquibase there is no feature to remove the lock, however, you can create a tool that performs the check of the lock record and remove it manually before executing your step from the liquibase. It is always important to ensure that there are no two executions in parallel in any way.

  • Currently your application goes up and also runs the liquibase? An interesting approach would be to separate this responsibility into another project that just runs the base, so your application would always go up using the base, which in this case was managed by an earlier step, in another project

  • 1

    I was using the Spring Boot base due to the ease of implementation, but I am thinking of changing this because of this application problem do not go up if you have any problem with the base. I thought there might be a solution to this. Thank you. Question answered. I will check if I put the liquibase script running on the terraform of the application instead of going up with spring boot.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.