Bitbucket Data Center Does Not Start - Could not acquire change log lock
Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.
Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Problem
Option#1: Bitbucket Data Center does not start and the following error can be seen in the atlassian-bitbucket.log
:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'liquibase' defined in class path resource [bitbucket-context.xml]: Invocation of init method failed; nested exception is liquibase.exception.LockException: Could not acquire change log lock. Currently locked by fe80:0:0:0:a00:27ff:fe6a:c787%2 (fe80:0:0:0:a00:27ff:fe6a:c787%2) since 12/6/12 2:08 PM
Option#2: Bitbucket Data Center has the nodes hosted in Docker containers. During the full cluster restart with (docker stop) the startup hangs on setting the lock for the filesystem:
[spring-startup] c.a.s.internal.home.HomeLockAcquirer Successfully acquired lock on home directory /var/atlassian/bitbucket-home/atlassian-bitbucket-5.16.0
Cause
The DATABASECHANGELOGLOCK
table has not been updated with the release lock information.
The likely cause of this is that the Bitbucket instance was forced to quit while it was trying to migrate the database schema after an upgrade, with the consequence that the lock was not released. You should always wait for Bitbucket to start up sufficiently for it to provide error messages if there are schema migration problems – never assume that it has hung and kill the process.
Another possible cause of not releasing the lock is that Bitbucket was forced to quit while performing automatic application setup.
Resolution
Bitbucket needs an exclusive lock on the DATABASECHANGELOGLOCK
table in order to start, so take care to disconnect/close the tool used to update the database. If you don't do this, you may experience Bitbucket hanging on startup with no errors in the logs and no response from the web server.
MySQL and SQL Server
UPDATE DATABASECHANGELOGLOCK SET LOCKED=0, LOCKGRANTED=null, LOCKEDBY=null where ID=1;
Oracle
UPDATE DATABASECHANGELOGLOCK SET LOCKED=0, LOCKGRANTED=null, LOCKEDBY=null where ID=1;
commit;
PostgreSQL
UPDATE databasechangeloglock SET LOCKED=false, LOCKGRANTED=null, LOCKEDBY=null where ID=1;
HSQLDB in Production Environments
We don't recommend the usage of HSQL for production environments. Please refer to Connect Bitbucket to an external database for a proper production environment deployment.
Shutdown Bitbucket.
Open your
<BITBUCKET_HOME>/data/db.script
and look for a string like:INSERT INTO DATABASECHANGELOGLOCK VALUES(1,TRUE,'2012-06-12 14:08:00.982000','fe80:0:0:0:a00:27ff:fe6a:c787%2 (fe80:0:0:0:a00:27ff:fe6a:c787%2)')
And replace it with the one below:
INSERT INTO DATABASECHANGELOGLOCK VALUES(1,FALSE, NULL,NULL )
Restart Bitbucket.
H2 Embedded Database in Production Environments
We don't recommend the usage of H2 Embedded Database for production environments. Please refer to Connect Bitbucket to an external database for a proper production environment deployment.
Stop Bitbucket.
Log in to the server as the user that runs Bitbucket.
Run the following command which will open a console connection to the database:
You'll want to update the path below to reflect where Bitbucket is installed and select the h2 jar. By default it is stored in:
/opt/atlassian/bitbucket/<Release_Number>
java -cp <BITBUCKET_INSTALL>/atlassian-bitbucket/WEB-INF/lib/h2-1.3.176.jar org.h2.tools.Shell
When prompted for the URL, enter:
You'll want to verify that the path below points your DB. By default it is stored in:
/var/atlassian/application-data
jdbc:h2:file://<$BITBUCKET_HOME>/bitbucket/shared/data/db;DB_CLOSE_ON_EXIT=TRUE
Press Enter when asked which driver to use.
Enter
sa
for the user.Press Enter twice when prompted for the password (no password is required).
This should leave you with a sql>
prompted, and you can run the update query below:
UPDATE databasechangeloglock SET LOCKED=false, LOCKGRANTED=null, LOCKEDBY=null where ID=1;
Related link: Access Bitbucket Data Center's H2 embedded database
Was this helpful?