Unable to copy the page due to attachment size mismatch

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.

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

Copying a page will fail with an error that attachment size is different in the filesystem and in the database.

Environment

The problem can be seen on any Confluence version.

Diagnosis

In the logs something like this will be visible:

com.atlassian.confluence.pages.attachments.AttachmentDataStreamSizeMismatchException: Attachment data stream contains a different number of bytes to the declared size of the attachment. Expected: 130192, actual: 130203
at com.atlassian.confluence.pages.persistence.dao.filesystem.FileSystemAttachmentDataUtil.writeStreamToFile(FileSystemAttachmentDataUtil.java:42)
at com.atlassian.confluence.pages.persistence.dao.filesystem.HierarchicalMultiStreamAttachmentDataFileSystem.saveAttachmentData(HierarchicalMultiStreamAttachmentDataFileSystem.java:104)
at com.atlassian.confluence.pages.persistence.dao.filesystem.FileSystemAttachmentDataDao.saveDataForAttachment(FileSystemAttachmentDataDao.java:150)
at com.atlassian.confluence.pages.persistence.dao.filesystem.FileSystemAttachmentDataDao.saveDataForAttachment(FileSystemAttachmentDataDao.java:120)
at com.atlassian.confluence.pages.persistence.dao.hibernate.AbstractHibernateAttachmentDao.saveNewAttachment(AbstractHibernateAttachmentDao.java:363)
at com.atlassian.confluence.pages.attachments.CachingAttachmentDao.saveNewAttachment(CachingAttachmentDao.java:202)
at com.atlassian.confluence.pages.DefaultAttachmentManager.saveNewAttachment(DefaultAttachmentManager.java:252)


Cause

If the size of the attachment is different in the database "contentproperties" table and on the file system, then the issue will be observed when we try to copy the page.

Solution

The solution is simply to locate the affected attachment, download it and attach it again to the page.

To locate the affected attachment:

  • Locate the pageid (eg. 22334455).
  • Then use the "Expected" value from the stack trace ( from this stack trace that is 130192) and pageid in this query to find the attachment name:

    select title from content where pageid=22334455 and contentid in (select contentid from contentproperties where propertyname='FILESIZE' and longval=130192);
  • Once you locate the attachment name, download it from the page and re-upload it again.
  • This should fix the issue.

The same behavior was observed with files created by Draw.io macro, which are stored as attachments.

  • The issue on that case can be solve by exporting the macro content and re-importing it.




Last modified on Feb 9, 2023

Was this helpful?

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