ORA-01400 cannot insert NULL into errors after restore using the Backup Client
Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.
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
Restoring a backup with the Backup Client causes errors when using the following following functions:
- SSH keys cannot be added
- Build status is not updated
- Branch permissions cannot be created
- Audit logs are not updated
One or more of the following errors appears in the atlassian-bitbucket.log
:
java.sql.SQLIntegrityConstraintViolationException: ORA-01400: cannot insert NULL into ("BITBUCKET"."AO_CFE8FA_BUILD_STATUS"."ID")
java.sql.SQLIntegrityConstraintViolationException: ORA-01400: cannot insert NULL into ("BITBUCKET"."AO_BD73C3_PROJECT_AUDIT"."AUDIT_ITEM_ID")
java.sql.SQLIntegrityConstraintViolationException: ORA-01400: cannot insert NULL into ("BITBUCKET"."AO_616D7B_BRANCH_TYPE"."ID")
java.sql.SQLIntegrityConstraintViolationException: ORA-01400: cannot insert NULL into ("BITBUCKET"."AO_6978BB_RESTRICTED_REF"."REF_ID")
java.sql.SQLIntegrityConstraintViolationException: ORA-01400: cannot insert NULL into ("BITBUCKET"."AO_FB71B4_SSH_PUBLIC_KEY"."ENTITY_ID")
Diagnosis
Extracting the active-objects-data.xml
file from the backup file reveals that the autoIncrement
attribute has been set to false for the primary key on Active Object tables.
<table name="AO_FB71B4_SSH_PUBLIC_KEY">
<column name="ENTITY_ID" primaryKey="true" autoIncrement="false" sqlType="2" precision="11"/>
<column name="KEY_MD5" primaryKey="false" autoIncrement="false" sqlType="12" precision="32"/>
<column name="KEY_TEXT" primaryKey="false" autoIncrement="false" sqlType="2005" precision="2147483647"/>
<column name="LABEL" primaryKey="false" autoIncrement="false" sqlType="12" precision="255"/>
<column name="USER_ID" primaryKey="false" autoIncrement="false" sqlType="2" precision="11"/>
</table>
In the above example, the ENTITY_ID
column should have autoIncrement="true"
.
Cause
The Oracle JDBC driver 12.1.0.2 was in use by Bitbucket Server when the backup was taken. There is a bug with this driver that causes the autoIncrement
flag to be set incorrectly.
The latest Bitbucket Server is bundled with version 12.1.0.1 of the driver which is not affected by this issue. We do not recommend changing the JDBC driver that comes bundled with Bitbucket Server.
Workaround
Use the DIY Backup to perform the backup which is not affected by this issue.
Resolution
Downgrade the Oracle JDBC driver to 12.1.0.1 which was originally bundled with Bitbucket Server and run the Backup Client again.