spring-projects / spring-projects/spring-data-rest
Concurrency issue with JPA Lists [DATAREST-895]
@odrotbohm is already working on this.
Since Dec 31, 2020.
- Dominant language
- Java
- Stars
- 958
- Forks
- 568
- PR merge metrics
- No merged PRs in 30d
Description
Laurent Bovet opened DATAREST-895 and commented
I have a OneToMany association with a JoinTable:
https://github.com/lbovet/bugtik/blob/jointable-concurrency-issue/src/main/java/li/chee/bugtik/Project.java#L20
When creating associations in parallel (POST URIs to the collection resource concurrently), There is a race condition where the previous collection content overwrites a more recent one. This results in not all the associations created.
Note that if I model the association with a JoinColumn, the problem does not arises:
https://github.com/lbovet/bugtik/blob/joincolumn-concurrency-ok/src/main/java/li/chee/bugtik/Project.java#L20
I think it is a bug that Spring Data Rest operations are not performed atomically in the JoinTable case. If not, is there a configurative way to solve this?
You can checkout the sample project (https://github.com/lbovet/bugtik.git) and try both branches:
mvn spring-boot:run
http://localhost:8080/concurrency-test.html
Affects: 2.4.4 (Gosling SR4), 2.5.2 (Hopper SR2)
Reference URL: https://github.com/lbovet/spring-data-rest/tree/issue/DATAREST-895
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.