KryoException:缓冲区太小

KryoException: Buffer too small

我正在使用 Gremlin 3.0.2 和 Titan 1.0.0。

我发送到 Gremlin 服务器的请求将 return 节点列表及其属性。实际上,它是一个如下所示的项目列表:

[coverurl:[https://lh3.googleusercontent.com/RYb-duneinq8ClWVLVKknkIx1jOKm64LjreziFApEnkKME8j9tHNDRi9NMA6PK4PTXO7], appname:[Slack], pkgid:[com.Slack]]

在一种情况下,一个请求将 return 38 个项目,如上面的那个,一切都很好。在另一种情况下,该列表将包含 56 个这样的项目,我得到以下异常:

WARN  org.apache.tinkerpop.gremlin.driver.MessageSerializer  - Response [PooledUnsafeDirectByteBuf(ridx: 0, widx: 0, cap: 0)] could not be deserialized by org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0.
ERROR org.apache.tinkerpop.gremlin.driver.Handler$GremlinResponseHandler  - Could not process the response
io.netty.handler.codec.DecoderException: org.apache.tinkerpop.gremlin.driver.ser.SerializationException: org.apache.tinkerpop.shaded.kryo.KryoException: Buffer too small: capacity: 0, required: 1
at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:99)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294)

去年here讨论过这个问题。然而,对于不同版本的 Titan 和向 Titan 写入数据,而不是像这里这样读取。

我没有看到任何编程方式来调整(反)序列化器的缓冲区大小,那么处理这个问题的首选方式是什么?此外,将一些限制(哪个?,哪里?)设置为更高的值只能是一个临时解决方案,因为我永远不知道请求将有多少数据return。

无论如何 - 我收到的数据量相当小(可能略多于 8500 字节)。我很惊讶竟然抛出了这个异常?

Titan 1.0 基于 TinkerPop 3.0.1...您是在自己构建 Titan 吗?

TINKERPOP-817 引入了允许配置 bufferSize 参数的修复程序。正如斯蒂芬在评论中提到的:

the kryo buffer size was defaulted to 4096 and would those throw that "Buffer too small" exception

修复进入了 TinkerPop 3.0.2 并记录在案 here

为了使用它,您需要将您的 Titan Server 升级到 运行 和 TinkerPop 3.0.2,最好在修改 tinkerpop.version in the Titan pom.xml. Find the Titan build directions here. Alternately, you could consider building the titan11 分支后从源代码重新编译获取最新的可用修复程序和 TinkerPop 3.1.1(Hadoop 2 支持!)。

接下来,您需要在 gremlin-server.yaml 配置中的相应序列化程序上配置 bufferSize。我认为您不能仅通过客户端配置解决此问题。

serializers:
  - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { bufferSize: 8192, useMapperFromGraph: graph }}       # application/vnd.gremlin-v1.0+gryo

由于您有一个 Java 客户端并且您希望直接使用 Vertex 对象,也许您可​​以考虑直接连接到 Titan 并完全避免这种序列化。