#Spring Boot Concurrent Threads

3 messages · Page 1 of 1 (latest)

silk girder
#

Hello everyone, I was wanting some ideas or some direction been stuck for bit now. I'm building a web application that handles requests via a REST API. my REST API creates, and updates entities that are incoming. The issue I'm having is that I notice upon a request being accepted, spring boot creates a new thread and I have the issue right now that if I send 5 requests around the same time (ms) then I get a DB locked because one of the threads is writing to the DB, so the other 4 threads get the exception. I am wondering how can I prevent this if anyone has had this issue? I am using JPA as well.

mental mango
#

this sounds like a limitation of your data source

#

if you really do need synchronized writing to your database, you should probably implement that through some common component that's synchronized or uses mutexes