Hi,

I've also been wondering about this subject.
According to the Neo4J design guide (
http://wiki.neo4j.org/content/Design_Guide) the factory node and id
generator patterns are the way to implement sequential ID generation.
However, according to this thread, it sounds like in a multi-threaded
environment I have one of two choices:
1. lock the factory node. However this will force transaction
serialization. That's not practical in my app.
2. reducing the granularity of the transactions - in the sense that each
transaction should only contain one node creation (of the same type, i.e.
uses the same factory node). That's not practical for me either, because in
several cases I would like to create more than one node in the same
transaction.
Since the design guide recommends the factory node pattern, I'm wondering
if there's anything I'm missing here, or that I should just avoid this
pattern and use some other ID generation mechanism.

Thanks,
Yaniv


On Thu, Nov 3, 2011 at 11:13 AM, Mattias Persson
<[email protected]>wrote:

> 2011/11/3 Cres <[email protected]>
>
> > This solution would have been ok if I had only one node created from that
> > factory in each transaction.
> >
> > It doesn't matter... after factory.setProperty is run that transaction
> has
> got a write lock on that factory node which is held until the transaction
> committs. The benefit you get from my proposal would be that you make sure
> you read the correct value.
>
>
> > however, as shown in the sample code I posted in the original message, I
> > have multiple nodes created in one transaction, and multiple such
> > transactions in multiple threads.
> > So while the creation of the actual nodes will of course be serialized,
> one
> > thread's transaction will have to wait for the other thread's transaction
> > to
> > finish completely, and so if the first thread has some processing to do
> > between the creation of the first and second nodes, the other third won't
> > be
> > able to create its two nodes in the meanwhile, because the first thread
> > will
> > have the lock on the factory node until the entire transaction completes.
> >
> > I'm looking for a way to do this having the nodes creation serialized but
> > without having the entire transactions serialized, possibly by somehow
> > releasing the lock on the factory node in mid-transaction, or by any
> other
> > method.
> >
> > Thanks again,
> > Ran.
> >
> > --
> > View this message in context:
> >
> http://neo4j-community-discussions.438527.n3.nabble.com/Node-Id-generation-deadlock-tp3473118p3476498.html
> > Sent from the Neo4j Community Discussions mailing list archive at
> > Nabble.com.
> > _______________________________________________
> > Neo4j mailing list
> > [email protected]
> > https://lists.neo4j.org/mailman/listinfo/user
> >
>
>
>
> --
> Mattias Persson, [[email protected]]
> Hacker, Neo Technology
> www.neotechnology.com
> _______________________________________________
> Neo4j mailing list
> [email protected]
> https://lists.neo4j.org/mailman/listinfo/user
>
_______________________________________________
Neo4j mailing list
[email protected]
https://lists.neo4j.org/mailman/listinfo/user

Reply via email to