gpt4 book ai didi

java - Cassandra java驱动程序连接错误

转载 作者:行者123 更新时间:2023-12-02 03:13:57 24 4
gpt4 key购买 nike

TL;DR - 所以我遇到了从 DataStax java cassandra 驱动程序到 DataStax cassandra 集群的连接问题。它最初连接并执行良好,然后突然在某个时刻失去连接并且不重新连接 - 此时所有查询都会失败。

更多信息-

所以我在 CentOS 上运行 DataStax cassandra 2.1 3 个节点集群,我使用 DataStax cassandra 驱动程序 3.0.0。在过去的几个月里,一切都进展顺利,最近 iv'e 部署了一些代码更改,其中包括一些架构更改(即向现有表添加列)和查询数量的增加。此时开始断开连接。

因此,当我的应用程序启动时,它会连接到集群并保存单个集群(和 session )对象,如下面的代码片段所示,此时一切顺利。几个小时后,我开始收到执行的每个查询的 NoHostAvailableException 。此时,我的其他服务器在同一个 cassandra 集群上运行良好,所以我知道集群本身没有任何问题。当我重新启动服务器时,一切都恢复正常。

经过更多调查后,当问题开始发生时,我发现两个节点都没有 Activity 连接。我将驱动程序设置为以DEBUG 级别登录到专用日志文件中,并等待问题再次出现。几个小时后,问题再次发生,在某个时刻日志文件显示以下消息:

Connection[/10.4.116.91:9042-1, inFlight=2, closed=false] connection error
io.netty.handler.codec.DecoderException: com.datastax.driver.core.exceptions.DriverInternalError: Adjusted frame length exceeds 268435456: 326843398 - discarded
at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:418)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:245)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:292)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:278)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:962)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:528)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:485)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:399)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:371)
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:112)
at java.lang.Thread.run(Thread.java:745)
Caused by: com.datastax.driver.core.exceptions.DriverInternalError: Adjusted frame length exceeds 268435456: 326843398 - discarded
at com.datastax.driver.core.Frame$Decoder$DecoderForStreamIdSize.decode(Frame.java:239)
at com.datastax.driver.core.Frame$Decoder.decode(Frame.java:205)
at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:387)
... 11 common frames omitted

之后您会看到以下内容:

Connection[/10.4.116.91:9042-1, inFlight=2, closed=false] connection error
io.netty.handler.codec.DecoderException: com.datastax.driver.core.exceptions.DriverInternalError: Adjusted frame length exceeds 268435456: 326843398 - discarded
at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:418)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:245)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:292)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:278)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:962)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:528)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:485)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:399)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:371)
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:112)
at java.lang.Thread.run(Thread.java:745)
Caused by: com.datastax.driver.core.exceptions.DriverInternalError: Adjusted frame length exceeds 268435456: 326843398 - discarded
at com.datastax.driver.core.Frame$Decoder$DecoderForStreamIdSize.decode(Frame.java:239)
at com.datastax.driver.core.Frame$Decoder.decode(Frame.java:205)
at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:387)
... 11 common frames omitted

从此时起,您只会看到超时和重试,但不会重新建立连接。

// CREATION OF CASSANDRA SESSION
PoolingOptions poolingOptions = new PoolingOptions();
poolingOptions
.setPoolTimeoutMillis(0)
.setMaxRequestsPerConnection(HostDistance.LOCAL, 32768)
.setMaxRequestsPerConnection(HostDistance.REMOTE, 2000);
cluster = builder.withPoolingOptions(poolingOptions).build();
cluster.getConfiguration().getCodecRegistry().register(new EnumNameCodec<>(OnBoardingSlide.Type.class));
session = cluster.connect(Global.getServerConfig().CASSANDRA_KEYSPACE_NAME);

最佳答案

这可能是 java 驱动程序中的错误

If a cassandra node is configured with native_transport_max_frame_size_in_mb > 256 and the driver reads a frame larger than 256mb it throws an exception: This breaks the drivers ability to read subsequent packets since the Decoder for parsing frames is static

这已在 3.0.4 中修复,这是详细信息的链接。

https://datastax-oss.atlassian.net/browse/JAVA-1292

您可以尝试升级您的驱动程序吗?

关于java - Cassandra java驱动程序连接错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40609378/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com