Repository: thinkaurelius/titan

Issue #921: Traversal and Transaction - Titan 0.9M1
Created: 2015-01-09T20:58:34Z
Reported here in the mailing list:
https://groups.google.com/d/msg/aureliusgraphs/JgMlZsuXhgg/slJF-qrpngMJ
but something i discovered a while back on my own and discussed with @dalaro - not sure that we came to a solution or if this is fixed.  i figured i would create an issue to prevent forgetting about it again.
it's pretty easy to recreate the problem:
gremlin> :remote connect tinkerpop.server conf/remote.yaml
==>Connected - localhost/127.0.0.1:8182
gremlin> :> g
==>standardtitangraph[berkeleyje:db/berkeley]
gremlin> :> g.addVertex("name","stephen")
==>v[256]
gremlin> :> g.V().count()
==>1
gremlin> :> g.V()
==>v[256]
gremlin> :> g.V().values("name")
==>stephen

all works as expected - it can clearly serialize all of that.  the use of has triggers this:
gremlin> :> g.V().has("name","stephen")
WARN  io.netty.channel.DefaultChannelPipeline  - An exceptionCaught() event was fired, and it reached at the tail of the pipeline. It usually means the last handler in the pipeline did not handle the exception.
java.lang.NullPointerException
    at com.tinkerpop.gremlin.driver.Handler$GremlinResponseHandler.channelRead0(Handler.java:45)
    at com.tinkerpop.gremlin.driver.Handler$GremlinResponseHandler.channelRead0(Handler.java:21)
    at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319)
    at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319)
    at com.tinkerpop.gremlin.driver.handler.WebSocketClientHandler.channelRead0(WebSocketClientHandler.java:72)
    at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319)
    at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319)
    at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:163)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319)
    at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:787)
    at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:130)
    at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354)
    at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116)
    at java.lang.Thread.run(Thread.java:745)
Response iteration and serialization exceeded the configured threshold for request [[RequestMessage{, requestId=a8d487f8-935b-478e-898a-4c45a60aefa6, op='eval', processor='', args={gremlin=g.V().has("name","stephen"), batchSize=64}}, [TitanGraphStep([[name,eq,stephen]])]]] - Operation cannot be executed because the enclosing transaction is closed

This could be a problem in Gremlin Server and nothing to do with the Titan implementation.

Duplicate issue #871: Inconsistent Transactional Scopes for Traversal
Created: 2014-12-04T13:32:02Z
Certain traversals seem to execute within different scopes.  This causes problems for Gremlin Server, but also might yield some weirdness for folks in other contexts.  You can recreate the issue from the console pretty easily.  The following sets up the graph:
gremlin> g = TitanFactory.open("conf/titan-berkeleydb.properties")
==>standardtitangraph[berkeleyje:/home/smallette/jvm/titan-console-0.9.0-M0/conf/db/berkeley]
gremlin> g.addVertex("name","stephen")
==>v[256]
gremlin> g.tx().commit()
==>null
gremlin> g.V()
==>v[256]
gremlin> g.V().filter{it.get().value('name')=='stephen'}
==>v[256]
gremlin> g.V().has('name','stephen')
==>v[256]

That all works nicely, but if i do a g.tx().rollback() my Traversal is invalidated:
gremlin> t=g.V().filter{it.get().value('name')=='stephen'};null
==>null
gremlin> g.tx().rollback()
==>null
gremlin> t
==>v[256]
gremlin> t = g.V().has('name','stephen');null
==>null
gremlin> g.tx().rollback()
==>null
gremlin> t
Operation cannot be executed because the enclosing transaction is closed
Display stack trace? [yN] y
java.lang.IllegalStateException: Operation cannot be executed because the enclosing transaction is closed
    at com.thinkaurelius.titan.graphdb.transaction.StandardTitanTx.verifyOpen(StandardTitanTx.java:270)
    at com.thinkaurelius.titan.graphdb.transaction.StandardTitanTx.getRelationType(StandardTitanTx.java:845)
    at com.thinkaurelius.titan.graphdb.query.QueryUtil.getType(QueryUtil.java:64)
    at com.thinkaurelius.titan.graphdb.query.QueryUtil.constraints2QNF(QueryUtil.java:177)
    at com.thinkaurelius.titan.graphdb.query.graph.GraphCentricQueryBuilder.constructQuery(GraphCentricQueryBuilder.java:193)
    at com.thinkaurelius.titan.graphdb.query.graph.GraphCentricQueryBuilder.vertices(GraphCentricQueryBuilder.java:140)
    at com.thinkaurelius.titan.graphdb.tinkerpop.optimize.TitanGraphStep.generateTraversers(TitanGraphStep.java:45)
    at com.tinkerpop.gremlin.process.graph.strategy.TraverserSourceStrategy.lambda$apply$355(TraverserSourceStrategy.java:50)
    at com.tinkerpop.gremlin.process.graph.strategy.TraverserSourceStrategy$$Lambda$25/1286437308.accept(Unknown Source)
    at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
    at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)
    at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1374)
    at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:512)
    at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:502)
    at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
    at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
    at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418)
    at com.tinkerpop.gremlin.process.graph.strategy.TraverserSourceStrategy.apply(TraverserSourceStrategy.java:50)
    at com.tinkerpop.gremlin.process.util.DefaultTraversalStrategies.lambda$apply$451(DefaultTraversalStrategies.java:41)
    at com.tinkerpop.gremlin.process.util.DefaultTraversalStrategies$$Lambda$10/700546109.accept(Unknown Source)
    at java.util.ArrayList.forEach(ArrayList.java:1249)
    at com.tinkerpop.gremlin.process.util.DefaultTraversalStrategies.apply(DefaultTraversalStrategies.java:41)
    at com.tinkerpop.gremlin.process.util.DefaultTraversal.applyStrategies(DefaultTraversal.java:44)
    at com.tinkerpop.gremlin.process.util.DefaultTraversal.hasNext(DefaultTraversal.java:76)
    at com.tinkerpop.gremlin.console.Console$_closure3.doCall(Console.groovy:155)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
    at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:324)
    at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:278)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1016)
    at org.codehaus.groovy.tools.shell.Groovysh.setLastResult(Groovysh.groovy:370)
    at org.codehaus.groovy.tools.shell.Groovysh.this$3$setLastResult(Groovysh.groovy)
    at org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:215)
    at org.codehaus.groovy.tools.shell.Groovysh.execute(Groovysh.groovy:159)
    at org.codehaus.groovy.tools.shell.Shell.leftShift(Shell.groovy:121)
    at org.codehaus.groovy.tools.shell.ShellRunner.work(ShellRunner.groovy:93)
    at org.codehaus.groovy.tools.shell.InteractiveShellRunner.super$2$work(InteractiveShellRunner.groovy)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
    at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:324)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1207)
    at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuperN(ScriptBytecodeAdapter.java:130)
    at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuper0(ScriptBytecodeAdapter.java:150)
    at org.codehaus.groovy.tools.shell.InteractiveShellRunner.work(InteractiveShellRunner.groovy:123)
    at org.codehaus.groovy.tools.shell.ShellRunner.run(ShellRunner.groovy:57)
    at org.codehaus.groovy.tools.shell.InteractiveShellRunner.super$2$run(InteractiveShellRunner.groovy)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
    at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:324)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1207)
    at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuperN(ScriptBytecodeAdapter.java:130)
    at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuper0(ScriptBytecodeAdapter.java:150)
    at org.codehaus.groovy.tools.shell.InteractiveShellRunner.run(InteractiveShellRunner.groovy:83)
    at org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:215)
    at com.tinkerpop.gremlin.console.Console.<init>(Console.groovy:99)
    at java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:636)
    at org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:215)
    at com.tinkerpop.gremlin.console.Console.main(Console.groovy:252)

Seems strange that one Traversal works but the other does not.  I'm not sure if other steps trigger this issue.  Gremlin Server would be happy if t could be iterated outside of the transaction it was initialized in (e.g. has should behave like filter in the example above).

Closing comment (2015-01-21T19:11:25Z): Duplicate of #921