2

Let's imagine we have an application that has 3 instances and 1 DB (there might be more synchronized DBs) and we have a withdraw method that basically selects the account from account table with @Lock annotation at Spring Data JPA Repository layer and makes the necessary changes in a transaction by using @Transactional. If another request is arrived to another instance to do the same operation on the same account at the same time, will it be able to get the lock or the created lock in instance_1 is a db level lock so that another instance cannot get another lock on the same row ?

If it is a db level lock, how can we manage those locks among multiple synchronized DBs which are not master-slave, all of them are master?

1
  • If the data repositories (such as databases, queues, etc.) implement JTA (and is enabled), then the transaction will automatically span all the data repositories. Commented Apr 20, 2023 at 17:13

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.