Apache spark Spark:DecodeXception:java.lang.OutOfMemoryError

Apache spark Spark:DecodeXception:java.lang.OutOfMemoryError,apache-spark,spark-streaming,apache-spark-1.4,Apache Spark,Spark Streaming,Apache Spark 1.4,我正在一个有3个工作节点的集群上运行Spark流媒体应用程序。偶尔,由于以下异常,作业会失败: Job aborted due to stage failure: Task 0 in stage 4508517.0 failed 4 times, most recent failure: Lost task 0.3 in stage 4508517.0 (TID 1376191, 172.31.47.126): io.netty.handler.codec.DecoderException: j

我正在一个有3个工作节点的集群上运行Spark流媒体应用程序。偶尔,由于以下异常,作业会失败:

Job aborted due to stage failure: Task 0 in stage 4508517.0 failed 4 times, most recent failure: Lost task 0.3 in stage 4508517.0 (TID 1376191, 172.31.47.126): io.netty.handler.codec.DecoderException: java.lang.OutOfMemoryError
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:153)
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.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)
Caused by: java.lang.OutOfMemoryError
at sun.misc.Unsafe.allocateMemory(Native Method)
at java.nio.DirectByteBuffer.<init>(DirectByteBuffer.java:127)
at java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:306)
at io.netty.buffer.PoolArena$DirectArena.newUnpooledChunk(PoolArena.java:440)
at io.netty.buffer.PoolArena.allocateHuge(PoolArena.java:187)
at io.netty.buffer.PoolArena.allocate(PoolArena.java:165)
at io.netty.buffer.PoolArena.reallocate(PoolArena.java:277)
at io.netty.buffer.PooledByteBuf.capacity(PooledByteBuf.java:108)
at io.netty.buffer.AbstractByteBuf.ensureWritable(AbstractByteBuf.java:251)
at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:849)
at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:841)
at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:831)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:146)
... 10 more  
作业因阶段失败而中止:阶段4508517.0中的任务0失败4次,最近的失败:阶段4508517.0中的任务0.3丢失(TID 1376191,172.31.47.126):io.netty.handler.codec.DecoderException:java.lang.OutOfMemoryError
位于io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:153)
位于io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333)
位于io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319)
位于io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:787)
在io.netty.channel.nio.AbstractNioByteChannel$niobytuensafe.read(AbstractNioByteChannel.java:130)
位于io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511)
在io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized处(NioEventLoop.java:468)
位于io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382)
位于io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354)
位于io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116)
运行(Thread.java:745)
原因:java.lang.OutOfMemoryError
在sun.misc.Unsafe.allocateMemory(本机方法)
位于java.nio.DirectByteBuffer(DirectByteBuffer.java:127)
位于java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:306)
在io.netty.buffer.PoolArena$DirectArena.newUnmoledChunk(PoolArena.java:440)
位于io.netty.buffer.PoolArena.allocateHuge(PoolArena.java:187)
在io.netty.buffer.PoolArena.allocate(PoolArena.java:165)处
在io.netty.buffer.PoolArena.realocate(PoolArena.java:277)
在io.netty.buffer.PooledByteBuf.capacity处(PooledByteBuf.java:108)
在io.netty.buffer.AbstractByteBuf.ensureWritable(AbstractByteBuf.java:251)处
位于io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:849)
位于io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:841)
位于io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:831)
位于io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:146)
... 10多
我在客户端模式下提交作业,没有任何特殊参数。 主人和工人都有15克的内存。Spark版本是1.4.0


这可以通过调整配置来解决吗?

我面临同样的问题,并发现这可能是由Spark 1.4使用的netty版本4.0.23.Final中的内存泄漏引起的(请参阅)

至少在使用netty 4.0.29.Final的Spark 1.5.0(请参阅)中解决了此问题

因此,升级到最新的Spark版本应该可以解决这个问题。我将在接下来的几天里尝试它

此外,当前版本中的Spark Jobserver强制使用netty 4.0.23.Final,因此它也需要修复


编辑:我用netty 4.0.29.Final升级到Spark 1.6,但仍然使用Spark Jobserver获得直接缓冲区OOM。

值得指出的一点是,我们在代码中使用了大量的DStream.cache。>这可以通过调整配置来解决吗?您应该已经尝试过了,请参见
--executor memory
--driver memory
。不要忘记使用
DStream.unpersist
,删除不再对您有用的
DStream
。使用Spark 1.6.2,仍然会出现此错误,我确定这与执行器内存无关,但不知道如何修复它。