forked from apache/flink
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FLINK-22424][network] Prevent releasing PipelinedSubpartition while …
…Task can still write to it This bug was happening when a downstream tasks were failing over or being cancelled. If all of the downstream tasks released subpartition views, underlying memory segments/buffers could have been recycled, while upstream task was still writting some records. The problem is fixed by adding the writer (result partition) itself as one more reference counted user of the result partition
- Loading branch information
1 parent
5948039
commit 211751c
Showing
5 changed files
with
164 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
113 changes: 113 additions & 0 deletions
113
...-runtime/src/test/java/org/apache/flink/runtime/io/network/buffer/UnpooledBufferPool.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
/* | ||
* 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.flink.runtime.io.network.buffer; | ||
|
||
import org.apache.flink.core.memory.MemorySegment; | ||
import org.apache.flink.core.memory.MemorySegmentFactory; | ||
|
||
import java.util.concurrent.CompletableFuture; | ||
|
||
/** Implementation of {@link BufferPool} that works on un-pooled memory segments. */ | ||
public class UnpooledBufferPool implements BufferPool { | ||
|
||
private static final int SEGMENT_SIZE = 1024; | ||
|
||
@Override | ||
public void lazyDestroy() {} | ||
|
||
@Override | ||
public Buffer requestBuffer() { | ||
return new NetworkBuffer(requestMemorySegment(), this); | ||
} | ||
|
||
@Override | ||
public BufferBuilder requestBufferBuilder() { | ||
return new BufferBuilder(requestMemorySegment(), this); | ||
} | ||
|
||
private MemorySegment requestMemorySegment() { | ||
return MemorySegmentFactory.allocateUnpooledOffHeapMemory(SEGMENT_SIZE, null); | ||
} | ||
|
||
@Override | ||
public BufferBuilder requestBufferBuilderBlocking() throws InterruptedException { | ||
return requestBufferBuilder(); | ||
} | ||
|
||
@Override | ||
public BufferBuilder requestBufferBuilder(int targetChannel) { | ||
return requestBufferBuilder(); | ||
} | ||
|
||
@Override | ||
public BufferBuilder requestBufferBuilderBlocking(int targetChannel) | ||
throws InterruptedException { | ||
return requestBufferBuilder(); | ||
} | ||
|
||
@Override | ||
public boolean addBufferListener(BufferListener listener) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public boolean isDestroyed() { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public int getNumberOfRequiredMemorySegments() { | ||
return Integer.MAX_VALUE; | ||
} | ||
|
||
@Override | ||
public int getMaxNumberOfMemorySegments() { | ||
return -1; | ||
} | ||
|
||
@Override | ||
public int getNumBuffers() { | ||
return Integer.MAX_VALUE; | ||
} | ||
|
||
@Override | ||
public void setNumBuffers(int numBuffers) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public int getNumberOfAvailableMemorySegments() { | ||
return Integer.MAX_VALUE; | ||
} | ||
|
||
@Override | ||
public int bestEffortGetNumOfUsedBuffers() { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public void recycle(MemorySegment memorySegment) { | ||
memorySegment.free(); | ||
} | ||
|
||
@Override | ||
public CompletableFuture<?> getAvailableFuture() { | ||
return AVAILABLE; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters