thinkaurelius / titan

Distributed Graph Database
http://titandb.io
Apache License 2.0
5.25k stars 1.01k forks source link

NPE when using repeat step with query.batch=true #1169

Open twilmes opened 9 years ago

twilmes commented 9 years ago

Version: Titan 1.0.0 This query works without issue with query.batch off.

Steps to reproduce using toy data with the relevant portion of the exception.

gremlin> graph = TitanFactory.open('./conf/titan-cassandra.properties')
==>standardtitangraph[cassandrathrift:[127.0.0.1]]
gremlin> g = graph.traversal()
==>graphtraversalsource[standardtitangraph[cassandrathrift:[127.0.0.1]], standard]
gremlin> v1 = graph.addVertex('id', 1)
==>v[4192]
gremlin> v2 = graph.addVertex('id', 2)
==>v[4096]
gremlin> v1.addEdge('knows', v2)
==>e[170-38g-28lx-35s][4192-knows->4096]
gremlin> g.tx().commit()
gremlin> g.V().has('id', 1).emit().repeat(out('knows'))
10:10:49 WARN  com.thinkaurelius.titan.graphdb.transaction.StandardTitanTx  - Query requires iterating over all vertices [(id = 1)]. For better performance, use indexes
==>v[4192]
java.lang.NullPointerException
Display stack trace? [yN] y
java.lang.NullPointerException
    at com.thinkaurelius.titan.graphdb.tinkerpop.optimize.TitanVertexStep.flatMap(TitanVertexStep.java:95)
    at org.apache.tinkerpop.gremlin.process.traversal.step.map.FlatMapStep.processNextStart(FlatMapStep.java:47)
    at com.thinkaurelius.titan.graphdb.tinkerpop.optimize.TitanVertexStep.processNextStart(TitanVertexStep.java:88)
    at org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep.hasNext(AbstractStep.java:140)
    at org.apache.tinkerpop.gremlin.process.traversal.step.util.ExpandableStepIterator.next(ExpandableStepIterator.java:54)
    at org.apache.tinkerpop.gremlin.process.traversal.step.branch.RepeatStep$RepeatEndStep.standardAlgorithm(RepeatStep.java:230)
    at org.apache.tinkerpop.gremlin.process.traversal.step.util.ComputerAwareStep.processNextStart(ComputerAwareStep.java:47)
    at org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep.hasNext(AbstractStep.java:140)
    at org.apache.tinkerpop.gremlin.process.traversal.step.branch.RepeatStep.standardAlgorithm(RepeatStep.java:143)
    at org.apache.tinkerpop.gremlin.process.traversal.step.util.ComputerAwareStep.processNextStart(ComputerAwareStep.java:47)
    at org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep.hasNext(AbstractStep.java:140)
    at org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversal.hasNext(DefaultTraversal.java:117)
effyteva commented 9 years ago

Hi,

I think this error might be related to: https://groups.google.com/forum/#!topic/gremlin-users/dLr31SyRuk0. It seems as if .emit().repeat() doesn't work on a multi-threaded environment at all, which might be the source of the query.batch issue as well.

Effy

sharpau commented 9 years ago

I have experienced this issue in 1.0 as well. Basically can't take advantage of query.batch until it is fixed.

twilmes commented 9 years ago

I posted a question related to this on the TinkerPop dev list to get some insight into possible repeat step interactions with graph provider optimizations (multi query in this case) and got some good feedback.

First thing first, I'm going to see how Titan runs the TinkerPop test suite and see if I can get it to run with this query.batch=true. I know there are Titan specific tests with batching on, but I'm assuming since this NPE doesn't happen during the full TP3 test run, it may not be enabled for that case.

graben1437 commented 8 years ago

Any progress in investigating this problem ?

twilmes commented 8 years ago

I added runners for the TP 3 tests with query.batch=true with this PR: https://github.com/thinkaurelius/titan/pull/1190

I was planning on using that as a jumping off point to do further analysis because it uncovered around 60 or so failures when I ran it that seem to be a result of the multiquery optimization steps.