thinkaurelius / titan

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

titan09 The vertex or type is not associated with this transaction [v[40980496]] #1095

Closed dmill-bz closed 9 years ago

dmill-bz commented 9 years ago

Hey,

I'm using titan09 with gremlin-console M9-RC3. I'm getting an error when I try to create a vertex and then attach another one to it. I don't know if this is an issue or if I'm doing something wrong. Here's how to recreate it:

bin/gremlin.sh 

         \,,,/
         (o o)
-----oOOo-(3)-oOOo-----
plugin activated: tinkerpop.server
plugin activated: tinkerpop.utilities
plugin activated: tinkerpop.tinkergraph
gremlin> :remote connect tinkerpop.server conf/remote.yaml
==>Connected - localhost/127.0.0.1:8182
gremlin> :> g.addV()
==>v[81948880]
gremlin> :> graph.tx().commit()
==>null
gremlin> :> newVertex = g.addV(); g.V(81948880).addOutE("HAS_MIGRATION", newVertex)
The vertex or type is not associated with this transaction [v[49320]]
Display stack trace? [yN] 
org.apache.tinkerpop.gremlin.groovy.plugin.RemoteException: The vertex or type is not associated with this transaction [v[49320]]
    at org.apache.tinkerpop.gremlin.console.groovy.plugin.DriverRemoteAcceptor.submit(DriverRemoteAcceptor.java:112)
    at org.apache.tinkerpop.gremlin.console.commands.SubmitCommand.execute(SubmitCommand.groovy:41)
    at org.codehaus.groovy.tools.shell.Shell.execute(Shell.groovy:101)
    at org.codehaus.groovy.tools.shell.Groovysh.super$2$execute(Groovysh.groovy)
    at sun.reflect.GeneratedMethodAccessor14.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    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.tools.shell.Groovysh.executeCommand(Groovysh.groovy:254)
    at org.codehaus.groovy.tools.shell.Groovysh.execute(Groovysh.groovy:153)
    at org.codehaus.groovy.tools.shell.Shell.leftShift(Shell.groovy:119)
    at org.codehaus.groovy.tools.shell.ShellRunner.work(ShellRunner.groovy:94)
    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:497)
    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:58)
    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:497)
    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:82)
    at org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:215)
    at org.apache.tinkerpop.gremlin.console.Console.<init>(Console.groovy:134)
    at org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:215)
    at org.apache.tinkerpop.gremlin.console.Console.main(Console.groovy:292)

Let me know if you need any extra information.

dmill-bz commented 9 years ago

Ok I've rebuilt TP3 and Titan09 with the current SNAPSHOTS and this seems to work correctly so I'm closing this.

dmill-bz commented 9 years ago

I spoke too soon, I still get this error. I however don't know if it's expected behavior as the following works fine:

newVertex = g.addV(); g.V(81948880).addOutE("HAS_MIGRATION", newVertex).next()

This is a complete guess but it might be TP3 related. Looks like maybe the difference between two expressions is that the first is iterated outside the scope of the transaction and the later within? Again a complete guess on my part. But it reminds me of https://issues.apache.org/jira/browse/TINKERPOP3-109

Might be confirmed from the fact that the following works:

newVertex = g.addV(); otherVertex = g.V(81948880).addOutE("HAS_MIGRATION", newVertex); graph.tx().commit(); otherVertex

Going to reopen on the off chance this is something to look into.

dmill-bz commented 9 years ago

And although

newVertex = g.addV(); g.V(81948880).addOutE("HAS_MIGRATION", newVertex).next()

works fine in the console (Gryo) it throws the following error using the GraphSON serializer:

WARN  org.apache.tinkerpop.gremlin.server.handler.WsGremlinResponseEncoder  - The result [ResponseResult{data=[e[17e-3bk-5jp-36w][4304-HAS_MIGRATION->4136]], meta={}}] in the request e8315923-d98d-4035-a34f-c8d8941114e5 could not be serialized and returned.
java.util.concurrent.ExecutionException: java.lang.NoClassDefFoundError: org/apache/tinkerpop/gremlin/util/StreamFactory
    at java.util.concurrent.FutureTask.report(FutureTask.java:122)
    at java.util.concurrent.FutureTask.get(FutureTask.java:192)
    at org.apache.tinkerpop.gremlin.server.handler.WsGremlinResponseEncoder.encode(WsGremlinResponseEncoder.java:67)
    at org.apache.tinkerpop.gremlin.server.handler.WsGremlinResponseEncoder.encode(WsGremlinResponseEncoder.java:45)
    at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:89)
    at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:633)
    at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:691)
    at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:626)
    at org.apache.tinkerpop.gremlin.server.handler.IteratorHandler.write(IteratorHandler.java:119)
    at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:633)
    at io.netty.channel.AbstractChannelHandlerContext.access$1900(AbstractChannelHandlerContext.java:32)
    at io.netty.channel.AbstractChannelHandlerContext$AbstractWriteTask.write(AbstractChannelHandlerContext.java:908)
    at io.netty.channel.AbstractChannelHandlerContext$WriteAndFlushTask.write(AbstractChannelHandlerContext.java:960)
    at io.netty.channel.AbstractChannelHandlerContext$AbstractWriteTask.run(AbstractChannelHandlerContext.java:893)
    at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:380)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:357)
    at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NoClassDefFoundError: org/apache/tinkerpop/gremlin/util/StreamFactory
    at com.thinkaurelius.titan.graphdb.relations.AbstractTypedRelation.properties(AbstractTypedRelation.java:144)
    at org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONSerializers$EdgeJacksonSerializer.writeProperties(GraphSONSerializers.java:146)
    at org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONSerializers$EdgeJacksonSerializer.ser(GraphSONSerializers.java:138)
    at org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONSerializers$EdgeJacksonSerializer.serialize(GraphSONSerializers.java:118)
    at org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONSerializers$EdgeJacksonSerializer.serialize(GraphSONSerializers.java:105)
    at com.fasterxml.jackson.databind.ser.impl.IndexedListSerializer.serializeContents(IndexedListSerializer.java:100)
    at com.fasterxml.jackson.databind.ser.impl.IndexedListSerializer.serializeContents(IndexedListSerializer.java:21)
    at com.fasterxml.jackson.databind.ser.std.AsArraySerializerBase.serialize(AsArraySerializerBase.java:183)
    at org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONUtil.writeWithType(GraphSONUtil.java:46)
    at org.apache.tinkerpop.gremlin.driver.ser.AbstractGraphSONMessageSerializerV1d0$ResponseMessageSerializer.ser(AbstractGraphSONMessageSerializerV1d0.java:235)
    at org.apache.tinkerpop.gremlin.driver.ser.AbstractGraphSONMessageSerializerV1d0$ResponseMessageSerializer.serialize(AbstractGraphSONMessageSerializerV1d0.java:205)
    at org.apache.tinkerpop.gremlin.driver.ser.AbstractGraphSONMessageSerializerV1d0$ResponseMessageSerializer.serialize(AbstractGraphSONMessageSerializerV1d0.java:197)
    at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:114)
    at com.fasterxml.jackson.databind.ObjectMapper._configAndWriteValue(ObjectMapper.java:2811)
    at com.fasterxml.jackson.databind.ObjectMapper.writeValueAsBytes(ObjectMapper.java:2292)
    at org.apache.tinkerpop.gremlin.driver.ser.AbstractGraphSONMessageSerializerV1d0.serializeResponseAsBinary(AbstractGraphSONMessageSerializerV1d0.java:107)
    at org.apache.tinkerpop.gremlin.server.handler.WsGremlinResponseEncoder.lambda$encode$64(WsGremlinResponseEncoder.java:67)
    at org.apache.tinkerpop.gremlin.server.handler.WsGremlinResponseEncoder$$Lambda$153/1714823976.call(Unknown Source)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    ... 1 more
Caused by: java.lang.ClassNotFoundException: org.apache.tinkerpop.gremlin.util.StreamFactory
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 22 more
spmallette commented 9 years ago

The StreamFactory class was removed from TinkerPop and replaced with IteratorUtils. That was broken late last Friday. Just fixed it this morning - pushed.

As for the other issue - your issue boils down to how you are iterating the traversal. Note that this works:

gremlin> :> g.addV().next()
==>v[4216]
gremlin> :> g.V()
==>v[4216]
gremlin> :> x=g.addV().next();g.V(4216).addOutE("knows",x).next()
==>e[sv-394-t1-3a8][4216-knows->4256]
gremlin> :> g.V()
==>v[4216]
==>v[4256]
gremlin> :> g.E()
==>e[sv-394-t1-3a8][4216-knows->4256]

For now the workaround is to not let Gremlin Server iterate results automatically when those results involve mutations. Trying to figure out how to make that work differently so it's not confusing to people. Tracking here:

https://issues.apache.org/jira/browse/TINKERPOP3-704

This issue doesn't appear to be Titan related and has a workaround - closing.

Neonell commented 8 years ago

You close the transaction before to create the edge, that's why you get an exception.

If you want to reuse a vertex you have to map it again, or you have to use it within the same transaction.

Cheers, Frédéric