Cannot Restore XML Backup Due to 'null value in column destpagetitle violates not-null constraint'
Symptoms
The following error appears during a space or global import:
2009-05-15 20:30:00,666 ERROR [Importing data task] [sf.hibernate.util.JDBCExceptionReporter] logExceptions ERROR: null value in column "destpagetitle" violates not-null constraint
-- referer: https://qa-cac.atlassian.com/admin/backup.action | url: /admin/restore.action | userName: don.willis@atlassian.com | action: restore
2009-05-15 20:30:00,667 ERROR [Importing data task] [sf.hibernate.impl.SessionImpl] execute Could not synchronize database state with session
-- referer: https://qa-cac.atlassian.com/admin/backup.action | url: /admin/restore.action | userName: don.willis@atlassian.com | action: restore
2009-05-15 20:30:00,667 ERROR [Importing data task] [confluence.importexport.impl.ReverseDatabinder] endElement net.sf.hibernate.exception.ConstraintViolationException: could not insert: [com.atlassian.confluence.links.OutgoingLink#190676995]
-- referer: https://qa-cac.atlassian.com/admin/backup.action | url: /admin/restore.action | userName: don.willis@atlassian.com | action: restore
net.sf.hibernate.exception.ConstraintViolationException: could not insert: [com.atlassian.confluence.links.OutgoingLink#190676995]
at net.sf.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:62)
at net.sf.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29)
at net.sf.hibernate.persister.AbstractEntityPersister.convert(AbstractEntityPersister.java:1331)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:472)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:436)
at net.sf.hibernate.impl.ScheduledInsertion.execute(ScheduledInsertion.java:37)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2449)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2435)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2392)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2261)
at com.atlassian.confluence.importexport.impl.ReverseDatabinder.flushIfNeeded(ReverseDatabinder.java:532)
at com.atlassian.confluence.importexport.impl.ReverseDatabinder.writeObject(ReverseDatabinder.java:505)
at com.atlassian.confluence.importexport.impl.ImportedObject.saveObject(ImportedObject.java:212)
at com.atlassian.confluence.importexport.impl.ReverseDatabinder.endObject(ReverseDatabinder.java:375)
at com.atlassian.confluence.importexport.impl.ReverseDatabinder.endElement(ReverseDatabinder.java:240)
at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanEndElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
Cause
In early versions of Confluence there was a not null constraint on the column: LINKS.DESTPAGETITLE. This constraint was removed from the schema creation in January 2004, but Confluence instances older than that will still have the constraint, as there was not upgrade task to remove it. See Cannot Restore XML Backup Due to 'null value in column destpagetitle violates not-null constraint'.
Resolution
Delete the constraint using the following SQL (tested against Postgres 8.2.9):
alter table links alter column destpagetitle drop not null;
Then retry the import.