gpt4 book ai didi

amazon-web-services - 如何从 shell 脚本中捕获 Spark 错误

转载 作者:行者123 更新时间:2023-12-04 08:02:07 25 4
gpt4 key购买 nike

我在 AWS Data Pipeline 中有一个管道运行名为 shell.sh 的 shell 脚本:

$ spark-submit transform_json.py


Running command on cluster...
[54.144.10.162] Running command...
[52.206.87.30] Running command...
[54.144.10.162] Command complete.
[52.206.87.30] Command complete.
run_command finished in 0:00:06.

AWS Data Pipeline 控制台显示作业“已完成”,但在 stderr 日志中我看到作业实际上已中止:

Caused by: com.amazonaws.services.s3.model.AmazonS3Exception: Status Code: 404, AWS Service: Amazon S3, AWS Request ID: xxxxx, AWS Error Code: null, AWS Error Message: Not Found...        
Caused by: org.apache.spark.SparkException: Job aborted due to stage failure: Task 0 in stage 5.0 failed 1 times, most recent failure: Lost task 0.0 in stage 5.0 (TID 5, localhost, executor driver): org.apache.spark.SparkException: Task failed while writing rows.
...
20/05/22 11:42:47 INFO MapOutputTrackerMasterEndpoint: MapOutputTrackerMasterEndpoint stopped!
20/05/22 11:42:47 INFO MemoryStore: MemoryStore cleared
20/05/22 11:42:47 INFO BlockManager: BlockManager stopped
20/05/22 11:42:47 INFO BlockManagerMaster: BlockManagerMaster stopped
20/05/22 11:42:47 INFO OutputCommitCoordinator$OutputCommitCoordinatorEndpoint: OutputCommitCoordinator stopped!
20/05/22 11:42:47 INFO SparkContext: Successfully stopped SparkContext
20/05/22 11:42:47 INFO ShutdownHookManager: Shutdown hook called

我对数据管道和 Spark 比较陌生;无法理解幕后实际发生的事情。如何让 shell 脚本捕获 SparkException

最佳答案

尝试像下面的例子...

你的 shell 脚本可以捕获这样的错误代码......其中非零退出代码是错误的

$? 是最近执行的命令的退出状态;按照惯例,0 表示成功,其他任何表示失败。


spark-submit transform_json.py


ret_code=$?
if [ $ret_code -ne 0 ]; then
exit $ret_code
fi

您必须编写代码以在错误情况下通过 sys.exit(-1) 返回退出代码。检查这个 python 异常处理...

检查这个Exit codes in Python

关于amazon-web-services - 如何从 shell 脚本中捕获 Spark 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62032408/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com