Uh oh!
There was an error while loading. Please reload this page.
[SPARK-26418][SHUFFLE] Only OpenBlocks without any ChunkFetch for one stream will cause memory leak in ExternalShuffleService - #23355
Conversation
beliefer
commented
Dec 20, 2018
If ExternalShuffleService only received a OpenBlocks message, not received any ChunkFetchRequest message, associate StreamState is hold by streams. |
wangshuo128
commented
Dec 20, 2018
Let me explain my problem in detail. We use In current code, server creates I think two reasons will cause this:
Currently the |
vanzin
left a comment
There was a problem hiding this comment.
This seems fine given the client code will always use the same client.
You could clean up application state in ExternalShuffleBlockHandler.applicationRemoved, but this is simpler.
| // Connection closed before any FetchChunk request received | ||
| streamManager.connectionTerminated(reverseClient.getChannel()); | ||
| assert streamManager.getStreamsSize() == 0; |
| import org.apache.spark.network.shuffle.protocol.OpenBlocks; | ||
| import org.junit.Test; | ||
| import java.nio.ByteBuffer; |
| package org.apache.spark.network.shuffle; | ||
| import io.netty.channel.Channel; | ||
| import org.apache.spark.network.buffer.ManagedBuffer; |
There was a problem hiding this comment.
Spark imports go into their own group. See existing code.
| } | ||
| @VisibleForTesting | ||
| public long getStreamsSize() { |
vanzin
commented
Dec 20, 2018
Also, please explain the fix, not the problem, in the PR. |
vanzin
commented
Dec 20, 2018
ok to test |
SparkQA
commented
Dec 21, 2018
Test build #100344 has finished for PR 23355 at commit
|
I check |
@vanzin
I will add some explanation about the fix in the PR description. Thank you. |
SparkQA
commented
Dec 21, 2018
Test build #100355 has finished for PR 23355 at commit
|
wangshuo128
commented
Dec 24, 2018
@vanzin |
beliefer
left a comment
There was a problem hiding this comment.
This change is so clearly.
There was a problem hiding this comment.
Agree with @vanzin that change's fine since OpenBlocks and fetchChunk would always use the same client.
A minor concern is:
Since we always register the channel when we receive the FetchChunkRequest in the past, so the associated channel with the stream will aways be correct. And for this change, if user call sendRpc(OpenBlocks) and fetchChunk with different client, then, we may record the wrong channel(which is the OpenBlocks chanel, rather than fetchChunk channel) with the stream which is being fetched, which may fall into the same issue as this pr fixed. So, I think we should leave some comment above fetchChunk to notify user that this method must use the same client with the OpenBlocks, otherwise, there may be potential memory leak.
| ManagedBuffer buf; | ||
| try { | ||
| streamManager.checkAuthorization(client, msg.streamChunkId.streamId); | ||
| streamManager.registerChannel(channel, msg.streamChunkId.streamId); |
There was a problem hiding this comment.
I think if you remove this, you should add it back to NettyBlockRpcServer for non external shuffle service. Otherwise, you'll introduce the bug you fixed with pr to the non external shuffle service.
There was a problem hiding this comment.
Good catch! Added it back to NettyBlockRpcServer.
| RpcResponseCallback callback = mock(RpcResponseCallback.class); | ||
| // Open blocks | ||
| handler.receive(reverseClient, openBlocks, callback); |
There was a problem hiding this comment.
Assert stream count after receiving an OpenBlocks message.
Ngone51
commented
Jan 15, 2019
Hi @wangshuo128 , did you see the issue was resolved with this pr ? |
wangshuo128
commented
Jan 15, 2019
@Ngone51 Thanks a lot for comment and review!
I had the same concern too. I added some comment at TransportClient.fetchChunk . |
wangshuo128
commented
Jan 15, 2019
cc @viirya@cloud-fan@gatorsmile Could you give some advice about this PR? Thanks! |
cloud-fan
commented
Jan 15, 2019
is it same as #23521 ? |
SparkQA
commented
Jan 15, 2019
Test build #101239 has finished for PR 23355 at commit
|
|
wangshuo128
commented
Jan 16, 2019
@Ngone51@cloud-fan Yes, found that this pr is same as 23521 and 23521 is better. I will close this pr. Thank you. Also thanks @viirya ! |
Ngone51
commented
Jan 16, 2019
@wangshuo128 ??? Why is better ? I can't get understand. #23521 does not intend to fix the issue you proposed here. And the time for registering a channel is obviously different between these two prs. |
wangshuo128
commented
Jan 16, 2019
Ngone51
commented
Jan 16, 2019
oh, I miss the newest update, they're same now. Sorry, @wangshuo128 . |
What changes were proposed in this pull request?
In current code path,
OneForOneStreamManagerholdsStreamStatein a Map namedstreams.A
StreamStateis initialized and put intostreamswhenOpenBlocksrequest received.One specific
StreamStateis removed from streams in two scenarios below:ChunkFetchRequestis closedStreamStatewill never be clean up, ifOpenBlocksrequest is received without any followingChunkFetchRequest. This will cause memory leak in server side, which is harmful for long running service such asExternalShuffleService.This PR associates
StreamStatewith channel when handleOpenBlocksrequest, becauseOpenBlocksrequest and followingChunkFetchRequests for a specific stream are sent from the sameTransportClientinOneForOneBlockFetcher.How was this patch tested?
New test added.