Uploading 2 attachments to same page at the same time may cause 500 error

XMLWordPrintable

    • 4
    • Severity 3 - Minor
    • 1

      Issue Summary

      Uploading attachments simultaneously to the same page may result in a 500 error. This can occur for REST API and by UI (Drag & Drop or by going to Insert File).

       

      This is reproducible on Data Center: (yes) 

      Steps to Reproduce

      REST API:

      1.  According to this sample, create a script to upload an attachment to a page.
        • script name:  script1.sh
        • attachment files name: file1.data
      2. Create another script to upload other attachment to same page
        • script name: script2.sh
        • attachment files name: file2.data
      3.  Edit crontab to make above 2 script running at same time
        00 10 * * * /XXX/XXX/script1.sh
        00 10 * * * /XXX/XXX/script2.sh
        
      1. Wait crontab job running

      UI:

      1. Open the same page on two browser windows
      1. Drag and drop a file into the page at the same time (easier to reproduce with a larger file, e.g. 100MB)

      Expected Results

      Both attachments will be uploaded without error

      Actual Results

      Only first attachments was uploaded successfully.
      Uploading second attachment will return 500 error.
      The below exception is thrown in the atlassian-confluence.log file:

      2024-10-07 01:10:02,544 ERROR [http-nio-8090-exec-6 url: /rest/api/content/27164680/child/attachment; user: admin] [rest.api.model.ExceptionConverter] convertServiceException No status code found for exception, converting to internal server error :
       -- url: /rest/api/content/27164680/child/attachment | userName: admin | traceId: 36853aafaaa7317e
      org.springframework.orm.hibernate5.HibernateOptimisticLockingFailureException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1; statement executed: update CONTENT set HIBERNATEVERSION=?, TITLE=?, LOWERTITLE=?, VERSION=?, CREATOR=?, CREATIONDATE=?, LASTMODIFIER=?, LASTMODDATE=?, VERSIONCOMMENT=?, PREVVER=?, CONTENT_STATUS=?, PAGEID=?, SPACEID=?, CHILD_POSITION=?, PARENTID=? where CONTENTID=? and HIBERNATEVERSION=?; nested exception is org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1; statement executed: update CONTENT set HIBERNATEVERSION=?, TITLE=?, LOWERTITLE=?, VERSION=?, CREATOR=?, CREATIONDATE=?, LASTMODIFIER=?, LASTMODDATE=?, VERSIONCOMMENT=?, PREVVER=?, CONTENT_STATUS=?, PAGEID=?, SPACEID=?, CHILD_POSITION=?, PARENTID=? where CONTENTID=? and HIBERNATEVERSION=?
      	at org.springframework.orm.hibernate5.SessionFactoryUtils.convertHibernateAccessException(Se
      

      Workaround

      Increase confluence.transaction.retry.maxAttempts (default is 2) will help REST API upload path.

      For UI attachment uploads, the users will have to try again as there’s no retry on transactions initiated there.

       

              Assignee:
              Jeffery Xie
              Reporter:
              Rick Li
              Votes:
              0 Vote for this issue
              Watchers:
              9 Start watching this issue

                Created:
                Updated:
                Resolved: