Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-17788

RangePartitioner results in few very large tasks and many small to empty tasks


    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.0
    • Fix Version/s: 2.3.0
    • Component/s: Spark Core, SQL
    • Labels:
    • Environment:

      Ubuntu 14.04 64bit
      Java 1.8.0_101


      Greetings everyone,

      I was trying to read a single field of a Hive table stored as Parquet in Spark (~140GB for the entire table, this single field is a Double, ~1.4B records) and look at the sorted output using the following:
      sql("SELECT " + field + " FROM MY_TABLE ORDER BY " + field + " DESC")
      ​But this simple line of code gives:
      Caused by: java.lang.IllegalArgumentException: Cannot allocate a page with more than 17179869176 bytes

      Same error for:
      sql("SELECT " + field + " FROM MY_TABLE).sort(field)
      sql("SELECT " + field + " FROM MY_TABLE).orderBy(field)

      After doing some searching, the issue seems to lie in the RangePartitioner trying to create equal ranges. [1]

      [1] https://spark.apache.org/docs/2.0.0/api/java/org/apache/spark/RangePartitioner.html

      The Double values I'm trying to sort are mostly in the range [0,1] (~70% of the data which roughly equates 1 billion records), other numbers in the dataset are as high as 2000. With the RangePartitioner trying to create equal ranges, some tasks are becoming almost empty while others are extremely large, due to the heavily skewed distribution.

      This is either a bug in Apache Spark or a major limitation of the framework. I hope one of the devs can help solve this issue.

      P.S. Email thread on Spark user mailing list:


          Issue Links



              • Assignee:
                cloud_fan Wenchen Fan
                babak.alipour@gmail.com Babak Alipour
              • Votes:
                0 Vote for this issue
                10 Start watching this issue


                • Created: