Github user mridulm commented on a diff in the pull request: https://github.com/apache/spark/pull/1609#discussion_r15542308 --- Diff: core/src/main/scala/org/apache/spark/util/collection/ExternalAppendOnlyMap.scala --- @@ -418,7 +459,25 @@ class ExternalAppendOnlyMap[K, V, C]( // TODO: Ensure this gets called even if the iterator isn't drained. private def cleanup() { - deserializeStream.close() + batchIndex = batchOffsets.length + val dstrm = deserializeStream + val fstrm = fileStream + deserializeStream = null + fileStream = null + + if (dstrm ne null) { + try { + dstrm.close() + } catch { + case ioEx: IOException => { + // best case attempt - atleast free the handles + if (fstrm ne null) { + try { fstrm.close() } catch {case ioEx: IOException => } + } + throw ioEx + } + } + } --- End diff -- This is just more defensive cleanup compared to earlier and setting batchIndex to unusable value. To ensure that any close related exceptions do not result in unclosed files (which impacts ulimit of spark process)
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---