I'm using Spring Framework and Spring Data and I need to lock specific row in a database table while processing is done, so nobody else can access the data and change it until the process is finished. At the same time, I'm running multiple instances of the same application.
Will the usage of PESSIMISTIC_WRITE
lock the specific row in a database in a such way that, when one application instance accesses that row, it will be inaccessible to other instances of the same application which could try to access the same row from the database at the same time?
There is a question discussing the differences between lock types, PESSIMISTIC_READ
vs. PESSIMISTIC_WRITE
. To be clear, I'm not asking for the differences between them, I'm asking for the scope of the PESSIMISTIC_WRITE
and how will obtaining that lock from one application instance affect other applications instances which could try to read and update the same row in the database table.