Confluence Space import fails due to 'duplicate key value violates unique constraint' error
Problem
When importing a Space into Confluence, the import fails due to a duplicate key error.
The following appears in the atlassian-confluence.log
file:
Import failed. Check your server logs for more information. com.atlassian.confluence.importexport.ImportExportException: Unable to complete import because the data does not match the constraints in the Confluence schema. Cause: PSQLException: ERROR: duplicate key value violates unique constraint "bandana_unique_key"
Cause
This behavior is caused by entries already existing within the Confluence database that would be duplicated by the import.
The Confluence 'bandana' table has the following unique key constraint:
"bandana_unique_key" UNIQUE CONSTRAINT, btree (bandanacontext, bandanakey)
There are multiple possible causes for this constraint to be violated.
Workaround
- Follow the instructions to enable Enabling Detailed SQL Logging
- Attempt the Space import
- Stop Confluence
- Find the INSERT query that is causing the unique constraint violation
- Note the banadanacontext and bandanakey values being set
Delete whatever entry already exists:
delete from BANDANA where BANDANACONTEXT = '<BANDANACONTEXT-value-from-insert-query>' and BANDANAKEY = '<BANDANAKEY-value-from-insert-query>';
- Start Confluence
- Attempt the Space import (repeat as needed)
Last modified on Aug 28, 2017
Powered by Confluence and Scroll Viewport.