neo4j-ogm
neo4j-ogm copied to clipboard
Session-bound cache breaks Read Committed Isolation Level
Setup
- Neo4j OGM 3.2.31
- In Process Neo4j 4.4.4 Enterprise (with BOLT port exposed)
- Spring Boot 2.6.4
- Spring Data Neo4j 5.3.9.RELEASE (connected using this example)
Issue
Neo4j's isolation level is Read Committed. If I start a transaction, subsequent MATCH queries within the same transaction may show different results if the data in the database changes in the meantime. OGM behaves differently. As long as there is no write operation from within the same transaction or an active call to session.clear(), it does not reflect changes from the database for entities that have already been loaded before within the same transaction.
Reproduction case:
- 3 Threads T1, T2, T3 perform the following operations
- T1 starts a transaction, creates an entity and commits the transaction
- T2 starts a transaction and reads the entity that was created by T1; T2 keeps its transaction running
- T3 starts a transaction, modifies the entity in the DB and commits the transaction
- T2 reads the same entity again
-> In step 5. OGM returns the object from its cache and does not realize the entity was changed in the database. I query all people with last name Miller and OGM suddenly presents me people with last name Doe.
Hi @nioertel
First of all, your analysis is correct. However, those are the semantics of Neo4j-OGM and we have no plans on changing them.
No recent activity. Closing this now.