Database Reference
In-Depth Information
robust and isn't likely to generate deadlocks, you'll need some understanding of Neo4j's
transaction management model.
We'll start by examining how transactions work and the default isolation level offered by
Neo4j. After that we'll look at how you can use explicit locks to obtain stronger isolation
guarantees.
7.2.1. Transaction semantics
Let's examine some of the guarantees that ACID transactions offer and how they're
handled in Neo4j.
Transactions and thread locality
EachnewtransactioninNeo4jisboundtothecurrentthread.Forthatreason,it'sabsolutely
essential to ensure that each transaction finishes properly and that each transactional con-
text is properly cleaned up.Otherwise, the next transaction to runonthe same thread could
potentially be affected by the stale context, resulting in erroneous and inconsistent out-
comes. The coding idioms shown in this chapter will help you avoid such problems.
Durability
Durability refers to writing data to permanent storage in a way that survives restarting the
database. If a transaction succeeds, you can assume that the data has been persisted to the
disk in a durable manner.
Underthecovers,though,Neo4jmaintainsatransactionlogthatgetsupdatedandpersisted
for each successful transaction with mutating operations. When it reaches a certain size, or
when the database shuts down, the transaction log gets flushed and the appropriate store
files get updated on the disk. Chapter 11 discusses the role of the transaction log.
Isolation levels and Neo4j Locks
A number of database management systems implement locking mechanisms to manage
concurrent access to the same database resources. Neo4j transactions are governed by dis-
tinct read and write locks on each graph resource (nodes and relationships).
Search WWH ::




Custom Search