如何在Spark worker上的map函数中调试错误? [英] How can I debug errors in a map function on Spark workers?

查看:108
本文介绍了如何在Spark worker上的map函数中调试错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Spark的新手,正试图找到自己的路.

I am new to Spark and trying to find my way.

我有一个Spark应用程序,可以在数据集上运行复杂的地图功能.该映射功能可能主要由于与数据相关的原因而失败.我如何获得有关出了什么问题的有意义的信息?我不确定从哪里开始.

I've a spark application that runs a complicated map function over a dataset. This map function can fail for mainly data related reasons. How can I get some meaningful information on what went wrong? I'm not sure where to start.

非常感谢!

推荐答案

好,所以确实可以,但是有一些陷阱.

Ok, so this is indeed possible, but there are some pitfalls.

广泛地创建一个类,该类封装了来自地图函数的结果,例如

Broadly, create a class that encapsulates your results from the map function eg

class CalcResult(object):

    def __init__(self):
        self.dataResult=None
        self.TraceBackStr=None
        self.wasError=None

然后,您可以测试wasError字段以记录异常.

Then you can test the wasError field in order to log exceptions.

异常对象不能为回溯对象,因为它们不是可拾取的.因此,我建议使用格式化的字符串.

The exception object cannot be a traceback object as they are not pickable. So, I suggest a formatted string.

这篇关于如何在Spark worker上的map函数中调试错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆