Reputation: 1033
I'm writing unit tests and verifying data that should be returned / created / updated ,etc within my JanusGraph backend.
I'm also verifying the results with a Gremlin terminal, but have noticed that entities that have been updated are not reflecting the changes in my terminal. The same thing happens when the vertex is deleted. It's no longer in the Graph, but my gremlin console returns results.
I've had coworkers run the same query's as myself to prove that the values are inconsistent. Is there a way to sync Gremlin with the actual values in the Graph?
EDIT. My code is committing. I'm just using tinkerpop to verify the data.
Upvotes: 0
Views: 204
Reputation: 68
JanusGraph have something called Transactional Scope. According to this concept,
All graph elements (vertices, edges, and types) are associated with the transactional scope in which they were retrieved or created. Under TinkerPop’s default transactional semantics, transactions are automatically created with the first operation on the graph and closed explicitly using commit() or rollback(). Once the transaction is closed, all graph elements associated with that transaction become stale and unavailable. However, JanusGraph will automatically transition vertices and types into the new transactional scope as shown in this example:
graph = JanusGraphFactory.open("berkeleyje:/tmp/janusgraph")
juno = graph.addVertex() //Automatically opens a new transaction
graph.tx().commit() //Ends transaction
juno.property("name", "juno") //Vertex is automatically transitioned
Edges, on the other hand, are not automatically transitioned and cannot be accessed outside their original transaction. They must be explicitly transitioned:
e = juno.addEdge("knows", graph.addVertex())
graph.tx().commit() //Ends transaction
e = g.E(e).next() //Need to refresh edge
e.property("time", 99)
May be this is happening with you.
Upvotes: 2