You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Herman van Hövell (Jira)" <ji...@apache.org> on 2020/10/08 08:00:17 UTC

[jira] [Updated] (SPARK-32901) UnsafeExternalSorter may cause a SparkOutOfMemoryError to be thrown while spilling

     [ https://issues.apache.org/jira/browse/SPARK-32901?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Herman van Hövell updated SPARK-32901:
--------------------------------------
    Fix Version/s: 2.4.8

> UnsafeExternalSorter may cause a SparkOutOfMemoryError to be thrown while spilling
> ----------------------------------------------------------------------------------
>
>                 Key: SPARK-32901
>                 URL: https://issues.apache.org/jira/browse/SPARK-32901
>             Project: Spark
>          Issue Type: Bug
>          Components: Spark Core
>    Affects Versions: 2.4.7, 3.0.1
>            Reporter: Tom van Bussel
>            Assignee: Tom van Bussel
>            Priority: Major
>             Fix For: 2.4.8, 3.0.2, 3.1.0
>
>
> Consider the following sequence of events:
>  # {{UnsafeExternalSorter}} runs out of space in its pointer array and attempts to allocate a large array to replace the current one.
>  # {{TaskMemoryManager}} tries to allocate the memory backing the large array using {{MemoryManager}}, but {{MemoryManager}} is only willing to return most but not all of the memory requested.
>  # {{TaskMemoryManager}} asks {{UnsafeExternalSorter}} to spill, which causes {{UnsafeExternalSorter}} to spill the current run to disk, to free its record pages and to reset its {{UnsafeInMemorySorter}}.
>  # {{UnsafeInMemorySorter}} frees its pointer array, and tries to allocate a new small pointer array.
>  # {{TaskMemoryManager}} tries to allocate the memory backing the small array using {{MemoryManager}}, but {{MemoryManager}} is unwilling to give it any memory, as the {{TaskMemoryManager}} is still holding on to the memory it got for the large array.
>  # {{TaskMemoryManager}} again asks {{UnsafeExternalSorter}} to spill, but this time there is nothing to spill.
>  # {{UnsafeInMemorySorter}} receives less memory than it requested, and causes a {{SparkOutOfMemoryError}} to be thrown, which causes the current task to fail.
> A simple way to fix this is to avoid allocating a new array in {{UnsafeInMemorySorter.reset()}} and to do this on-demand instead.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org