-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-26418][SHUFFLE] Only OpenBlocks without any ChunkFetch for one stream will cause memory leak in ExternalShuffleService #23355
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 1 commit
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 |
|---|---|---|
|
|
@@ -23,6 +23,7 @@ | |
| import java.util.concurrent.ConcurrentHashMap; | ||
| import java.util.concurrent.atomic.AtomicLong; | ||
|
|
||
| import com.google.common.annotations.VisibleForTesting; | ||
| import com.google.common.base.Preconditions; | ||
| import io.netty.channel.Channel; | ||
| import org.apache.commons.lang3.tuple.ImmutablePair; | ||
|
|
@@ -202,4 +203,8 @@ public long registerStream(String appId, Iterator<ManagedBuffer> buffers) { | |
| return myStreamId; | ||
| } | ||
|
|
||
| @VisibleForTesting | ||
| public long getStreamsSize() { | ||
|
||
| return streams.size(); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.apache.spark.network.shuffle; | ||
|
|
||
| import io.netty.channel.Channel; | ||
| import org.apache.spark.network.buffer.ManagedBuffer; | ||
|
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. Spark imports go into their own group. See existing code. |
||
| import org.apache.spark.network.buffer.NioManagedBuffer; | ||
| import org.apache.spark.network.client.RpcResponseCallback; | ||
| import org.apache.spark.network.client.TransportClient; | ||
| import org.apache.spark.network.client.TransportResponseHandler; | ||
| import org.apache.spark.network.server.OneForOneStreamManager; | ||
| import org.apache.spark.network.server.RpcHandler; | ||
| import org.apache.spark.network.shuffle.protocol.OpenBlocks; | ||
| import org.junit.Test; | ||
|
|
||
| import java.nio.ByteBuffer; | ||
|
||
|
|
||
| import static org.mockito.Mockito.mock; | ||
| import static org.mockito.Mockito.when; | ||
|
|
||
| public class StreamStatesCleanupSuite { | ||
|
|
||
| @Test | ||
| public void testStreamsAreRemovedCorrectly() { | ||
| OneForOneStreamManager streamManager = new OneForOneStreamManager(); | ||
| ExternalShuffleBlockResolver blockResolver = mock(ExternalShuffleBlockResolver.class); | ||
| TransportClient reverseClient | ||
| = new TransportClient(mock(Channel.class), mock(TransportResponseHandler.class)); | ||
| RpcHandler handler = new ExternalShuffleBlockHandler(streamManager, blockResolver); | ||
|
|
||
| ManagedBuffer block0Marker = new NioManagedBuffer(ByteBuffer.wrap(new byte[3])); | ||
| ManagedBuffer block1Marker = new NioManagedBuffer(ByteBuffer.wrap(new byte[7])); | ||
| when(blockResolver.getBlockData("app0", "exec1", 0, 0, 0)) | ||
| .thenReturn(block0Marker); | ||
| when(blockResolver.getBlockData("app0", "exec1", 0, 0, 1)) | ||
| .thenReturn(block1Marker); | ||
| ByteBuffer openBlocks = new OpenBlocks("app0", "exec1", | ||
| new String[]{"shuffle_0_0_0", "shuffle_0_0_1"}) | ||
| .toByteBuffer(); | ||
|
|
||
| RpcResponseCallback callback = mock(RpcResponseCallback.class); | ||
|
|
||
| // Open blocks | ||
| handler.receive(reverseClient, openBlocks, callback); | ||
|
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. Assert stream count after receiving an |
||
| // Connection closed before any FetchChunk request received | ||
| streamManager.connectionTerminated(reverseClient.getChannel()); | ||
|
|
||
| assert streamManager.getStreamsSize() == 0; | ||
|
||
| } | ||
|
|
||
| } | ||
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.
I think if you remove this, you should add it back to
NettyBlockRpcServerfor 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! Added it back to
NettyBlockRpcServer.