Bamboo fails to start after PostgreSQL migration with error relation build does not exist
Problem
Bamboo fails to start after migrating PostgreSQL database to another PostgreSQL server with the following steps:
- Migrate PostgreSQL server through
pg_dump
to another server - Configure
bamboo.cfg.xml
to refer to the new PostgreSQL server
The following appears in the atlassian-bamboo.log
2017-08-24 15:59:22,866 ERROR [localhost-startStop-1] [AbstractUpgradeManager] org.postgresql.util.PSQLException: ERROR: relation "build" does not exist
Position: 34
org.postgresql.util.PSQLException: ERROR: relation "build" does not exist
Position: 34
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2310)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2023)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:217)
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:421)
at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:318)
at org.postgresql.jdbc.PgStatement.executeQuery(PgStatement.java:281)
at com.mchange.v2.c3p0.impl.NewProxyStatement.executeQuery(NewProxyStatement.java:327)
at com.atlassian.bamboo.upgrade.tasks.validation.PlanKeysCorrectlyFormatted$1.doInHibernateTransaction(PlanKeysCorrectlyFormatted.java:39)
at com.atlassian.bamboo.upgrade.AbstractBootstrapUpgradeTask.withDatabaseConnection(AbstractBootstrapUpgradeTask.java:69)
Diagnosis
Run the following SQL query to check if there is a search_path
configured for the database user:
SELECT r.rolname, d.datname, rs.setconfig
FROM pg_db_role_setting rs
LEFT JOIN pg_roles r ON r.oid = rs.setrole
LEFT JOIN pg_database d ON d.oid = rs.setdatabase
WHERE r.rolname = 'databaseUser' OR d.datname = 'databaseName';
Replace databaseUser
and databaseName
with the settings in bamboo.cfg.xml
If there is no result, it means that the database user is using the default search_path
public
Cause
- PostgreSQL is using the
search_path
public by default - The database dump is migrated to a custom schema and/or the database user is configured with incorrect
search_path
Resolution
Configure the database user to use the correct search_path
with the following SQL and restart Bamboo:
ALTER ROLE databaseUser SET search_path TO customSchema;
Replace databaseUser
and customSchema with the correct settings