Multiple AttachmentData objects were returned when only one was expected for attachment
Symptoms
- Cannot rebuild indicies from scratch after upgrade
- Cannot search successfully
The following appears in the atlassian-confluence.log
:
org.springframework.dao.IncorrectResultSizeDataAccessException: Multiple AttachmentData objects were returned when only one was expected for attachment: Attachment: <attachment name and id>
at com.atlassian.confluence.pages.persistence.dao.hibernate.HibernateAttachmentDataDao.getAttachmentDataForAttachment(HibernateAttachmentDataDao.java:77)
Cause
There are duplicates in the attachmentdata table, most likely due to this bug - CONF-7882Getting issue details... STATUS
Resolution
Identify duplicates from attachmentdata table in the database
select attachmentdataid, attachmentid, attversion, count(*) from ATTACHMENTDATA group by attachmentid, attachmentdataid, attversion having count(*)>1;
Delete the duplicates that have the same attachmentid and attversion, leaving the version which has the greatest attachmentdataid:
delete from ATTACHMENTDATA where attachmentdataid=<put in attachmentdataids here>;
- Last step is to How to Rebuild the Content Indexes From Scratch on Confluence Server