Reputation: 1743
While experimenting with Neo4j graphs I found that there can be only one transaction with a "given transaction name" at any given time. Is it true or am I making some mistake in understanding transactions?
e.g. consider following code:
updateNode(Node node){
Transaction txNode = graphDB.beginTx();
try{
//do some operations on node
txNode.success();
}finally{
txNode.finish();
}
}
If I have multiple processes or multiple threads running on same "graphDB", where each process/thread can call above function for different nodes, will it be like only one transaction with name "txNode", which can cause problems between threads / processes?
I think it is because, transactions are created at graph level, so each transaction (required to be used in parallel) must have different name.
Please clarify if I'm wrong...
And if I'm correct, how can we tackle such situations? How can we create transactions with different names for each such thread / process running in parallel?
Upvotes: 1
Views: 903
Reputation: 19373
The transaction "txNode" is just your variable name for the instance of the transaction created. Every time your method executes, a new transaction is created. The same one isn't re-used. You don't have to worry about distinguishing between transactions at the application level.
Upvotes: 1