0

TL; DR - 所以我有一个从DataStax java cassandra驱动程序到DataStax cassandra集群的连接问题。它最初连接和执行得很好,然后在某一点突然失去连接并且不重新连接 - 此时所有查询都失败。Cassandra java驱动程序连接错误

更多信息 -

所以我跑在CentOS DataStax卡桑德拉2.1 3个节点的集群中,我使用DataStax卡桑德拉驱动程序3.0.0。在过去的几个月中,一切都运行良好,最近iv'e部署了一些代码更改,包括一些模式更改(即向现有表添加列)以及增加查询次数。断开连接在这一点开始。

因此,当我的应用程序上升时,它连接到群集并拥有一个群集(和会话)对象,如下面的代码片段所示,此时一切顺利。几个小时后,我开始接收每个查询执行NoHostAvailableException。在这一点上,我有其他服务器与相同的cassandra集群表现良好,所以我知道集群本身没有任何问题。当我重启我的服务器时,一切都很好。

在调查了一会儿之后,当问题开始发生时,我看到没有任何活动连接到两个节点。如果将驱动程序设置为在专用日志文件中登录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); 
+0

你正在做插入或只是从cassandra读取? – root545

+0

两者。所有查询都失败。 – AvivC

回答

2

如果卡桑德拉节点被配置有native_transport_max_frame_size_in_mb> 256和驱动程序读取的帧比256MB抛出异常大。这可能是在Java驱动程序

一个错误由于解码器,用于解析帧的读取后续数据包的能力是静态

在3.0.4这已被固定在, 这里是链接的细节。

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

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

+0

我也在这里收到此提示: https://groups.google.com/a/lists.datastax.com/forum/#!topic/java-driver-user/1cSGl-YOzxE 我刚刚迁移今天。我会等待几天,看看它是否重复,我会在这里确认! 谢谢! – AvivC

+0

似乎不会重复使用新版本! – AvivC

相关问题