【问题标题】:PySpark throws java.io.EOFException when reading big files with boto3使用 boto3 读取大文件时 PySpark 抛出 java.io.EOFException
【发布时间】:2016-03-09 07:15:15
【问题描述】:

我正在使用 boto3 从 S3 读取文件,这比sc.textFile(...) 快得多。这些文件大约在 300MB 和 1GB 之间。流程如下:

data = sc.parallelize(list_of_files, numSlices=n_partitions) \
    .flatMap(read_from_s3_and_split_lines)

events = data.aggregateByKey(...)

运行此进程时,出现异常:

15/12/04 10:58:00 WARN TaskSetManager: Lost task 41.3 in stage 0.0 (TID 68, 10.83.25.233): org.apache.spark.SparkException: Python worker exited unexpectedly (crashed)
    at org.apache.spark.api.python.PythonRunner$$anon$1.read(PythonRDD.scala:203)
    at org.apache.spark.api.python.PythonRunner$$anon$1.<init>(PythonRDD.scala:207)
    at org.apache.spark.api.python.PythonRunner.compute(PythonRDD.scala:125)
    at org.apache.spark.api.python.PythonRDD.compute(PythonRDD.scala:70)
    at org.apache.spark.rdd.RDD.computeOrReadCheckpoint(RDD.scala:300)
    at org.apache.spark.rdd.RDD.iterator(RDD.scala:264)
    at org.apache.spark.api.python.PairwiseRDD.compute(PythonRDD.scala:342)
    at org.apache.spark.rdd.RDD.computeOrReadCheckpoint(RDD.scala:300)
    at org.apache.spark.rdd.RDD.iterator(RDD.scala:264)
    at org.apache.spark.scheduler.ShuffleMapTask.runTask(ShuffleMapTask.scala:73)
    at org.apache.spark.scheduler.ShuffleMapTask.runTask(ShuffleMapTask.scala:41)
    at org.apache.spark.scheduler.Task.run(Task.scala:88)
    at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:214)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.EOFException
    at java.io.DataInputStream.readInt(DataInputStream.java:392)
    at org.apache.spark.api.python.PythonRunner$$anon$1.read(PythonRDD.scala:139)
    ... 15 more

很多时候,只是一些任务崩溃并且作业能够恢复。但是,有时整个作业会在出现许多此类错误后崩溃。我一直无法找到这个问题的根源,并且似乎根据我读取的文件数量、我应用的确切转换来出现和消失......读取单个文件时它永远不会失败。

【问题讨论】:

    标签: amazon-s3 pyspark eofexception boto3


    【解决方案1】:

    我遇到过类似的问题,我的调查表明问题是 Python 进程的可用内存不足。 Spark 占用了所有内存,Python 进程(PySpark 工作的地方)一直在崩溃。

    一些建议:

    1. 为机器添加一些内存,
    2. 不持久化不需要的 RDD,
    3. 更明智地管理内存(对 Spark 内存使用添加一些限制)。

    【讨论】:

      猜你喜欢
      • 2021-12-03
      • 1970-01-01
      • 1970-01-01
      • 2016-09-27
      • 1970-01-01
      • 2018-11-07
      • 2014-11-09
      • 1970-01-01
      • 2021-10-18
      相关资源
      最近更新 更多