Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a liquibase lock timeout?

You can see in the issue here: (liquibase-lock-reasons) at situation where the client Liquibase locks when a Liquibase operation has been interrupted, leaving liquibase in a locked state.

I'm wondering if there is a way to configure Liquibase to automatically detect this situation from the date and time in the LOCKGRANTED column. I think if you've held onto the lock for an hour - you should call that an expired lock.

My question is: Is there a liquibase lock timeout?

like image 722
hawkeye Avatar asked May 21 '15 23:05

hawkeye


People also ask

What is Liquibase lock?

Liquibase uses the DATABASECHANGELOGLOCK table to ensure only one instance of Liquibase runs at a time. When you make a database update, Liquibase reads from the DATABASECHANGELOG table to determine which changesets need to run.

What is Databasechangelog table?

Liquibase uses the DATABASECHANGELOG table to track which changesets have been run. If the table does not exist in the database, Liquibase creates one automatically.

What is Liquibase used for?

Liquibase allows you to specify the database change you want using SQL or several different database-agnostic formats, including XML, YAML, and JSON. Developers can abstract the database code to make it extremely easy to push out changes to different database types.

How long does Liquibase take to lock a database?

There is no lock timeout. Liquibase has no idea of how long to expect changeSets to take, and if some are doing DML on large tables they can take hours to run successfully.

What is the use of Liquibase in containers?

liquibase: Waiting for changelog lock.... Containers that use Liquibase, for managing and applying database schema changes, execute a task during startup that determines whether schema changes need to be applied or not.

How does Liquibase use the DatabaseChangeLogLock Table?

Liquibase uses the DATABASECHANGELOGLOCK table to ensure only one instance of Liquibase runs at a time. When you make a database update, Liquibase reads from the DATABASECHANGELOG table to determine which changeset s need to run.

What does lock wait timeout exceeded mean in InnoDB?

One of the most popular InnoDB’s errors is InnoDB lock wait timeout exceeded, for example: SQLSTATE [HY000]: General error: 1205 Lock wait timeout exceeded; try restarting transaction The above simply means the transaction has reached the innodb_lock_wait_timeout while waiting to obtain an exclusive lock which defaults to 50 seconds.


2 Answers

There is no lock timeout. Liquibase has no idea of how long to expect changeSets to take, and if some are doing DML on large tables they can take hours to run successfully.

There is a releaseLocks command you can use to clear the locks manually, or you could subclass liquibase.lockservice.StandardLockService to add additional logic to override the lock after after a set period of time.

If you have only one machine that would be updating the database, you can consider https://github.com/liquibase/liquibase-nochangeloglock as well, which completely disables the lock support.

I could see it as being a useful feature to have configurable, so I did add https://liquibase.jira.com/browse/CORE-2375 to track the feature.

like image 106
Nathan Voxland Avatar answered Oct 14 '22 22:10

Nathan Voxland


Actually,looking at the code of StandardLockService, it is configurable using the system property "liquibase.changeLogLockWaitTimeInMinutes"...

public class StandardLockService implements LockService {
    ...
    private long changeLogLockWaitTime = 300000L;
    ....
    public StandardLockService() {
        try {
            this.changeLogLockWaitTime = 60000L * Long.parseLong(System.getProperty("liquibase.changeLogLockWaitTimeInMinutes"));
            LogFactory.getLogger().info("lockWaitTime change to: " + this.changeLogLockWaitTime);
        } catch (NumberFormatException var2) {
            ;
        }
    }
like image 41
Alessio Santacroce Avatar answered Oct 14 '22 22:10

Alessio Santacroce