Uploaded image for project: 'Confluence Cloud'
  1. Confluence Cloud
  2. CONFCLOUD-78329

Attaching a file via PUT /wiki/rest/api/content/{id}/child/attachment fails with org.springframework.transaction.UnexpectedRollbackException error

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Low
    • Page - Attachments
    • None

    Description

      Issue Summary

      This is reproducible on Data Center: No

      There are intermittent issues with the Create or Update Attachment REST API endpoint used to add attachments to our application (/wiki/rest/api/content/{id}/child/attachment - Create or update attachment

       

      Occasionally, the API fails and returns a 500 status accompanied by the message:

       

      org.springframework.transaction.UnexpectedRollbackException: Transaction rolled back because it has been marked as rollback-only 

       

       

      Since it’s happening for multiple sites, we suspect that it may be due to a race condition or something similar while writing to the db (not necessarily broken objects within a page).

       

      Your assistance and guidance in resolving this issue would be greatly appreciated.

      Steps to Reproduce

      1. N/A
      2.  

      Expected Results

      Adds an attachment to a piece of content. If the attachment already exists for the content, then the attachment is updated (i.e. a new version of the attachment is created).

      Actual Results

      So far, this has not been reproducible consistently, but there had been a number of occurrences. One recent example is traceId 3217d973910e4262b6d4c2e026a28c57.

      { [-]
         ctx: { [+]
         }
         ec2: { [+]
         }
         env: prod-eucentral
         ext: { [-]
           accessStatus: LICENSED_USE_ACCESS
           confluenceVersion: 2
           connection: 26cdfe41
           experience: unknown
           experienceId: unknown
           ncsStepVersion: 2
           reconciliationReason: UPDATE_ATTACHMENT
           route: WRITER
           traceId: 3217d973910e4262b6d4c2e026a28c57
         }
         hostname: bca2cc929884
         level: ERROR
         logger: org.hibernate.engine.jdbc.batch.internal.BatchingBatch
         m: { [+]
         }
         message: HHH000315: Exception executing batch [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=?, NAVIGATIONTYPE=?, PAGEID=?, SPACEID=?, CHILD_POSITION=?, PARENTID=? where CONTENTID=? and HIBERNATEVERSION=?], SQL: update CONTENT set HIBERNATEVERSION=?, TITLE=?, LOWERTITLE=?, VERSION=?, CREATOR=?, CREATIONDATE=?, LASTMODIFIER=?, LASTMODDATE=?, VERSIONCOMMENT=?, PREVVER=?, CONTENT_STATUS=?, NAVIGATIONTYPE=?, PAGEID=?, SPACEID=?, CHILD_POSITION=?, PARENTID=? where CONTENTID=? and HIBERNATEVERSION=?
         micros_container: confluence
         product: confluence
         thread: http-nio-8081-exec-20 [tenantId:40b6679b-b71a-43f5-b66f-fe2395d9313d, experience:unknown] [traceId:3217d973910e4262b6d4c2e026a28c57]
         time: 2024-04-10T13:04:43.572520689Z
         timestamp: 2024-04-10T13:04:43.572
      } 
      { [-]
         ctx: { [+]
         }
         ec2: { [+]
         }
         env: prod-eucentral
         err: { [-]
           class: [ [+]
           ]
           stack: java.lang.RuntimeException: 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=?, NAVIGATIONTYPE=?, 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=?, NAVIGATIONTYPE=?, PAGEID=?, SPACEID=?, CHILD_POSITION=?, PARENTID=? where CONTENTID=? and HIBERNATEVERSION=?. Listener: com.atlassian.confluence.plugins.collab.service.CollabContentEventListener event: com.atlassian.confluence.event.events.content.attachment.AttachmentUpdateEvent
            com.atlassian.event.internal.SingleParameterMethodListenerInvoker.invoke(SingleParameterMethodListenerInvoker.java:51)
            com.atlassian.confluence.event.ConfluenceListenerHandlersConfiguration$TimingListenerHandler$1.invoke(ConfluenceListenerHandlersConfiguration.java:61)
            com.atlassian.event.internal.AsynchronousAbleEventDispatcher.lambda$static$0(AsynchronousAbleEventDispatcher.java:57)
            ...
      
            Caused by: 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=?, NAVIGATIONTYPE=?, 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=?, NAVIGATIONTYPE=?, PAGEID=?, SPACEID=?, CHILD_POSITION=?, PARENTID=? where CONTENTID=? and HIBERNATEVERSION=?
            ...
      
            Caused by: 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=?, NAVIGATIONTYPE=?, PAGEID=?, SPACEID=?, CHILD_POSITION=?, PARENTID=? where CONTENTID=? and HIBERNATEVERSION=?
            ...
         }
         ext: { [-]
           accessStatus: LICENSED_USE_ACCESS
           confluenceVersion: 2
           connection: 26cdfe41
           experience: unknown
           experienceId: unknown
           ncsStepVersion: 2
           rootCause: 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=?, NAVIGATIONTYPE=?, PAGEID=?, SPACEID=?, CHILD_POSITION=?, PARENTID=? where CONTENTID=? and HIBERNATEVERSION=?
           route: WRITER
           traceId: 3217d973910e4262b6d4c2e026a28c57
         }
         hostname: bca2cc929884
         level: ERROR
         logger: com.atlassian.event.internal.AsynchronousAbleEventDispatcher
         m: { [+]
         }
         message: There was an exception thrown trying to dispatch event from the invoker [Timing Invoker for SingleParameterMethodListenerInvoker{method=public void com.atlassian.confluence.plugins.collab.service.CollabContentEventListener.collabUpdateAttachment(com.atlassian.confluence.event.events.content.attachment.AttachmentUpdateEvent), listener=com.atlassian.confluence.plugins.collab.service.CollabContentEventListener@226e8f19}]
         micros_container: confluence
         product: confluence
         thread: http-nio-8081-exec-20 [tenantId:40b6679b-b71a-43f5-b66f-fe2395d9313d, experience:unknown] [traceId:3217d973910e4262b6d4c2e026a28c57]
         time: 2024-04-10T13:04:43.577699944Z
         timestamp: 2024-04-10T13:04:43.576
      } 

      Workaround

      Currently, there is no known workaround for this behavior. A workaround will be added here when available

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              b0911210be5a Takafumi Ohtake -Ricksoft-
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated: