janusgraph
janusgraph copied to clipboard
Wrong result for count query when mixed index optimization used
For confirmed bugs, please report:
- Version: 0.6.0
- Storage Backend: all
- Mixed Index Backend: all
- Link to discussed bug:
- Expected Behavior: correct answer
- Current Behavior: in tx element not affected in count
- Steps to Reproduce:
gremlin> graph = JanusGraphFactory.build().
......1> set("storage.backend","berkeleyje").
......2> set("storage.directory","/tmp/graph").
......3> set("index.search.backend","lucene").
......4> set("index.search.directory","/tmp/graph/").
......5> open()
==>standardjanusgraph[berkeleyje:/tmp/graph]
gremlin> g = graph.traversal()
==>graphtraversalsource[standardjanusgraph[berkeleyje:/tmp/graph], standard]
gremlin>
gremlin> mgmt = graph.openManagement()
==>org.janusgraph.graphdb.database.management.ManagementSystem@2506e949
gremlin> p1 = mgmt.makePropertyKey('p1').cardinality(Cardinality.SINGLE).dataType(String.class).make()
==>p1
gremlin> mgmt.buildIndex("string", Vertex.class).addKey(p1, Mapping.STRING.asParameter()).buildMixedIndex("search")
==>string
gremlin> mgmt.commit()
==>null
gremlin> graph.traversal().addV().property("p1","v")
==>v[4256]
gremlin> graph.tx().commit()
==>null
gremlin> graph.traversal().V().has("p1").count().profile()
==>Traversal Metrics
Step Count Traversers Time (ms) % Dur
=============================================================================================================
JanusGraphMixedIndexCountStep 1 1 59.540 100.00
MixedIndexCountQuery 58.041
\_query=[(p1 <> null)]:string
>TOTAL - - 59.540 -
gremlin> graph.traversal().V().has("p1").count()
==>1
gremlin> graph.traversal().addV().property("p1","v2")
==>v[4168]
gremlin> graph.traversal().V().has("p1").count()
==>1 <---- Wrong
gremlin> graph.traversal().withoutStrategies(org.janusgraph.graphdb.tinkerpop.optimize.strategy.JanusGraphMixedIndexCountStrategy.class).V().has("p1").count()
==>2 <---- Correct
gremlin> graph.traversal().withoutStrategies(org.janusgraph.graphdb.tinkerpop.optimize.strategy.JanusGraphMixedIndexCountStrategy.class).V().has("p1").count().profile()
==>Traversal Metrics
Step Count Traversers Time (ms) % Dur
=============================================================================================================
JanusGraphStep([],[p1.neq]) 2 2 1.232 88.01
constructGraphCentricQuery 0.238
GraphCentricQuery 0.753
\_condition=(p1 <> null)
\_orders=[]
\_isFitted=true
\_isOrdered=true
\_query=[(p1 <> null)]:string
\_index=string
\_index_impl=search
CountGlobalStep 1 1 0.167 11.99
>TOTAL - - 1.400 -
gremlin>
Yeah, I guess I forgot to count uncommitted transactions in JanusGraphMixedIndexCountStep :(
Yeah, I guess I forgot to count uncommitted transactions in
JanusGraphMixedIndexCountStep:(
Any update for this issue?
@TCGOGOGO
I might be able to take a look at some time but it has been four years since I introduced the feature, and I have already forgot about most of the code. Would you be interested in contributing a bug fix?