Jason Plurad created TINKERPOP-1379:
---------------------------------------

             Summary: unaccounted excess in TailGlobalStep
                 Key: TINKERPOP-1379
                 URL: https://issues.apache.org/jira/browse/TINKERPOP-1379
             Project: TinkerPop
          Issue Type: Bug
          Components: process
    Affects Versions: 3.2.1
            Reporter: Jason Plurad


https://github.com/apache/tinkerpop/blob/master/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/TailGlobalStep.java#L71-L74

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, 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.
{noformat}
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);
{noformat}

The fix is this:
{noformat}
if (excess > 0) {
    oldest.setBulk(oldestBulk-excess);
    // Account for the loss of excess in the tail buffer
    this.tailBulk -= excess;
}
{noformat}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to