Uploaded image for project: 'Confluence Data Center'
  1. Confluence Data Center
  2. CONFSERVER-23771

Attachment Migration from database to filesystem fails due to filesize mismatch

XMLWordPrintable

      When testing migration of attachments from the database to the filesystem I get about 400 of the stacktrace below. This is caused by a mismatch between the reported filesize in the attachment table and the actual length of the attachment. The current behaviour is to log the error and skip the attachment. However, I have checked some of the attachments and they are not actually broken. It is (at least sometimes) the attachment table that is incorrect.

      So really, Confluence should log a warning and migrate the data regardless.

      Note, I'm not sure how old this bug is, but since it's definitely older than 4.0 I've put "3.5" as the affects version.

      SQL to find a summary of the affected records:

      select count(*), attachments.filesize, avg(length(attachmentdata.data)), attachments.contenttype, attachments.attachment_comment, attachments.version
      from attachments, attachmentdata
      where attachments.attachmentid=attachmentdata.attachmentid and filesize != length(data)
      group by attachments.filesize, attachments.contenttype, attachments.attachment_comment, attachments.version
      

      Sample stacktrace

      2011-10-19 14:57:02,346 ERROR [Long running task: Attachment data migration] [persistence.dao.hibernate.AbstractHibernateAttachmentDao$IntraHibernateAttachmentCopier] copy Could not copy attachment: Attachment: Marketing Pyramid v.2 (542867488) jon
       -- referer: http://localhost:8080/confluence/admin/doeditattachmentstorage.action | url: /confluence/admin/doattachmentmigration.action | userName: dwillis.adm | action: doattachmentmigration
      com.atlassian.confluence.pages.attachments.AttachmentDataStreamSizeMismatchException: Attachment data stream contains a different number of bytes to the declared size of the attachment. Expected: 495, actual: 6514
          at com.atlassian.confluence.pages.persistence.dao.FileSystemAttachmentDataDao.writeStreamToFile(FileSystemAttachmentDataDao.java:241)
          at com.atlassian.confluence.pages.persistence.dao.FileSystemAttachmentDataDao.saveDataForAttachment(FileSystemAttachmentDataDao.java:172)
          at com.atlassian.confluence.pages.persistence.dao.FileSystemAttachmentDataDao.saveDataForAttachment(FileSystemAttachmentDataDao.java:132)
          at com.atlassian.confluence.pages.persistence.dao.hibernate.AbstractHibernateAttachmentDao$IntraHibernateAttachmentCopier.copy(AbstractHibernateAttachmentDao.java:448)
          at com.atlassian.confluence.pages.persistence.dao.hibernate.AbstractHibernateAttachmentDao$IntraHibernateAttachmentMigrator.migrate(AbstractHibernateAttachmentDao.java:503)
          at com.atlassian.confluence.util.longrunning.AttachmentMigrationLongRunningTask$1.doInTransactionWithoutResult(AttachmentMigrationLongRunningTask.java:71)
          at org.springframework.transaction.support.TransactionCallbackWithoutResult.doInTransaction(TransactionCallbackWithoutResult.java:33)
          at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:128)
          at com.atlassian.confluence.util.longrunning.AttachmentMigrationLongRunningTask.runInternal(AttachmentMigrationLongRunningTask.java:66)
          at com.atlassian.confluence.util.longrunning.ConfluenceAbstractLongRunningTask.run(ConfluenceAbstractLongRunningTask.java:21)
          at com.atlassian.confluence.util.longrunning.ManagedTask.run(ManagedTask.java:35)
          at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
          at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
          at java.util.concurrent.FutureTask.run(FutureTask.java:138)
          at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
          at java.lang.Thread.run(Thread.java:680)
      

        1. migration_log.txt
          119 kB
        2. DB_to_FS3.png
          DB_to_FS3.png
          158 kB
        3. DB_to_FS2.png
          DB_to_FS2.png
          376 kB
        4. DB_to_FS1.png
          DB_to_FS1.png
          382 kB

              don.willis@atlassian.com Don Willis
              don.willis@atlassian.com Don Willis
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: