Thanks, Michael. I'm using an embedded graph database with the java api. I think I fixed it with the "synchronized" key word on the method.
On Wed, Jun 15, 2016 at 8:53 PM, 'Michael Hunger' via Neo4j < neo4j@googlegroups.com> wrote: > You have to create a lock to make that an exclusive operation. > > Best with cypher's MERGE and a unique constraint which take care of > creating that index lock for you: > > create constraint on t:Top assert t.id is unique; > > MERGE (t:Top {id:123}) RETURN t; > > > On Wed, Jun 15, 2016 at 12:27 AM, David Starkweather <stark...@gmail.com> > wrote: > >> Hell all, >> >> Thanks for all your hard work in delivering such a great product. >> >> I have an application built on top of neo4j using the java api for >> v3.0.1. It requires finding a "top" node first at the beginning of every >> one of my >> graph operations. This top node serves as the start of my graph db. I >> noticed an earlier edition of neo4j used a >> reference node from which to retrieve the graph. Since that apparently >> is no longer a feature in newer releases, >> I chose to label this top node with a "TOP" label, and then simply >> retrieve this node using findNode method. Now, this method works >> great so long as the testing is done in a single thread. However, when >> used in multiple threads, it occasionally gets a >> MultipleFoundException thrown when invoking this findNode method. I feel >> quite certain that my code only creates one top >> node at a time, and whenever it creates a new top node, it deletes the >> old top node and always does so within a single transaction block. >> However, if findNodes() is used instead, I find that two nodes can be >> counted by iterating through the ResourceIterator (with hasNext/getNext). >> (Although I'm not sure if they are both viable active nodes.) >> >> Is this the best technique for maintaining such a single top node? Or is >> there a more preferred way? >> >> Does the ResourceIterator that is returned ever contain outdated entries? >> (I notice the javadocs for this class is missing.) >> >> I would appreciate any ideas you may have on this. >> >> Thanks again. >> David Starkweather >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Neo4j" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to neo4j+unsubscr...@googlegroups.com. >> For more options, visit https://groups.google.com/d/optout. >> > > -- > You received this message because you are subscribed to the Google Groups > "Neo4j" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to neo4j+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Neo4j" group. To unsubscribe from this group and stop receiving emails from it, send an email to neo4j+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.