-
Type:
Bug
-
Resolution: Fixed
-
Priority:
Low
-
Affects Version/s: 8.5.4, 9.2.5
-
Component/s: Core - Content REST APIs
-
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:
- According to this sample, create a script to upload an attachment to a page.
- script name: script1.sh
- attachment files name: file1.data
- Create another script to upload other attachment to same page
- script name: script2.sh
- attachment files name: file2.data
- Edit crontab to make above 2 script running at same time
00 10 * * * /XXX/XXX/script1.sh 00 10 * * * /XXX/XXX/script2.sh
- Wait crontab job running
UI:
- Open the same page on two browser windows
- 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.