neo4j/community — Issue #156: Transaction API semantic issue + implementation bug
Author: alphazero
Created: 2011-12-29 03:40:12+00:00
State: open

**Issue**

The Transaction API semantics are (independent of documentation) somewhat problematic. One may start a transaction and never issue either success or failure. and finish() will happily accept this course of events It just happens I was hacking on an idea so it was a one class affair that allowed quick retrace of the/my programmer error. But in a large codebase, this issue

**suggestions**

- WARN log it, at the minimum: "WARN nop-TX completion"
- int Transaction#finish() // non-zero error, etc. is useful
- void Transaction#finish() throws InvalidTransaction (>> RuntimeException), is imo best

**bug**

There is also a bug (regardless of API semantics and programmer error):

Transaction tx = gdb.beginTx();
Node node = gdb.createNode();
tx.finish();

// this node claims it belongs to the gdb in question
// it also claims to have a valid id (e.g. 1 in a fresh db)
//
assert node.getGraphDatabase().equals(gdb) : "node's gdb is not the gdb";

// but the gdb instance claims ignorance of this assertion :)
// try with an empty db and note the disowned node@1 ...
//
Iterable nit = GlobalGraphOperations.at(gdb).getAllNodes();
for(Node n : nit)
System.out.format("n.id: %s\n", n.getId());

--

neo4j community (download) @ neo4j-community-1.6.M02