"Could not get unique fields for table" error while migrating from internal DB to Oracle DB in Bitbucket Datacenter

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

While migrating from the Bitbucket internal database to the external Oracle Database, you will see the message "Could not get unique fields for table" in the Bitbucket logs.

Environment

Bitbucket Datacenter

Oracle Database

Diagnosis

In the atlassian-bitbucket.log, you'll see the below error message:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 2024-02-29 00:00:00,071 ERROR [Caesium-1-3] c.a.a.retention.RetentionJobRunner Failed to execute RetentionJob com.atlassian.activeobjects.internal.ActiveObjectsInitException: bundle [com.atlassian.audit.atlassian-audit-plugin] at com.atlassian.activeobjects.osgi.TenantAwareActiveObjects$1$1$1.call(TenantAwareActiveObjects.java:95) at com.atlassian.activeobjects.osgi.TenantAwareActiveObjects$1$1$1.call(TenantAwareActiveObjects.java:86) at com.atlassian.sal.core.executor.ThreadLocalDelegateCallable.call(ThreadLocalDelegateCallable.java:38) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.lang.Thread.run(Thread.java:829) ... 1 frame trimmed Caused by: java.lang.RuntimeException: Could not get unique fields for table 'AO_C77861_AUDIT_ENTITY' at net.java.ao.schema.helper.DatabaseMetaDataReaderImpl.getUniqueFields(DatabaseMetaDataReaderImpl.java:191) at com.atlassian.activeobjects.osgi.TenantAwareActiveObjects$1$1$1.call(TenantAwareActiveObjects.java:91) ... 6 common frames omitted Caused by: java.sql.SQLException: Invalid argument(s) in call at oracle.jdbc.OracleDatabaseMetaData.getIndexInfo(OracleDatabaseMetaData.java:3731) at net.java.ao.db.OracleDatabaseProvider.getIndexes(OracleDatabaseProvider.java:100) at net.java.ao.schema.helper.DatabaseMetaDataReaderImpl.getUniqueFields(DatabaseMetaDataReaderImpl.java:180) ... 43 common frames omitted

Cause

The schema name looks something like BITBUCKET-USER. Oracle Database does not accept hyphen (-) in the schema name, hence this error.

Solution

Follow the below steps to use a different schema for your Oracle Database and use that while connecting the Oracle Database to Bitbucket:

  1. Create another user with a name that doesn't have a hyphen (-) and has an underscore (_) instead, or just one word like "bitbucketuser

  2. Add/modify the Database information in the <Bitbucket-home>/shared/bitbucket.propertiesfile.

Please refer to this page for more information: Connect Bitbucket to Oracle.

Updated on February 25, 2025

Still need help?

The Atlassian Community is here for you.