I'm trying to understand and use spring transactional isolation level. I need to maximize concurrency of my application and I just need to be careful about dirty reads. Phantom read and other scenarios are really not required to be taken care. So decided to use Isolation.READ_COMMITTED for one of the most used transactional methods of my application. As per spring documenttion:
This level only prohibits a transaction from reading a row with uncommitted changes in it.
So here is the scenario I am facing that i believe is little different than above statement.
criticalMethod(customeId):
- Read data of customer from table1
- make some decision
- add a new row for that customer in table1
- carry on some long processing.....
So when this method gets called in parallel for two completely independently customers c1 and c2, if for c1 was on step 4 when method for c2 gets called. So my method call for c2 blocks at step 1 util method call for c1 finishes.
I simulated this scenario with eclipse debugging. I am able to query data from my database side on table1 for customer c2. As per the above documentation of spring, my second method call should not get blocked.
Am I missing something?
Here is my technology stack:
- Java: 8
- Spring : 4.3.7
- Database: SqlServer 2012
- ORM: Mybatis 3.4.2
- mybatis spring version : 1.3.1