amazon-archives / dynamodb-janusgraph-storage-backend

The Amazon DynamoDB Storage Backend for JanusGraph
Apache License 2.0
446 stars 99 forks source link

Unable to execute scripts with bound parameters: Gremlin Server hangs #22

Closed jbmusso closed 8 years ago

jbmusso commented 8 years ago

Greetings. Using Titan 1.0.0 with DynamoDB local, I'm unable to execute scripts with bound parameters sent to Gremlin Server via Websocket. Scripts with no parameters work fine. I'm using the default gremlin-server-local.yaml file (default setup from http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Tools.TitanDB.DownloadingAndRunning.html#Tools.TitanDB.DownloadingAndRunning.title). Everything works fine from the Gremlin console. Also using java version "1.8.0_45".

The following query works: Gremlin Server returns intermediate and termination messages, and the vertex gets added to the graph:

{
  "requestId": "7091d5a0-ae15-11e5-b942-d57806399243",
  "processor": "",
  "op": "eval",
  "args": {
    "gremlin": "g.addV(label, 'user', 'firstname', 'Alice')",
    "accept": "application/json",
    "language": "gremlin-groovy"
  }
}

However, the same query with bound parameters fails to execute. Gremlin server doesn't stream any message back to the client, and no vertex is added to the graph:

{
  "requestId": "2160a1d0-ae17-11e5-a9b1-fd3c55aea4b5",
  "processor": "",
  "op": "eval",
  "args": {
    "gremlin": {
      "script": "g.addV(label, 'user', 'firstname', p1)",
      "params": {
        "p1": "Alice"
      }
    },
    "accept": "application/json",
    "language": "gremlin-groovy"
  }
}

Gremlin Server throws, here's the complete stacktrace:

340896 [gremlin-server-worker-1] 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.ClassCastException: java.util.LinkedHashMap cannot be cast to java.lang.String
  at org.apache.tinkerpop.gremlin.server.op.AbstractEvalOpProcessor.evalOpInternal(AbstractEvalOpProcessor.java:145)
  at org.apache.tinkerpop.gremlin.server.op.standard.StandardOpProcessor.evalOp(StandardOpProcessor.java:69)
  at org.apache.tinkerpop.gremlin.server.op.standard.StandardOpProcessor$$Lambda$112/798544109.accept(Unknown Source)
  at org.apache.tinkerpop.gremlin.server.handler.OpExecutorHandler.channelRead0(OpExecutorHandler.java:66)
  at org.apache.tinkerpop.gremlin.server.handler.OpExecutorHandler.channelRead0(OpExecutorHandler.java:41)
  at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105)
  at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308)
  at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294)
  at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)
  at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308)
  at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294)
  at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)
  at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308)
  at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294)
  at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)
  at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308)
  at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294)
  at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)
  at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308)
  at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294)
  at io.netty.handler.codec.http.websocketx.WebSocketServerProtocolHandler$1.channelRead(WebSocketServerProtocolHandler.java:146)
  at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308)
  at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294)
  at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:182)
  at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308)
  at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294)
  at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:846)
  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)

I'm using https://github.com/jbmusso/gremlin-javascript and can dig into the internal if needed. Client tests work fine against TP 3.0.1, including scripts executed with bound parameters.

jbmusso commented 8 years ago

Closing this as this was an issue on our side. The error resulted from a wrong usage of the client. The request should have been formatted this way:

{
  "requestId": "2160a1d0-ae17-11e5-a9b1-fd3c55aea4b5",
  "processor": "",
  "op": "eval",
  "args": {
    "gremlin": "g.addV(label, 'user', 'firstname', p1)",
    "bindings": {
      "p1": "Alice"
    },
    "accept": "application/json",
    "language": "gremlin-groovy"
  }
}