Last active
September 4, 2015 18:03
-
-
Save helgridly/0c153a79fa746fa3e266 to your computer and use it in GitHub Desktop.
Orient 2.1.1 leaky transactions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val dbName = "blah" | |
val factory = new OrientGraphFactory("memory:"+dbName, "admin", "admin") | |
factory.setThreadMode(THREAD_MODE.MANUAL) | |
factory.setAutoStartTx(false) | |
factory.setUseClassForEdgeLabel(false) | |
factory.setUseLightweightEdges(true) | |
//Initial setup of DB. | |
val graph = factory.getTx | |
graph.begin() | |
val root = graph.asInstanceOf[OrientGraph].addVertex(s"class:Test", Map.empty[String, Object].asJava) | |
val v2 = graph.asInstanceOf[OrientGraph].addVertex(s"class:OtherSide", Map.empty[String, Object].asJava) | |
root.addEdge("foo", v2) | |
graph.commit() | |
new Thread(new Runnable { | |
def run() { | |
//Thread switches out the vertex on the other side of the "foo" edge. | |
val graph = factory.getTx | |
graph.begin() | |
println("t1 open") | |
Thread.sleep(1000) | |
val root = graph.asInstanceOf[OrientGraph].getVerticesOfClass("Test").head | |
root.getEdges(Direction.OUT, "foo").map( v => graph.removeVertex(v.getVertex(Direction.IN)) ) | |
println("t1 removed vtx") | |
val v2 = graph.asInstanceOf[OrientGraph].addVertex(s"class:OtherSide", Map.empty[String, Object].asJava) | |
root.addEdge("foo", v2) | |
println("t1 readded vtx") | |
graph.commit() | |
} | |
}).start() | |
Thread.sleep(500) | |
val graph2 = factory.getTx | |
graph2.begin() | |
//If I move this line after the 550 sleep (i.e. after t1 commits), it's fine. | |
val root2 = graph2.asInstanceOf[OrientGraph].getVerticesOfClass("Test").head | |
println("t2 got root") | |
Thread.sleep(550) | |
println("t2 looking for verts") | |
//This assertion fails. | |
assert( root2.getEdges(Direction.OUT, "foo").size > 0 ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Since this is a concurrency issue, you might need to adjust the timings to repro this. The printlns should appear in the following order: