PostgreSQL database issue when database user is changed

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

Summary

Problem

When the old database user is PostgreSQL default super user postgres and a new database user is created and configured in bitbucket.properties, Bitbucket fails to start with the following issue reported in atlassian-bitbucket.log:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'bootstrapLiquibase' defined in class path resource [stash-context.xml]: Invocation of init method failed; nested exception is liquibase.exception.LockException: liquibase.exception.UnexpectedLiquibaseException: liquibase.exception.DatabaseException: Error executing SQL SELECT COUNT(*) FROM public.databasechangeloglock: ERROR: current transaction is aborted, commands ignored until end of transaction block at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1778) ... 5 common frames omitted Caused by: liquibase.exception.LockException: liquibase.exception.UnexpectedLiquibaseException: liquibase.exception.DatabaseException: Error executing SQL SELECT COUNT(*) FROM public.databasechangeloglock: ERROR: current transaction is aborted, commands ignored until end of transaction block at liquibase.lockservice.StandardLockService.acquireLock(StandardLockService.java:289) at liquibase.lockservice.StandardLockService.waitForLock(StandardLockService.java:207) at liquibase.Liquibase.update(Liquibase.java:184) at liquibase.Liquibase.update(Liquibase.java:179) at liquibase.integration.spring.SpringLiquibase.performUpdate(SpringLiquibase.java:317) at liquibase.database.ExtendedSpringLiquibase.afterPropertiesSet(ExtendedSpringLiquibase.java:32) ... 5 common frames omitted Caused by: liquibase.exception.UnexpectedLiquibaseException: liquibase.exception.DatabaseException: Error executing SQL SELECT COUNT(*) FROM public.databasechangeloglock: ERROR: current transaction is aborted, commands ignored until end of transaction block at liquibase.lockservice.StandardLockService.isDatabaseChangeLogLockTableInitialized(StandardLockService.java:173) at liquibase.lockservice.StandardLockService.init(StandardLockService.java:121) at liquibase.lockservice.StandardLockService.acquireLock(StandardLockService.java:246) ... 10 common frames omitted Caused by: liquibase.exception.DatabaseException: Error executing SQL SELECT COUNT(*) FROM public.databasechangeloglock: ERROR: current transaction is aborted, commands ignored until end of transaction block at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:70) at liquibase.executor.jvm.JdbcExecutor.query(JdbcExecutor.java:138) at liquibase.executor.jvm.JdbcExecutor.query(JdbcExecutor.java:146) at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:154) at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:169) at liquibase.executor.jvm.JdbcExecutor.queryForInt(JdbcExecutor.java:190) at liquibase.executor.jvm.JdbcExecutor.queryForInt(JdbcExecutor.java:185) at liquibase.lockservice.StandardLockService.isDatabaseChangeLogLockTableInitialized(StandardLockService.java:162) ... 12 common frames omitted Caused by: org.postgresql.util.PSQLException: ERROR: current transaction is aborted, commands ignored until end of transaction block at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2440) at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2183) at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:308) at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:441) at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:365) at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:307) at org.postgresql.jdbc.PgStatement.executeCachedSql(PgStatement.java:293) at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:270) at org.postgresql.jdbc.PgStatement.executeQuery(PgStatement.java:224) at com.zaxxer.hikari.pool.ProxyStatement.executeQuery(ProxyStatement.java:111) at com.zaxxer.hikari.pool.HikariProxyStatement.executeQuery(HikariProxyStatement.java) at liquibase.executor.jvm.JdbcExecutor$QueryStatementCallback.doInStatement(JdbcExecutor.java:419) at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:57) ... 19 common frames omitted Caused by: org.postgresql.util.PSQLException: ERROR: relation "databasechangeloglock" already exists at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2440) at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2183) at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:308) at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:441) at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:365) at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:307) at org.postgresql.jdbc.PgStatement.executeCachedSql(PgStatement.java:293) at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:270) at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:266) at com.zaxxer.hikari.pool.ProxyStatement.execute(ProxyStatement.java:95) at com.zaxxer.hikari.pool.HikariProxyStatement.execute(HikariProxyStatement.java) at liquibase.executor.jvm.JdbcExecutor$ExecuteStatementCallback.doInStatement(JdbcExecutor.java:352) at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:57) at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:125) at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:109) at liquibase.lockservice.StandardLockService.init(StandardLockService.java:97) ... 11 common frames omitted

Diagnosis

Environment

  • PostgreSQL 9.5.19

  • Bitbucket Server 6.6.1

Cause

There is most likely a database permission issue happening, even though this is not 100% confirmed.

This problem might affect other database tables.

Solution

Resolution

  1. Create a new database and new user according to Connecting Bitbucket Server to PostgreSQL, making sure that this user owns the newly created database

  2. Instead of updating bitbucket.properties directly, use the Database Migration wizard in order to migrate to the newly created database with the newly created user.

Updated on April 8, 2025

Still need help?

The Atlassian Community is here for you.