apache-spark - Cassandra datastax 驱动程序连接突然终止

标签 apache-spark cassandra datastax-java-driver

我在 Cassandra 2.1.11 中使用 com.datastax.cassandra:cassandra-driver-core:2.1.7.1。抛出以下异常,它似乎指向协议(protocol)版本问题,但抛出 NPE 而不是 ProtocolException。

2016-01-26 17:46:29.426 TRACE - [launch worker-1] [74120143-3dc5-466d-8a71-68edbe03620d] com.datastax.driver.core.Connection      : Connection[/192.172.2.51:9042-1, inFlight=1, closed=false] writing request
 PREPARE SELECT * FROM loops WHERE venue_id = ? AND loop_state = ?  AND covers_year = ?  AND covers_month = ?  AND covers_day = 0 
2016-01-26 17:46:29.427 DEBUG - [r2-nio-worker-1] [74120143-3dc5-466d-8a71-68edbe03620d] com.datastax.driver.core.Connection      : Connection[/192.172.1.51:9042-3, inFlight=0, closed=false] connection error
java.lang.NullPointerException
        at com.datastax.driver.core.ProtocolOptions.getProtocolVersionEnum(ProtocolOptions.java:178)
        at com.datastax.driver.core.QueryLogger.protocolVersion(QueryLogger.java:753)
        at com.datastax.driver.core.QueryLogger.parameterValueAsString(QueryLogger.java:738)
        at com.datastax.driver.core.QueryLogger.appendParameters(QueryLogger.java:709)
        at com.datastax.driver.core.QueryLogger.logQuery(QueryLogger.java:647)
        at com.datastax.driver.core.QueryLogger.maybeLogNormalQuery(QueryLogger.java:631)
        at com.datastax.driver.core.QueryLogger$ConstantThresholdQueryLogger.maybeLogNormalOrSlowQuery(QueryLogger.java:278)
        at com.datastax.driver.core.QueryLogger.update(QueryLogger.java:620)
        at com.datastax.driver.core.Cluster$Manager.reportLatency(Cluster.java:1422)
        at com.datastax.driver.core.RequestHandler$SpeculativeExecution.onSet(RequestHandler.java:607)
        at com.datastax.driver.core.Connection$Dispatcher.channelRead0(Connection.java:991)
        at com.datastax.driver.core.Connection$Dispatcher.channelRead0(Connection.java:913)
        at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319)
        at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:254)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319)
        at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319)
        at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:163)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319)
        at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:787)
        at io.netty.channel.epoll.EpollSocketChannel$EpollSocketUnsafe.epollInReady(EpollSocketChannel.java:722)
        at io.netty.channel.epoll.EpollEventLoop.processReady(EpollEventLoop.java:326)
        at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:264)
        at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116)
        at java.lang.Thread.run(Thread.java:745)
2016-01-26 17:46:29.427 TRACE - [r2-nio-worker-4] [74120143-3dc5-466d-8a71-68edbe03620d] com.datastax.driver.core.Connection      : Connection[/192.172.2.51:9042-1, inFlight=1, closed=false] request sent successfully
2016-01-26 17:46:29.430 DEBUG - [r2-nio-worker-1] [74120143-3dc5-466d-8a71-68edbe03620d] com.datastax.driver.core.Connection      : Defuncting connection to /192.172.1.51:9042
com.datastax.driver.core.TransportException: [/192.172.1.51:9042] Unexpected exception triggered (java.lang.NullPointerException)
        at com.datastax.driver.core.Connection$Dispatcher.exceptionCaught(Connection.java:1028)
        at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:271)
        at io.netty.channel.AbstractChannelHandlerContext.notifyHandlerException(AbstractChannelHandlerContext.java:768)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:335)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319)
        at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:254)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319)
        at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319)
        at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:163)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319)
        at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:787)
        at io.netty.channel.epoll.EpollSocketChannel$EpollSocketUnsafe.epollInReady(EpollSocketChannel.java:722)
        at io.netty.channel.epoll.EpollEventLoop.processReady(EpollEventLoop.java:326)
        at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:264)
        at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116)
        at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NullPointerException
        at com.datastax.driver.core.ProtocolOptions.getProtocolVersionEnum(ProtocolOptions.java:178)
        at com.datastax.driver.core.QueryLogger.protocolVersion(QueryLogger.java:753)
        at com.datastax.driver.core.QueryLogger.parameterValueAsString(QueryLogger.java:738)
        at com.datastax.driver.core.QueryLogger.appendParameters(QueryLogger.java:709)
        at com.datastax.driver.core.QueryLogger.logQuery(QueryLogger.java:647)
        at com.datastax.driver.core.QueryLogger.maybeLogNormalQuery(QueryLogger.java:631)
        at com.datastax.driver.core.QueryLogger$ConstantThresholdQueryLogger.maybeLogNormalOrSlowQuery(QueryLogger.java:278)
        at com.datastax.driver.core.QueryLogger.update(QueryLogger.java:620)
        at com.datastax.driver.core.Cluster$Manager.reportLatency(Cluster.java:1422)
        at com.datastax.driver.core.RequestHandler$SpeculativeExecution.onSet(RequestHandler.java:607)
        at com.datastax.driver.core.Connection$Dispatcher.channelRead0(Connection.java:991)
        at com.datastax.driver.core.Connection$Dispatcher.channelRead0(Connection.java:913)
        at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333)
        ... 16 more
2016-01-26 17:46:29.431 TRACE - [r2-nio-worker-4] [74120143-3dc5-466d-8a71-68edbe03620d] com.datastax.driver.core.Connection      : Connection[/192.172.2.51:9042-1, inFlight=1, closed=false] received: RESULT PREPARED 0xc66a551ecfc5ac34839e19fdfa0c5705 [venue_id (uuid)][loop_state (varchar)][covers_year (int)][covers_month (int)] (resultMetadata=[venue_id (uuid)][loop_state (varchar)][covers_year (int)][covers_month (int)][covers_day (int)][start (timestamp)][created_on (timestamp)][end (timestamp)][id (uuid)][iterations (int)][playlist (list<frozen<ums_qa."LoopMediaAsset">>)][slots (list<frozen<ums_qa."Slot">>)][updated_on (timestamp)])

两个 Cassandra 节点都工作正常并接受连接。一些驱动程序似乎是如何任意关闭连接的。无法在任何地方找到报告的类似问题。任何帮助将不胜感激。谢谢。

最佳答案

在 2.1.8 和 2.1.9 之间有一个小的 native 协议(protocol)版本增加 - 通过将 2.1.7 驱动程序与 2.1.11 服务器一起使用,您有一个由服务器提供的 native 原型(prototype)版本号,该版本号无法被识别客户。

鉴于堆栈跟踪(以及驱动程序中这些行的代码 - https://github.com/datastax/java-driver/blob/f4240267b3a3b829fa51242441dd219424a91347/driver-core/src/main/java/com/datastax/driver/core/ProtocolOptions.java#L168-L179 ),我可能会首先升级到最新的 2.1.11+ cassandra-driver 版本以排除这种情况。

关于apache-spark - Cassandra datastax 驱动程序连接突然终止,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35021167/

相关文章:

python - 属性错误 :split on spark sql python using lambda

nosql - 跟踪用户关系的最佳数据库是什么?

Cassandra 同时清理多台服务器

cassandra - 如何以不同于其他列的方式映射静态列?

apache-spark - Pyspark 添加字符串类型的空文字映射

python - 将 Python 转换为 Scala

nosql - Cassandra CQL 时间范围查询

java - 以线程安全的方式缓存preparestatement?

database - Cassandra 2.0.6 : Higher number of results when adding AND to query

scala - 在 Clojure 中编写 Spark Structured Streaming 示例时出错