list-locks returns the hostname, IP address, and the timestamp the Liquibase lock record was added to the DATABASECHANGELOGLOCK table.
list-locks is typically used when an error occurs during a database deployment. The error might indicate that there is a lock record in the DATABASECHANGELOGLOCK table by another user that is preventing Liquibase from applying changes to the specified database.
list-locks will read the DATABASECHANGELOGLOCK table and return a list that includes the hostname, IP address, and the timestamp the lock record was granted to the DATABASECHANGELOGLOCK table and determines the connections to the DATABASECHANGELOGLOCK table based on the database URL.
To run the
list-locks command, specify the driver, classpath, and URL in the Liquibase properties file. For more information, see Create and Configure a liquibase.properties File. You can also specify these properties in your command line.
Then run the
liquibase --changelog-file=mainchangelog.xml list-locks
Note: Enter the name of the changelog you want to use in place of
main-changelog.xml. You can also add the
changelog-file to the properties file.
list-locks global attributes
Tip: For best results, specify all commands and parameters in the
--kebab-case format in the CLI. If your preference is camelCase, it also works in the CLI.
The root changelog
The JDBC database connection URL
The database username
The database password
password attributes are not required for connections and systems which use alternate means of authentication.
list-locks command produces the following output when there is no lock on the table:
Liquibase Community 4.9.1 by Liquibase Database change log locks for DBUSER@jdbc:h2:tcp://localhost:9090/mem:dev - No locks Liquibase command 'list-locks' was executed successfully.
list-locks command produces the following output when there is a lock on the table:
Liquibase Community 4.9.1 by Liquibase Database change log locks for DBUSER@jdbc:h2:tcp://localhost:9090/mem:dev - 2605:6000:101c:686:486:f4ae:82fe:3c99%en0 (2605:6000:101c:686:486:f4ae:82fe:3c99%en0) at May 6, 2022, 9:04:38 PM Liquibase command 'list-locks' was executed successfully.