Getting Duplicate Attachment Errors: "findSingleObject Uh oh - found more than one object when single object requested" in the Logs
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
The purpose of this documentation is to consolidate the following bug reports:
This issue was once a known bug in the previous version of confluence (3.0 and below). However, Confluence users still often find duplicated attachments exists in the database with an unknown reason. This documentation provides a workaround on how to delete one of the duplicated attachments from the database.
Problem
The following appears in the atlassian-confluence.log
1
2
2016-02-17 14:32:44,338 ERROR [http-nio-8090-exec-2] [com.atlassian.hibernate.HibernateObjectDao] findSingleObject Uh oh - found more than one object when single object requested: [Attachment: charlie.png v.1 (9995208) charlie, Attachment: charlie.png v.1 (9995209) charlie]
-- referer: http://confluence_base_url:8090/pages/viewpage.action?pageId=1278210 | url: /rest/likes/1.0/content/1278210/likes | userName: charlie
Solution
Diagnosis
Find all the occurrences of the duplicated attachments:
Open atlassian-confluence.log located in the <confluence_home_folder>/logs
Find all the occurrence of the stacktrace:
1
findSingleObject Uh oh - found more than one object when single object requested: [Attachment:
You will find stacktrace that includes the duplicated attachment's name, such as the example provided in the beginning of this documentation.
Confirm the existence of duplicated attachments in the database:
From the stacktrace obtained, find out and list all the duplicated attachments from the database using SQL query.
Confluence 5.7 and above
1
SELECT * FROM CONTENT WHERE TITLE = '<DUPLICATED ATTACHMENT TITLE>';
If the query above returns too many results, it's possible to further narrow down those results:
1
2
3
4
5
6
7
8
9
10
11
12
13
select title, version, pageid, count(pageid)
from CONTENT
where title='<DUPLICATED ATTACHMENT TITLE>'
and contenttype='ATTACHMENT'
group by title, version, pageid having count(pageid) > 1;
SELECT contentid, title, version, pageid, tableWithCount.count FROM
(SELECT *, count(*)
OVER
(PARTITION BY
version,pageid
) AS count
FROM content) tableWithCount
WHERE title='<DUPLICATED ATTACHMENT TITLE>' and contenttype='ATTACHMENT' and tableWithCount.count > 1 order by pageid;
Confluence 5.6 and below
1
SELECT * FROM ATTACHMENTS WHERE TITLE = '<DUPLICATED ATTACHMENT TITLE>';
Take note of the attachments' name. For example, from the above logs, the attachment name in question is 'charlie.png'. Therefore, replace '<DUPLICATED ATTACHMENT TITLE>' with 'charlie.png'
The SQL queries above will list you with the details of the duplicated attachments. From here, decide which attachments that should be kept and which one should be deleted. Take note of their CONTENTID (5.7 and above) or their ATTACHMENTID (5.6 and below).
Workaround
The log messages are harmless and the attachments will work as expected. However, if you need to remove those messages, the workaround is to delete one of the duplicated attachments from the database. Use the following DELETE SQL queries:
Confluence 5.7 and above
1
DELETE FROM CONTENT WHERE CONTENTID = <CONTENT_ID>;
Use the queries below to avoid FK constraint error:
1 2 3
DELETE FROM IMAGEDETAILS where ATTACHMENTID = <CONTENT_ID>; DELETE FROM CONTENTPROPERTIES WHERE CONTENTID = <CONTENT_ID>; DELETE FROM CONTENT WHERE CONTENTID = <CONTENT_ID>;
Confluence 5.6 and below
1
DELETE FROM ATTACHMENTS WHERE ATTACHMENTID = <ATTACHMENT_ID>;
Replace the <CONTENT_ID> and <ATTACHMENT_ID> with the CONTENTID and the ATTACHMENTID that was obtained from the Diagnosis step
Always back up your data before making any database modifications. If possible, test any alter, insert, update, or delete SQL commands on a staging server first.
Was this helpful?