Getting Duplicate Attachment Errors: "findSingleObject Uh oh - found more than one object when single object requested" in the Logs

Still need help?

The Atlassian Community is here for you.

Ask the community

Platform Notice: Server and Data Center Only. This article only applies to Atlassian products on the server and data center platforms.

Purpose

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

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

Diagnosis

Find all the occurrence of the duplicated attachments:

  1. Open atlassian-confluence.log located in the <confluence_home_folder>/logs
  2. Find all the occurrence of the stacktrace

    findSingleObject Uh oh - found more than one object when single object requested: [Attachment:
  3. 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
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:

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
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
DELETE FROM CONTENT WHERE CONTENTID = <CONTENT_ID>;
  • Use the queries below to avoid FK constraint error:

    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
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 performing any modifications to the database. If possible, test any alter, insert, update, or delete SQL commands on a staging server first.




DescriptionThe purpose of this documentation is to consolidate bug reports on getting Duplicate Attachment Errors: "findSingleObject Uh oh - found more than one object when single object requested" in the Logs
ProductConfluence
PlatformServer
Last modified on Apr 16, 2020

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.