Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 29.4k
SPARK-1656: Fix potential resource leaks#577
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
071fdd1afc33834521d6e28b90dc2de96e5c431095File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -73,7 +73,22 @@ private[spark] class DiskStore(blockManager: BlockManager, diskManager: DiskBloc | ||
| val startTime = System.currentTimeMillis | ||
| val file = diskManager.getFile(blockId) | ||
| val outputStream = new FileOutputStream(file) | ||
| blockManager.dataSerializeStream(blockId, outputStream, values) | ||
| try { | ||
| try { | ||
| blockManager.dataSerializeStream(blockId, outputStream, values) | ||
| } finally { | ||
| // Close outputStream here because it should be closed before file is deleted. | ||
| outputStream.close() | ||
| } | ||
| } catch { | ||
| case e: Throwable => { | ||
| if (file.exists()) { | ||
| file.delete() | ||
| } | ||
| throw e | ||
| } | ||
| } | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think what you had before was actually clearer. Nested MemberAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I noticed that Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm I'm still not so sure about having the nested MemberAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The previous codes are: 1try {
2 blockManager.dataSerializeStream(blockId, outputStream, values)
3 outputStream.close()
4 } catch {
5casee: Throwable=> {
6 outputStream.close()
7if(file.exists()) {
8 file.delete()
9 }
10throw e
11 }
12 }My concern is if L6 outputStream.close() throws an exception, MemberAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @andrewor14 do you agree my concern? Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, that seems fine. | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not do the full MemberAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I want to close the stream before deleting the file. Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On Unix at least that's not necessary. It's possible to delete a file with open fds. The inodes will be released when you close the fd. Don't know if Windows follows the same semantics, though. | ||
| val length = file.length | ||
| val timeTaken = System.currentTimeMillis - startTime | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you actually want to handle this case; you should delete the file in case write failed.