-
Notifications
You must be signed in to change notification settings - Fork 29.3k
[SPARK-30246][CORE] OneForOneStreamManager might leak memory in connectionTerminated #27064
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
Changes from 2 commits
22def77
a9ebe4f
410651d
ac58798
b02e48a
0fde4c9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -18,6 +18,7 @@ | |||||||||||||||||||||||
| package org.apache.spark.network.server; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| import java.util.Iterator; | ||||||||||||||||||||||||
| import java.util.LinkedList; | ||||||||||||||||||||||||
| import java.util.Map; | ||||||||||||||||||||||||
| import java.util.Random; | ||||||||||||||||||||||||
| import java.util.concurrent.ConcurrentHashMap; | ||||||||||||||||||||||||
|
|
@@ -117,19 +118,26 @@ public static Pair<Long, Integer> parseStreamChunkId(String streamChunkId) { | |||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| @Override | ||||||||||||||||||||||||
| public void connectionTerminated(Channel channel) { | ||||||||||||||||||||||||
| LinkedList<StreamState> removedStates = new LinkedList<>(); | ||||||||||||||||||||||||
| // Close all streams which have been associated with the channel. | ||||||||||||||||||||||||
| for (Map.Entry<Long, StreamState> entry: streams.entrySet()) { | ||||||||||||||||||||||||
| StreamState state = entry.getValue(); | ||||||||||||||||||||||||
| if (state.associatedChannel == channel) { | ||||||||||||||||||||||||
| streams.remove(entry.getKey()); | ||||||||||||||||||||||||
| removedStates.add(streams.remove(entry.getKey())); | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| // Release all remaining buffers. | ||||||||||||||||||||||||
| for (StreamState state: removedStates) { | ||||||||||||||||||||||||
| // Release all remaining buffers. | ||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||
| while (state.buffers.hasNext()) { | ||||||||||||||||||||||||
| ManagedBuffer buffer = state.buffers.next(); | ||||||||||||||||||||||||
|
Member
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. Once we got RuntimeException, don't we just fail? Is there memory leak?
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. Lines 87 to 97 in 1b0570c
Member
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. oh I see. Then this change may also swallow the RuntimeException so
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. So I think there're two options here with achieving goal;
Technically the change from logging side would be logger name which may not a big deal, but it's also valid concern if we think channelInactive is the one to decide how to handle the exception.
Member
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. yea, I think it might make the caller (channelInactive or others if any) thinks everything is fine inside We might have multiple exception during releasing buffers. We can rethrow a
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 thanks for the input. @hensg Could you follow up the comment above? Thanks! |
||||||||||||||||||||||||
| if (buffer != null) { | ||||||||||||||||||||||||
| buffer.release(); | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| } catch (RuntimeException e) { | ||||||||||||||||||||||||
| logger.error("Exception trying to release remaining StreamState buffers", e); | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.