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?