Details
Description
This code doesn't account for the excess removed from tailBulk. This can cause the code to set incorrect bulk values when there are multiple traversers in the tail buffer.
I observed this behavior intermittently in TitanGraph (https://github.com/thinkaurelius/titan/pull/1312), which doesn't allow user defined ids, so the ordering of the traversers in the TraverserSet is a lot more random than the unit tests using TinkerGraph.
This issue is reproducible with TinkerGraph (master/3.2.1). Instead of loading from one of the data files, manually create the graph with the ids in inverted order.
graph = TinkerGraph.open(); // graph.io(IoCore.gryo()).readGraph("tinkerpop-modern.kryo"); final Vertex v1 = graph.addVertex(T.id, 6L, T.label, "person", "name", "marko", "age", 29); final Vertex v2 = graph.addVertex(T.id, 5L, T.label, "person", "name", "vadas", "age", 27); final Vertex v3 = graph.addVertex(T.id, 4L, T.label, "software", "name", "lop", "lang", "java"); final Vertex v4 = graph.addVertex(T.id, 3L, T.label, "person", "name", "josh", "age", 32); final Vertex v5 = graph.addVertex(T.id, 2L, T.label, "software", "name", "ripple", "lang", "java"); final Vertex v6 = graph.addVertex(T.id, 1L, T.label, "person", "name", "peter", "age", 35); v1.addEdge("knows", v2, "weight", 0.5d); v1.addEdge("knows", v4, "weight", 1.0d); v1.addEdge("created", v2, "weight", 0.4d); v4.addEdge("knows", v5, "weight", 1.0d); v4.addEdge("knows", v3, "weight", 0.4d); v6.addEdge("knows", v3, "weight", 0.2d); if (graph.features().graph().supportsTransactions()) graph.tx().commit(); final GraphTraversalSource g = graph.traversal(); String result = g.V().repeat(both()).times(3).tail(7).count().next().toString(); boolean success = "7".equals(result);
The fix is this:
if (excess > 0) { oldest.setBulk(oldestBulk-excess); // Account for the loss of excess in the tail buffer this.tailBulk -= excess; }
Attachments
Issue Links
- is duplicated by
-
TINKERPOP-1393 RepeatUnrollStrategy alters traversal behavior
- Closed
- links to
Great. If you have a fix, please provide a PR that also has an added test case to TailTest so we know things are solid.