Uploading 2 attachments to same page at the same time via REST API will cause 500 error

XMLWordPrintable

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Low
    • None
    • Affects Version/s: 8.5.4
    • None
    • 3
    • Severity 3 - Minor
    • 1

      Issue Summary

      If uploading 2 attachments( with different file name ) to a page at the same time via REST API, it will  API will cause 500 error.

      Note: If uploading to different pages at same time, this problem does not happen.

       

      This is reproducible on Data Center: (yes) 

      Steps to Reproduce

      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
        
      4. Wait crontab job running

       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

      Currently there is no known workaround for this behavior.

            Assignee:
            Unassigned
            Reporter:
            Rick Li
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: