Bitbucket Server 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 Server does not start and the following error can be seen in the atlassian-bitbucket.log
:
1
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 the setting the lock for the filesystem:
1
[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 Server 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 Server 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 Server was forced to quit while performing automatic application setup.
Resolution
Bitbucket Server 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 do not do this you may experience Bitbucket Server hanging on start up with no errors in the logs and no response from the web server.
Click here to expand for MySQL and SQL Server
1
UPDATE DATABASECHANGELOGLOCK SET LOCKED=0, LOCKGRANTED=null, LOCKEDBY=null where ID=1;
Click here to expand for Oracle
1
2
UPDATE DATABASECHANGELOGLOCK SET LOCKED=0, LOCKGRANTED=null, LOCKEDBY=null where ID=1;
commit;
Click here to expand for PostgreSQL
1
UPDATE databasechangeloglock SET LOCKED=false, LOCKGRANTED=null, LOCKEDBY=null where ID=1;
Click here to expand for HSQLDB
About 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.
1- Shutdown Bitbucket Server
2- Open your <BITBUCKET_HOME>/data/db.script
and look for a string like:
1
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 substitute it by the one below:
1
INSERT INTO DATABASECHANGELOGLOCK VALUES(1,FALSE, NULL,NULL )
3- Restart Bitbucket Server
Click here to expand for H2 Embedded Database
About 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 Server
Login to the server as the user that runs Bitbucket Server
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 Server is installed and select the h2 jar. By default it is stored in:
/opt/atlassian/bitbucket/<Release_Number>
1
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
1
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 userPress 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:
1
UPDATE databasechangeloglock SET LOCKED=false, LOCKGRANTED=null, LOCKEDBY=null where ID=1;
Related link:Accessing Bitbucket Server's H2 embedded database
Was this helpful?