【发布时间】:2020-07-16 09:52:59
【问题描述】:
我正在尝试以 JSON 格式将数据帧写入 s3 位置。但是,每当执行器任务失败并且 Spark 重试该阶段时,它就会抛出 FileAlreadyExistsException。
之前有人问过similar question,但它使用单独的 spark conf 解决了 ORC 文件,并没有解决我的问题。
这是我的代码:
val result = spark.sql(query_that_OOMs_executor)
result.write.mode(SaveMode.Overwrite).json(s3_path)
从火花用户界面,执行器上的错误说
ExecutorLostFailure (executor 302 exited caused by one of the running tasks)
Reason: Container killed by YARN for exceeding memory limits. 4.5 GB of 4.5 GB physical memory used.
Consider boosting spark.yarn.executor.memoryOverhead or disabling yarn.nodemanager.vmem-check-enabled because of YARN-4714.
但驱动程序堆栈跟踪显示
Job aborted due to stage failure: Task 1344 in stage 2.0 failed 4 times, most recent failure: Lost task 1344.3 in stage 2.0 (TID 25797, executor.ec2.com, executor 217): org.apache.hadoop.fs.FileAlreadyExistsException: s3://prod-bucket/application_1590774027047/-650323473_1594243391573/part-01344-dc971661-93ef-4abc-8380-c000.json already exists
如何让 spark 尝试覆盖这个 JSON 文件?这样,一旦所有 4 次重试都失败,我就会得到驱动程序的真正原因。我已经将模式设置为覆盖,所以这没有帮助。
【问题讨论】:
-
我也有同样的问题..有时它会起作用,有时它不会..解决这个问题 - 添加代码以在写入之前删除目录..
-
@Srinivas 在我的情况下不起作用我确保
s3_path在调用.json(s3_path)之前是唯一的,当写入时任务失败并且路径已经存在时会发生异常。 -
你在用什么
FileOutputCommitter?您可能有兴趣查看hadoop.apache.org/docs/r3.1.1/hadoop-aws/tools/hadoop-aws/…。
标签: apache-spark apache-spark-sql