sk0x50 commented on issue #12540:
URL: https://github.com/apache/ignite/issues/12540#issuecomment-3743650646

   At first glance, your code appears to be correct.
   You are trying to read data (using read transaction(P, RC)) in parallel with 
committing a write transaction (write transaction(P, RC)), 
   but the "problem" is that the read transaction(P, RC) (even though it is a 
pessimistic one) does not acquire a lock!
   
   I prepared the following table that would help to understand how it works in 
Apache Ignite 2:
   
   | TX operation(s) | X - concurrency, Y - isolation | Pessimistic, 
Read_Committed | Pessimistic, Repeatable_Read & Serializable | Optimistic, 
Read_Committed | Optimistic, Repeatable_Read | Optimistic, Serializable |
   | --- | --- | --- | --- | --- | --- | --- |
   | `tx.start(X, Y)` |  |  | | | |
   | Read data within TX `Account acc = cache.get(accId);` | Inconsistent read 
possible | Yes | No | Yes | Yes | No* |
   | Read data within TX `Account acc = cache.get(accId);` | Read value cached 
in tx (subsequent reads return the same value) | No | Yes | No | Yes | Yes |
   | Read data within TX `Account acc = cache.get(accId);` | Lock acquired on 
read | No | Yes | No | No | No |
   | Make changes `acc.update(100);` |  |  |  |  |  |  |
   | Store the updated data `cache.put(accId, acc);` | Lock obtained on write | 
Yes | N/A (prelocked) | No | No | No |
   | Commit `tx.commit();` | Lock acqured on commit | N/A (prelocked) | N/A 
(prelocked) | Yes | Yes | Yes** |
   | Commit `tx.commit();` | Consistency validated on commit | No | No | No | 
No | Yes |
   
   (*) Even though an inconsistent read is possible within the transaction 
logic, it will be validated during the commit phase, and the entire transaction 
will be rolled back. 
   (**) Even though the locks are acquired on the commit phase, in `OPTIMISTIC 
SERIALIZABLE` mode, the locks are not acquired sequentially. Only individual 
locks are acquired in parallel. This means that multiple entries are not locked 
together, and deadlocks are not possible.
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to