Spring Mongo: How to handle org.springframework.dao.OptimisticLockingFailureException

43 Views Asked by At

I have a Spring boot service which uses Spring Mongo. I have an application which needs to handle concurrency and therefore I sometimes have two threads which are trying to update the same document at the same time. Whenever I read data from the collection for one document, I would like to restrict all other threads from even reading that document. Instead I would like to make them wait, until the first thread has completed and saved its changes to the document

Is it also possible to fine tune this mechanism, to say block all documents that have a particular field set to something?

Been looking into transactions and pessimestic locking but can't seem to find anything that works well with Spring mongo

0

There are 0 best solutions below