Skip to content

[SPARK-7181][CORE]fix inifite loop in Externalsorter's mergeWithAggregation #5737

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,8 @@ private[spark] class ExternalSorter[K, V, C](
val k = elem._1
var c = elem._2
while (sorted.hasNext && sorted.head._1 == k) {
c = mergeCombiners(c, sorted.head._2)
val pair = sorted.next()
c = mergeCombiners(c, pair._2)
}
(k, c)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,10 @@ class ExternalSorterSuite extends FunSuite with LocalSparkContext with PrivateMe
val agg = new Aggregator[Int, Int, Int](i => i, (i, j) => i + j, (i, j) => i + j)
val ord = implicitly[Ordering[Int]]
val sorter = new ExternalSorter(Some(agg), Some(new HashPartitioner(3)), Some(ord), None)
sorter.insertAll((0 until 100000).iterator.map(i => (i / 2, i)))

// avoid combine before spill
sorter.insertAll((0 until 50000).iterator.map(i => (i , 2 * i)))
sorter.insertAll((0 until 50000).iterator.map(i => (i, 2 * i + 1)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this actually run the case that you modified? (i.e. did this modified test fail before your fix?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it failed on my computer(this testcase didn't stop). I set the memory limit to a small value on my computer to ganrantee spills. I think we can also set spark.shuffle.memoryFraction to a small value to do this. The origin value of spark.shuffle.memoryFraction is 0.001, I don't know if it can ganrantee spills. If not, we should change it to a smaller value.

val results = sorter.partitionedIterator.map{case (p, vs) => (p, vs.toSet)}.toSet
val expected = (0 until 3).map(p => {
(p, (0 until 50000).map(i => (i, i * 4 + 1)).filter(_._1 % 3 == p).toSet)
Expand Down