有没有办法在Spark中捕获执行程序杀死的异常? [英] Is there a way to catch executor killed exception in Spark?
问题描述
在执行我的Spark程序期间,有时(它的原因对我来说仍然是个谜)纱线会杀死容器(执行程序),并发出消息,表明已超出内存限制.我的程序确实恢复了,尽管Spark通过产生一个新的容器重新执行了任务.但是,在我的程序中,一个任务还在磁盘上创建了一些中间文件.当杀死一个容器时,这些文件将被留下.有没有一种方法可以捕获被执行者杀死的异常,以便删除残留的中间文件.显然,异常处理代码也需要在执行程序运行所在的同一节点上运行,以便我可以从那里删除文件.
During execution of my Spark program, sometimes (The reason for it is still a mystery to me) yarn kills containers (executors) giving the message that the memory limit was exceeded. My program does recover though with Spark re-executing the task by spawning a new container. However, in my program, a task also creates some intermediate files on the disk. When a container is killed, those files are left behind. Is there a way I can catch the executor-killed as an exception so that I can delete the intermediate files left behind. Obviously, the exception handling code also needs to run on the same node the executor was running on, so that I can delete the files from there.
推荐答案
在 @Taras Matyashovskyy 答案的顶部添加.
Adding on top of @Taras Matyashovskyy answer.
您可以使用SparkListener和拦截SparkListener(Executor)事件.
下面是可用的侦听器事件列表.
Below are list of Listener events available.
SparkListenerApplicationStart
SparkListenerApplicationStart
SparkListenerJobStart
SparkListenerJobStart
SparkListenerStageSubmitted
SparkListenerStageSubmitted
SparkListenerTaskStart
SparkListenerTaskStart
SparkListenerTaskGettingResult
SparkListenerTaskGettingResult
SparkListenerTaskEnd
SparkListenerTaskEnd
SparkListenerStageCompleted
SparkListenerStageCompleted
SparkListenerJobEnd
SparkListenerJobEnd
SparkListenerApplicationEnd
SparkListenerApplicationEnd
SparkListenerEnvironmentUpdate
SparkListenerEnvironmentUpdate
SparkListenerBlockManagerAdded
SparkListenerBlockManagerAdded
SparkListenerBlockManagerRemoved
SparkListenerBlockManagerRemoved
SparkListenerBlockUpdated
SparkListenerBlockUpdated
SparkListenerUnpersistRDD
SparkListenerUnpersistRDD
SparkListenerExecutorAdded
SparkListenerExecutorAdded
SparkListenerExecutor已删除
SparkListenerExecutorRemoved
示例: 请访问删除了可能适合您的原因(我没有尝试过)
Please have a look in to removed reason which may suits you(I haven't tried)
这篇关于有没有办法在Spark中捕获执行程序杀死的异常?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!