[Neo4j] Transactions and creating new nodes

2010-07-16 Thread Dmitrii Dimandt
It's possible that I haven't looked to hard, but my question is this:

A typical scenario for a site is to create a user. Before you create a user, 
you do this in a transaction:

- begin transaction
- check if such a user (node in neo4j) exists
- if it exists, end transaction
- return
- if such a user doesn't exist, create a new user(node)
- end transaction
- return

Can a separate thread create a new node while I'm in a transaction? If it can, 
how can I prevent that thread from creating a user with the user name I'm about 
to create?
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] Transactions and creating new nodes

2010-07-16 Thread David Montag
Hi Dmitrii,

Separate threads can create nodes in different transactions, yes. You could
lock around the user creation code you included in order to keep user
creation atomic.

David

On Fri, Jul 16, 2010 at 10:59 AM, Dmitrii Dimandt dmitr...@gmail.comwrote:

 It's possible that I haven't looked to hard, but my question is this:

 A typical scenario for a site is to create a user. Before you create a
 user, you do this in a transaction:

 - begin transaction
 - check if such a user (node in neo4j) exists
- if it exists, end transaction
- return
 - if such a user doesn't exist, create a new user(node)
 - end transaction
 - return

 Can a separate thread create a new node while I'm in a transaction? If it
 can, how can I prevent that thread from creating a user with the user name
 I'm about to create?
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user

___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] Transactions and creating new nodes

2010-07-16 Thread Dmitrii Dimandt
Thank you for clarification!




 Hi Dmitrii,
 
 Separate threads can create nodes in different transactions, yes. You could
 lock around the user creation code you included in order to keep user
 creation atomic.
 
 David
 
 On Fri, Jul 16, 2010 at 10:59 AM, Dmitrii Dimandt dmitr...@gmail.comwrote:
 
 It's possible that I haven't looked to hard, but my question is this:
 
 A typical scenario for a site is to create a user. Before you create a
 user, you do this in a transaction:
 
 - begin transaction
 - check if such a user (node in neo4j) exists
   - if it exists, end transaction
   - return
 - if such a user doesn't exist, create a new user(node)
 - end transaction
 - return
 
 Can a separate thread create a new node while I'm in a transaction? If it
 can, how can I prevent that thread from creating a user with the user name
 I'm about to create?
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user
 
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user

___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user