Thanks Mattias & David.
Yes, am doing tx.success() and tx.finish() when I commit.
I also noticed that once I get IllegalStateException, I cant search for any
nodes from the graph index.
Here's my code snippet when create,index and commit the nodes & also when
delete the nodes:
Create nodes:
GraphDatabaseService neo = neoFactory.getNeoService();
Index indexService = neoFactory.getIndexService();
Transaction tx = neo.beginTx();
try
{
for (Row row: resultRows.values())
{
try
{
Node newNode = neo.createNode();
for(String key: row.getKeys())
{
String value = row.getValue(key);
newNode.setProperty(key,value);
indexService.add( newNode, key.toLowerCase(), value.toLowerCase() );
indexService.add( newNode, "fulltext", value.toLowerCase() );
}
}catch(Exception e)
{
e.printStackTrace();
}
}
tx.success();
}
finally
{
tx.finish();
}
----------------------------------------------------
Delete nodes:
try {
GraphDatabaseService neo = neoFactory.getNeoService();
Index indexService = neoFactory.getIndexService();
Transaction tx = neo.beginTx();
List<Node> nodes = getNodeList(indexService.query( index, value ));
System.out.println("Found Removable Nodes:"+nodes.size());
for (Node n: nodes)
{
for (Iterator it=n.getRelationships().iterator(); it.hasNext(); )
{
Relationship r = (Relationship)it.next();
try{
r.delete();
}catch (Exception e) {
e.printStackTrace();
}
}
Map<String, String> props = getNodesProperties(n);
for (String key: props.keySet())
{
String val = props.get(key);
indexService.remove(n, key, val);
}
try
{
n.delete();
} catch (Exception e)
{
e.printStackTrace();
}
}
tx.success();
}
finally
{
tx.finish();
}
On Thu, Feb 17, 2011 at 1:23 AM, David Montag <
[email protected]> wrote:
> John,
>
> Are you doing tx.success() and tx.finish() when you commit? If so, then you
> likely already have an open transaction for that thread.
>
> If you start a new transaction while already in an open transaction, you
> will get a dummy transaction. It will not do anything when you commit it
> successfully, but if it fails, the parent transaction will fail. The data
> in
> the nested transaction only gets committed when the parent transaction
> commits. So if you've lost the reference to the top-level transaction,
> that's an issue.
>
> Also, if you'd like to share the code, I'd be glad to have a look at it.
>
> David
>
> On Wed, Feb 16, 2011 at 10:00 PM, John Howard <[email protected]>
> wrote:
>
> > We found this strange behaviour with regard to transactions ( we use
> > neo1.3-SNAPSHOT)
> > Here are the steps in our application:
> >
> > 1. created,indexed and commited 10 nodes successfully
> > 2. created, indexed and commited 40 nodes successfully
> > 3. created, indexed and commited 900 nodes successfully
> > 4. we found some app specific mistake in the step 3. So we removed
> indexes,
> > deleted 900 nodes and commited successfully.
> > 5. we tried to query those deleted nodes just to confirm whether delete
> was
> > successful.
> > 6. we were able to search for 900 (deleted)nodes from the index, and when
> > we
> > tried to access a property of a (deleted) node, it threw the following
> > exception:
> > java.lang.IllegalStateException: Node[7599] has been deleted in this tx
> > at
> >
> >
> org.neo4j.kernel.impl.core.LockReleaser.getCowPropertyRemoveMap(LockReleaser.java:445)
> > at
> >
> >
> org.neo4j.kernel.impl.core.NodeManager.getCowPropertyRemoveMap(NodeManager.java:898)
> > at
> > org.neo4j.kernel.impl.core.Primitive.getPropertyKeys(Primitive.java:99)
> > at
> > org.neo4j.kernel.impl.core.NodeProxy.getPropertyKeys(NodeProxy.java:129)
> > at
> > neopoc.data.util.graphManager.getNodesProperties(graphManager.java:771)
> >
> > 7. As a result of the above exception, it rolled back step 1 & 2 as well.
> > So
> > we lost all the nodes.
> >
> > My suspicion is, even though we committed successfullly in the steps 1,
> 2,
> > 3, 4, they were never internally committed. May be some kind of
> > differed/lazy commit and not immediate commit.
> >
> > Thank you for your assistance.
> >
> > -
> > _______________________________________________
> > Neo4j mailing list
> > [email protected]
> > https://lists.neo4j.org/mailman/listinfo/user
> >
>
>
>
> --
> David Montag
> Neo Technology, www.neotechnology.com
> Cell: 650.556.4411
> [email protected]
> _______________________________________________
> Neo4j mailing list
> [email protected]
> https://lists.neo4j.org/mailman/listinfo/user
>
_______________________________________________
Neo4j mailing list
[email protected]
https://lists.neo4j.org/mailman/listinfo/user