小记-bug解决:Exception thrown in awaitResult/Connection reset by peer

14 篇文章 0 订阅

org.apache.spark.SparkException: Exception thrown in awaitResult

"time":"2020-07-02 11:10:15","logtype":"ERROR","loginfo":"Executor self-exiting due to : Driver masterba17fc94-f00c-477a-b1d4-4c165c7893d9cupid-11-194-251-15:45755 disassociated! Shutting down."}
{"time":"2020-07-02 11:10:15","logtype":"WARN","loginfo":"Issue communicating with driver in heartbeater"}
org.apache.spark.SparkException: Exception thrown in awaitResult: 
	at org.apache.spark.util.ThreadUtils$.awaitResult(ThreadUtils.scala:205)
	at org.apache.spark.rpc.RpcTimeout.awaitResult(RpcTimeout.scala:75)
	at org.apache.spark.rpc.RpcEndpointRef.askSync(RpcEndpointRef.scala:92)
	at org.apache.spark.executor.Executor.org$apache$spark$executor$Executor$$reportHeartBeat(Executor.scala:785)
	at org.apache.spark.executor.Executor$$anon$2$$anonfun$run$1.apply$mcV$sp(Executor.scala:814)
	at org.apache.spark.executor.Executor$$anon$2$$anonfun$run$1.apply(Executor.scala:814)
	at org.apache.spark.executor.Executor$$anon$2$$anonfun$run$1.apply(Executor.scala:814)
	at org.apache.spark.util.Utils$.logUncaughtExceptions(Utils.scala:1988)
	at org.apache.spark.executor.Executor$$anon$2.run(Executor.scala:814)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
  • 解决:
#调整参数大小:
	spark.sql.broadcastTimeout=1200 默认大小300

java.io.IOException: Connection reset by peer

java.io.IOException: Connection reset by peer
	at sun.nio.ch.FileDispatcherImpl.read0(Native Method)
	at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:39)
	at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223)
	at sun.nio.ch.IOUtil.read(IOUtil.java:192)
	at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:380)
	at io.netty.buffer.PooledUnsafeDirectByteBuf.setBytes(PooledUnsafeDirectByteBuf.java:288)
	at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:1106)
	at io.netty.channel.socket.nio.NioSocketChannel.doReadBytes(NioSocketChannel.java:343)
	at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:123)
	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:645)
	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:580)
	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:497)
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:459)
	at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:858)
	at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:138)
	at java.lang.Thread.run(Thread.java:745)
  • 解决:
调大参数: 
 spark.network.timeout 默认大小 120 s 
 spark.executor.heartbeatInterval 默认大小10s
 #注:spark.network.timeout的参数要大于 spark.executor.heartbeatInterval 心跳参数
 	Interval between each executor's heartbeats to the driver. 
 	Heartbeats let the driver know that the executor is still alive 
 	and update it with metrics for in-progress tasks. 
 	spark.executor.heartbeatInterval should be significantly less than spark.network.timeout
该 HTML 代码是一个静态网页,如果您需要实现数据更新,需要使用后端技术。一种常见的方式是使用 JavaScript 和 AJAX 技术,通过向后端发送请求获取数据,并将数据动态更新到页面上。 具体实现步骤如下: 1. 在后端编写一个 API,用于获取设备运行状态的数据。可以使用 Flask、Django 等框架来实现该 API。 2. 在前端使用 JavaScript 和 AJAX 技术,向后端发送请求获取数据。可以使用 jQuery 或原生的 XMLHttpRequest 对象来实现。 3. 在获取到数据后,使用 JavaScript 动态更新页面上对应的元素。可以使用 jQuery 或原生的 DOM 操作方法来实现。 下面是一个简单的示例代码,使用 jQuery 实现数据更新: ``` <!DOCTYPE html> <html> <head> <title>设备运行实况</title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <style> body { font-family: Arial, sans-serif; background-color: #f7f7f7; } h1 { text-align: center; margin-top: 50px; } table { margin: auto; border-collapse: collapse; border: 1px solid #ddd; width: 80%; } th, td { padding: 12px; text-align: center; border-bottom: 1px solid #ddd; } th { background-color: #4CAF50; color: white; } .status-ok { color: green; font-weight: bold; } .status-warning { color: orange; font-weight: bold; } .status-error { color: red; font-weight: bold; } </style> <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> <script> $(document).ready(function() { // 定时更新数据 setInterval(function() { $.ajax({ url: '/api/devices', type: 'GET', dataType: 'json', success: function(data) { // 更新数据 $.each(data, function(i, item) { $('#device-' + item.id + '-status').text(item.status); $('#device-' + item.id + '-time').text(item.time); $('#device-' + item.id + '-status').removeClass().addClass('status-' + item.status.toLowerCase()); }); }, error: function(xhr, textStatus, errorThrown) { console.log('Error: ' + errorThrown); } }); }, 5000); // 每隔 5 秒更新一次数据 }); </script> </head> <body> <h1>设备运行实况</h1> <table> <tr> <th>设备名称</th> <th>运行状态</th> <th>最近更新时间</th> </tr> <tr> <td>设备 A</td> <td id="device-1-status" class="status-ok">正常运行</td> <td id="device-1-time">2021-10-01 10:30:00</td> </tr> <tr> <td>设备 B</td> <td id="device-2-status" class="status-warning">运行异常</td> <td id="device-2-time">2021-10-01 11:00:00</td> </tr> <tr> <td>设备 C</td> <td id="device-3-status" class="status-error">停机</td> <td id="device-3-time">2021-10-01 12:11:00</td> </tr> </table> </body> </html> ``` 在上面的示例代码中,我们使用了 jQuery 的 `$.ajax` 方法向后端发送 GET 请求,获取设备状态的数据。在请求成功后,我们使用 `$.each` 方法遍历数据,并更新页面上对应的元素。每隔 5 秒钟更新一次数据。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值