You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2020/09/28 11:08:41 UTC
[GitHub] [flink] curcur opened a new pull request #13501: Single task result partition type
curcur opened a new pull request #13501:
URL: https://github.com/apache/flink/pull/13501
## What is the purpose of the change
Introduce a new ResultPartitionType: `ResultPartitionType.PIPELINED_APPROXIMATE` to match with a new subpartitoin type `PipelinedApproximateSubpartition`/`PipelinedApproximateSubpartitionView`.
* {@link ResultPartitionType#PIPELINED_APPROXIMATE} is different from {@link ResultPartitionType#PIPELINED_BOUNDED} in that * {@link ResultPartitionType#PIPELINED_APPROXIMATE} is not decomposed automatically after consumption.
## Brief change log
*(for example:)*
- *The TaskInfo is stored in the blob store on job creation time as a persistent artifact*
- *Deployments RPC transmits only the blob storage reference*
- *TaskManagers retrieve the TaskInfo from the blob cache*
## Verifying this change
*(Please pick either of the following options)*
This change is a trivial rework / code cleanup without any test coverage.
*(or)*
This change is already covered by existing tests, such as *(please describe tests)*.
*(or)*
This change added tests and can be verified as follows:
*(example:)*
- *Added integration tests for end-to-end deployment with large payloads (100MB)*
- *Extended integration test for recovery after master (JobManager) failure*
- *Added test that validates that TaskInfo is transferred only once across recoveries*
- *Manually verified the change by running a 4 node cluser with 2 JobManagers and 4 TaskManagers, a stateful streaming program, and killing one JobManager and two TaskManagers during the execution, verifying that recovery happens correctly.*
## Does this pull request potentially affect one of the following parts:
- Dependencies (does it add or upgrade a dependency): (yes / no)
- The public API, i.e., is any changed class annotated with `@Public(Evolving)`: (yes / no)
- The serializers: (yes / no / don't know)
- The runtime per-record code paths (performance sensitive): (yes / no / don't know)
- Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn/Mesos, ZooKeeper: (yes / no / don't know)
- The S3 file system connector: (yes / no / don't know)
## Documentation
- Does this pull request introduce a new feature? (yes / no)
- If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] AHeise commented on pull request #13501: Single task result partition type
Posted by GitBox <gi...@apache.org>.
AHeise commented on pull request #13501:
URL: https://github.com/apache/flink/pull/13501#issuecomment-702912020
I also had the idea to simply introduce a new Buffer type PARTIAL_DATA_BUFFER that is set by the deserializer. Then, we would be able to skip without any magic.
I'm currently too tired to assess whether we actual need the record length information or if it's enough to know if a given buffer is a complete record or not.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] curcur commented on a change in pull request #13501: Single task result partition type
Posted by GitBox <gi...@apache.org>.
curcur commented on a change in pull request #13501:
URL: https://github.com/apache/flink/pull/13501#discussion_r498883527
##########
File path: flink-runtime/src/main/java/org/apache/flink/runtime/io/network/partition/PipelinedApproximateSubpartition.java
##########
@@ -0,0 +1,138 @@
+package org.apache.flink.runtime.io.network.partition;
+
+import org.apache.flink.runtime.io.network.buffer.Buffer;
+import org.apache.flink.runtime.io.network.buffer.BufferConsumer;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.annotation.Nullable;
+
+import static org.apache.flink.util.Preconditions.checkState;
+
+public class PipelinedApproximateSubpartition extends PipelinedSubpartition {
+
+ private static final Logger LOG = LoggerFactory.getLogger(PipelinedApproximateSubpartition.class);
+
+ private boolean isPartialBuffer = false;
+
+ PipelinedApproximateSubpartition(int index, ResultPartition parent) {
+ super(index, parent);
+ }
+
+ public void releaseView() {
+ readView = null;
+ isPartialBuffer = true;
+ isBlockedByCheckpoint = false;
+ sequenceNumber = 0;
+ }
+
+ @Override
+ public PipelinedSubpartitionView createReadView(BufferAvailabilityListener availabilityListener) {
+ synchronized (buffers) {
+ checkState(!isReleased);
+
+ // if the view is not released yet
+ if (readView != null) {
+ releaseView();
+ }
+
+ LOG.debug("{}: Creating read view for subpartition {} of partition {}.",
+ parent.getOwningTaskName(), getSubPartitionIndex(), parent.getPartitionId());
+
+ readView = new PipelinedApproximateSubpartitionView(this, availabilityListener);
+ }
+
+ return readView;
+ }
+
+ @Nullable
+ @Override
+ BufferAndBacklog pollBuffer() {
Review comment:
the difference is :
```
buffer = bufferConsumer.build();
```
==>
```
if (isPartialBuffer) {
BufferConsumer.PartialRecordCleanupResult result = bufferConsumer.skipPartialRecord();
buffer = result.getBuffer();
isPartialBuffer = result.getCleaned();
} else {
buffer = bufferConsumer.build();
}
```
That's why this method is very clean, it limits the change to very few classes/methods.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #13501: Single task result partition type --- the most original one
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #13501:
URL: https://github.com/apache/flink/pull/13501#issuecomment-699941154
Thanks a lot for your contribution to the Apache Flink project. I'm the @flinkbot. I help the community
to review your pull request. We will use this comment to track the progress of the review.
## Automated Checks
Last check on commit 810706f4c5550bd8691799c78e44aa6a80a132b6 (Fri Feb 19 07:32:44 UTC 2021)
**Warnings:**
* No documentation files were touched! Remember to keep the Flink docs up to date!
* **Invalid pull request title: No valid Jira ID provided**
<sub>Mention the bot in a comment to re-run the automated checks.</sub>
## Review Progress
* ❓ 1. The [description] looks good.
* ❓ 2. There is [consensus] that the contribution should go into to Flink.
* ❓ 3. Needs [attention] from.
* ❓ 4. The change fits into the overall [architecture].
* ❓ 5. Overall code [quality] is good.
Please see the [Pull Request Review Guide](https://flink.apache.org/contributing/reviewing-prs.html) for a full explanation of the review process.<details>
The Bot is tracking the review progress through labels. Labels are applied according to the order of the review items. For consensus, approval by a Flink committer of PMC member is required <summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot approve description` to approve one or more aspects (aspects: `description`, `consensus`, `architecture` and `quality`)
- `@flinkbot approve all` to approve all aspects
- `@flinkbot approve-until architecture` to approve everything until `architecture`
- `@flinkbot attention @username1 [@username2 ..]` to require somebody's attention
- `@flinkbot disapprove architecture` to remove an approval you gave earlier
</details>
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] AHeise commented on a change in pull request #13501: Single task result partition type
Posted by GitBox <gi...@apache.org>.
AHeise commented on a change in pull request #13501:
URL: https://github.com/apache/flink/pull/13501#discussion_r497014099
##########
File path: flink-runtime/src/main/java/org/apache/flink/runtime/io/network/partition/ResultPartitionFactory.java
##########
@@ -131,8 +132,15 @@ public ResultPartition create(
bufferCompressor,
bufferPoolFactory);
- for (int i = 0; i < subpartitions.length; i++) {
- subpartitions[i] = new PipelinedSubpartition(i, pipelinedPartition);
+ if (type == ResultPartitionType.PIPELINED_APPROXIMATE) {
Review comment:
If we expect more partitions type, I'd rather see some factory lambda being extracted and used.
```
BiFunction<Integer, PipelinedResultPartition, PipelinedSubpartition> factory;
if (type == ResultPartitionType.PIPELINED_APPROXIMATE) {
factory = PipelinedApproximateSubpartition::new;
} else {
factory = PipelinedSubpartition::new;
}
for (int i = 0; i < subpartitions.length; i++) {
subpartitions[i] = factory.apply(i, pipelinedPartition);
}
```
##########
File path: flink-runtime/src/main/java/org/apache/flink/runtime/io/network/partition/PipelinedApproximateSubpartition.java
##########
@@ -0,0 +1,138 @@
+package org.apache.flink.runtime.io.network.partition;
+
+import org.apache.flink.runtime.io.network.buffer.Buffer;
+import org.apache.flink.runtime.io.network.buffer.BufferConsumer;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.annotation.Nullable;
+
+import static org.apache.flink.util.Preconditions.checkState;
+
+public class PipelinedApproximateSubpartition extends PipelinedSubpartition {
+
+ private static final Logger LOG = LoggerFactory.getLogger(PipelinedApproximateSubpartition.class);
+
+ private boolean isPartialBuffer = false;
+
+ PipelinedApproximateSubpartition(int index, ResultPartition parent) {
+ super(index, parent);
+ }
+
+ public void releaseView() {
+ readView = null;
+ isPartialBuffer = true;
+ isBlockedByCheckpoint = false;
+ sequenceNumber = 0;
+ }
+
+ @Override
+ public PipelinedSubpartitionView createReadView(BufferAvailabilityListener availabilityListener) {
+ synchronized (buffers) {
+ checkState(!isReleased);
+
+ // if the view is not released yet
+ if (readView != null) {
+ releaseView();
+ }
+
+ LOG.debug("{}: Creating read view for subpartition {} of partition {}.",
+ parent.getOwningTaskName(), getSubPartitionIndex(), parent.getPartitionId());
+
+ readView = new PipelinedApproximateSubpartitionView(this, availabilityListener);
+ }
+
+ return readView;
+ }
+
+ @Nullable
+ @Override
+ BufferAndBacklog pollBuffer() {
+ synchronized (buffers) {
+ if (isBlockedByCheckpoint) {
+ return null;
+ }
+
+ Buffer buffer = null;
+
+ if (buffers.isEmpty()) {
+ flushRequested = false;
+ }
+
+ while (!buffers.isEmpty()) {
+ BufferConsumer bufferConsumer = buffers.peek();
+
+ // `isPartialBuffer` is set to true in the same Netty thread when ResultPartitionView is released
+ if (isPartialBuffer) {
+ BufferConsumer.PartialRecordCleanupResult result = bufferConsumer.skipPartialRecord();
+ buffer = result.getBuffer();
+ isPartialBuffer = !result.getCleaned();
+ } else {
+ buffer = bufferConsumer.build();
+ }
+
+ checkState(bufferConsumer.isFinished() || buffers.size() == 1,
+ "When there are multiple buffers, an unfinished bufferConsumer can not be at the head of the buffers queue.");
+
+ if (buffers.size() == 1) {
+ // turn off flushRequested flag if we drained all of the available data
+ flushRequested = false;
+ }
+
+ if (bufferConsumer.isFinished()) {
+ buffers.poll().close();
+ decreaseBuffersInBacklogUnsafe(bufferConsumer.isBuffer());
+ }
+
+ if (buffer.readableBytes() > 0) {
+ break;
+ }
+
+ buffer.recycleBuffer();
+ buffer = null;
+
+ if (!bufferConsumer.isFinished()) {
+ break;
+ }
+ }
+
+ if (buffer == null) {
+ return null;
+ }
+
+ if (buffer.getDataType().isBlockingUpstream()) {
+ isBlockedByCheckpoint = true;
+ }
+
+ updateStatistics(buffer);
+ // Do not report last remaining buffer on buffers as available to read (assuming it's unfinished).
+ // It will be reported for reading either on flush or when the number of buffers in the queue
+ // will be 2 or more.
+ return new BufferAndBacklog(
+ buffer,
+ getBuffersInBacklog(),
+ isDataAvailableUnsafe() ? getNextBufferTypeUnsafe() : Buffer.DataType.NONE,
+ sequenceNumber++);
+ }
+ }
+
+ @Override
+ public String toString() {
+ final long numBuffers;
+ final long numBytes;
+ final boolean finished;
+ final boolean hasReadView;
+
+ synchronized (buffers) {
Review comment:
You'd usually assume that toString is called under lock (also in IDE). (I'm not aware of such a complicated `toString`).
##########
File path: flink-streaming-java/src/main/java/org/apache/flink/streaming/api/environment/StreamExecutionEnvironment.java
##########
@@ -358,6 +361,12 @@ public long getBufferTimeout() {
return this.bufferTimeout;
}
+
+ public StreamExecutionEnvironment setGlobalDataExchangeMode(GlobalDataExchangeMode globalDataExchangeMode) {
Review comment:
I'd probably not expose `GlobalDataExchangeMode` directly, but rather go with `enableApproximateSinkFailover`.
##########
File path: flink-runtime/src/main/java/org/apache/flink/runtime/io/network/partition/PipelinedApproximateSubpartition.java
##########
@@ -0,0 +1,138 @@
+package org.apache.flink.runtime.io.network.partition;
+
+import org.apache.flink.runtime.io.network.buffer.Buffer;
+import org.apache.flink.runtime.io.network.buffer.BufferConsumer;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.annotation.Nullable;
+
+import static org.apache.flink.util.Preconditions.checkState;
+
+public class PipelinedApproximateSubpartition extends PipelinedSubpartition {
+
+ private static final Logger LOG = LoggerFactory.getLogger(PipelinedApproximateSubpartition.class);
+
+ private boolean isPartialBuffer = false;
+
+ PipelinedApproximateSubpartition(int index, ResultPartition parent) {
+ super(index, parent);
+ }
+
+ public void releaseView() {
+ readView = null;
+ isPartialBuffer = true;
+ isBlockedByCheckpoint = false;
+ sequenceNumber = 0;
+ }
+
+ @Override
+ public PipelinedSubpartitionView createReadView(BufferAvailabilityListener availabilityListener) {
+ synchronized (buffers) {
+ checkState(!isReleased);
+
+ // if the view is not released yet
+ if (readView != null) {
+ releaseView();
+ }
+
+ LOG.debug("{}: Creating read view for subpartition {} of partition {}.",
+ parent.getOwningTaskName(), getSubPartitionIndex(), parent.getPartitionId());
+
+ readView = new PipelinedApproximateSubpartitionView(this, availabilityListener);
+ }
+
+ return readView;
+ }
+
+ @Nullable
+ @Override
+ BufferAndBacklog pollBuffer() {
Review comment:
Instead of copying&adjusting the whole method, I'd like to see some inner method being extracted in the base class and being overwritten here.
##########
File path: flink-runtime/src/main/java/org/apache/flink/runtime/io/network/partition/PipelinedApproximateSubpartition.java
##########
@@ -0,0 +1,138 @@
+package org.apache.flink.runtime.io.network.partition;
+
+import org.apache.flink.runtime.io.network.buffer.Buffer;
+import org.apache.flink.runtime.io.network.buffer.BufferConsumer;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.annotation.Nullable;
+
+import static org.apache.flink.util.Preconditions.checkState;
+
+public class PipelinedApproximateSubpartition extends PipelinedSubpartition {
+
+ private static final Logger LOG = LoggerFactory.getLogger(PipelinedApproximateSubpartition.class);
+
+ private boolean isPartialBuffer = false;
+
+ PipelinedApproximateSubpartition(int index, ResultPartition parent) {
+ super(index, parent);
+ }
+
+ public void releaseView() {
+ readView = null;
+ isPartialBuffer = true;
+ isBlockedByCheckpoint = false;
+ sequenceNumber = 0;
+ }
+
+ @Override
+ public PipelinedSubpartitionView createReadView(BufferAvailabilityListener availabilityListener) {
+ synchronized (buffers) {
+ checkState(!isReleased);
+
+ // if the view is not released yet
+ if (readView != null) {
+ releaseView();
+ }
+
+ LOG.debug("{}: Creating read view for subpartition {} of partition {}.",
+ parent.getOwningTaskName(), getSubPartitionIndex(), parent.getPartitionId());
+
+ readView = new PipelinedApproximateSubpartitionView(this, availabilityListener);
+ }
+
+ return readView;
+ }
+
+ @Nullable
+ @Override
+ BufferAndBacklog pollBuffer() {
Review comment:
That would also avoid some of the visibility changes of the fields in the base class.
##########
File path: flink-runtime/src/main/java/org/apache/flink/runtime/io/network/partition/PipelinedApproximateSubpartitionView.java
##########
@@ -0,0 +1,27 @@
+package org.apache.flink.runtime.io.network.partition;
+
+import static org.apache.flink.util.Preconditions.checkState;
+
+public class PipelinedApproximateSubpartitionView extends PipelinedSubpartitionView {
+
+ PipelinedApproximateSubpartitionView(PipelinedApproximateSubpartition parent, BufferAvailabilityListener listener) {
+ super(parent, listener);
+ }
+
+ @Override
+ public void releaseAllResources() {
+ if (isReleased.compareAndSet(false, true)) {
+ // The view doesn't hold any resources and the parent cannot be restarted. Therefore,
+ // it's OK to notify about consumption as well.
+ checkState(parent instanceof PipelinedApproximateSubpartition);
+ ((PipelinedApproximateSubpartition) parent).releaseView();
Review comment:
It might also be an option to replicate the field in this class with `PipelinedApproximateSubpartition` (a slightly different name would also be good like `approximateParent`).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #13501: Single task result partition type
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #13501:
URL: https://github.com/apache/flink/pull/13501#issuecomment-699944339
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "63450ff4d3f109854d55980aeaa87ec8dcc7e9ca",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "63450ff4d3f109854d55980aeaa87ec8dcc7e9ca",
"triggerType" : "PUSH"
}, {
"hash" : "810706f4c5550bd8691799c78e44aa6a80a132b6",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "810706f4c5550bd8691799c78e44aa6a80a132b6",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 63450ff4d3f109854d55980aeaa87ec8dcc7e9ca UNKNOWN
* 810706f4c5550bd8691799c78e44aa6a80a132b6 UNKNOWN
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] curcur commented on a change in pull request #13501: Single task result partition type
Posted by GitBox <gi...@apache.org>.
curcur commented on a change in pull request #13501:
URL: https://github.com/apache/flink/pull/13501#discussion_r497225677
##########
File path: flink-runtime/src/main/java/org/apache/flink/runtime/io/network/partition/PipelinedApproximateSubpartition.java
##########
@@ -0,0 +1,138 @@
+package org.apache.flink.runtime.io.network.partition;
+
+import org.apache.flink.runtime.io.network.buffer.Buffer;
+import org.apache.flink.runtime.io.network.buffer.BufferConsumer;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.annotation.Nullable;
+
+import static org.apache.flink.util.Preconditions.checkState;
+
+public class PipelinedApproximateSubpartition extends PipelinedSubpartition {
+
+ private static final Logger LOG = LoggerFactory.getLogger(PipelinedApproximateSubpartition.class);
+
+ private boolean isPartialBuffer = false;
+
+ PipelinedApproximateSubpartition(int index, ResultPartition parent) {
+ super(index, parent);
+ }
+
+ public void releaseView() {
+ readView = null;
+ isPartialBuffer = true;
+ isBlockedByCheckpoint = false;
+ sequenceNumber = 0;
+ }
+
+ @Override
+ public PipelinedSubpartitionView createReadView(BufferAvailabilityListener availabilityListener) {
+ synchronized (buffers) {
+ checkState(!isReleased);
+
+ // if the view is not released yet
+ if (readView != null) {
+ releaseView();
+ }
+
+ LOG.debug("{}: Creating read view for subpartition {} of partition {}.",
+ parent.getOwningTaskName(), getSubPartitionIndex(), parent.getPartitionId());
+
+ readView = new PipelinedApproximateSubpartitionView(this, availabilityListener);
+ }
+
+ return readView;
+ }
+
+ @Nullable
+ @Override
+ BufferAndBacklog pollBuffer() {
Review comment:
I totally agree. If we reach an agreement, I will definitely do that.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] pnowojski commented on a change in pull request #13501: Single task result partition type
Posted by GitBox <gi...@apache.org>.
pnowojski commented on a change in pull request #13501:
URL: https://github.com/apache/flink/pull/13501#discussion_r497371743
##########
File path: flink-runtime/src/main/java/org/apache/flink/runtime/io/network/buffer/BufferBuilder.java
##########
@@ -86,11 +94,34 @@ public int append(ByteBuffer source) {
int available = getMaxCapacity() - positionMarker.getCached();
int toCopy = Math.min(needed, available);
+ // Each Data BufferBuilder starts with a 4-byte integer header
+ // Since length can only be 0 or positive numbers, the first bit of the integer
+ // is used to identify whether the first record is partial (1) or not (0)
+ // The remaining 31 bits stands for the length of the record remaining.
+ // The data written is not made visible to reader until {@link #commit()}, so the BufferBuilder
+ // ends either with a complete record or full buffer after append();
+ if (isEmptyBufferBuilder()) {
+ available = available - BUFFER_BUILDER_HEADER_SIZE;
+ toCopy = Math.min(needed, available);
+ int header = Header.headerEncode(isPartialRecord(source), toCopy);
+ memorySegment.putIntBigEndian(positionMarker.getCached(), header);
+ positionMarker.move(BUFFER_BUILDER_HEADER_SIZE);
+ }
+
Review comment:
1. first 4 bytes of `ByteBuffer source` already contain length. Why do we need to encode the length for the second time?
2. I think it would be easier/cleaner/more reliable to detect the partial record on the higher layer. Maybe somewhere around `BufferWritingResultPartition#emitRecord/broadcastRecord`? After all if it ever needs to de a second iteration in
```
do {
final BufferBuilder bufferBuilder = getSubpartitionBufferBuilder(targetSubpartition);
bufferBuilder.appendAndCommit(record);
if (bufferBuilder.isFull()) {
finishSubpartitionBufferBuilder(targetSubpartition);
}
} while (record.hasRemaining());
```
it directly means "hey! that's partial record".
It would be cleaner, as on this layer we do not know anything about the content of the buffers, or how are they being used. Thus `isPartialRecord` here is a bit strange concept.
##########
File path: flink-runtime/src/main/java/org/apache/flink/runtime/io/network/partition/PipelinedApproximateSubpartition.java
##########
@@ -0,0 +1,138 @@
+package org.apache.flink.runtime.io.network.partition;
+
+import org.apache.flink.runtime.io.network.buffer.Buffer;
+import org.apache.flink.runtime.io.network.buffer.BufferConsumer;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.annotation.Nullable;
+
+import static org.apache.flink.util.Preconditions.checkState;
+
+public class PipelinedApproximateSubpartition extends PipelinedSubpartition {
+
+ private static final Logger LOG = LoggerFactory.getLogger(PipelinedApproximateSubpartition.class);
+
+ private boolean isPartialBuffer = false;
+
+ PipelinedApproximateSubpartition(int index, ResultPartition parent) {
+ super(index, parent);
+ }
+
+ public void releaseView() {
+ readView = null;
+ isPartialBuffer = true;
+ isBlockedByCheckpoint = false;
+ sequenceNumber = 0;
+ }
+
+ @Override
+ public PipelinedSubpartitionView createReadView(BufferAvailabilityListener availabilityListener) {
+ synchronized (buffers) {
+ checkState(!isReleased);
+
+ // if the view is not released yet
+ if (readView != null) {
+ releaseView();
+ }
+
+ LOG.debug("{}: Creating read view for subpartition {} of partition {}.",
+ parent.getOwningTaskName(), getSubPartitionIndex(), parent.getPartitionId());
+
+ readView = new PipelinedApproximateSubpartitionView(this, availabilityListener);
+ }
+
+ return readView;
+ }
+
+ @Nullable
+ @Override
+ BufferAndBacklog pollBuffer() {
Review comment:
I would proceed with caution, but if it can be done cleanly, it would definitely be worth to deduplicate this code.
As it is, it's hard for me to even review it and see the difference.
##########
File path: flink-runtime/src/main/java/org/apache/flink/runtime/io/network/buffer/BufferConsumer.java
##########
@@ -96,15 +98,43 @@ public boolean isFinished() {
return writerPosition.isFinished();
}
+ public boolean startOfDataBuffer() {
+ return buffer.getDataType() == DATA_BUFFER && currentReaderPosition == 0;
+ }
+
/**
+ * BufferConsumer skips the buffer header before building buffer.
* @return sliced {@link Buffer} containing the not yet consumed data. Returned {@link Buffer} shares the reference
* counter with the parent {@link BufferConsumer} - in order to recycle memory both of them must be recycled/closed.
*/
public Buffer build() {
writerPosition.update();
int cachedWriterPosition = writerPosition.getCached();
- Buffer slice = buffer.readOnlySlice(currentReaderPosition, cachedWriterPosition - currentReaderPosition);
+
+ Buffer slice = null;
+
+ // data buffer && starting from the beginning of the buffer
+ if (startOfDataBuffer()) {
+ // either do not have any data, or at least have 4 bytes (header + data)
+ checkState(
+ (cachedWriterPosition - currentReaderPosition > BUFFER_BUILDER_HEADER_SIZE)
+ || (currentReaderPosition == cachedWriterPosition)
+ );
+
+ // remove the header
+ if (cachedWriterPosition - currentReaderPosition > BUFFER_BUILDER_HEADER_SIZE) {
+ slice = buffer.readOnlySlice(
+ currentReaderPosition + BUFFER_BUILDER_HEADER_SIZE,
+ cachedWriterPosition - currentReaderPosition - BUFFER_BUILDER_HEADER_SIZE);
+ }
+ }
Review comment:
Wouldn't the same as my previous commit apply here as well? Handling the partial record length might be more meaningful in `SpillingAdaptiveSpanningRecordDeserializer#setNextBuffer`?
##########
File path: flink-runtime/src/main/java/org/apache/flink/runtime/io/network/partition/PipelinedApproximateSubpartitionView.java
##########
@@ -0,0 +1,27 @@
+package org.apache.flink.runtime.io.network.partition;
+
+import static org.apache.flink.util.Preconditions.checkState;
+
+public class PipelinedApproximateSubpartitionView extends PipelinedSubpartitionView {
+
+ PipelinedApproximateSubpartitionView(PipelinedApproximateSubpartition parent, BufferAvailabilityListener listener) {
+ super(parent, listener);
+ }
+
+ @Override
+ public void releaseAllResources() {
+ if (isReleased.compareAndSet(false, true)) {
+ // The view doesn't hold any resources and the parent cannot be restarted. Therefore,
+ // it's OK to notify about consumption as well.
+ checkState(parent instanceof PipelinedApproximateSubpartition);
+ ((PipelinedApproximateSubpartition) parent).releaseView();
+ }
+ }
Review comment:
Why is this method behaving differently compared to `PipelinedSubpartitionView#releaseAllResources`?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] StephanEwen commented on pull request #13501: Single task result partition type
Posted by GitBox <gi...@apache.org>.
StephanEwen commented on pull request #13501:
URL: https://github.com/apache/flink/pull/13501#issuecomment-702157253
I took a look only at the partial record handling. I like the idea of not transporting the partial record offsets at all across the networks, which means we don't have to make the deserializers aware of that.
Regarding the implementation, I have the same comment as @pnowojski . Given that the partial lengths fields are not communicated across the network, I feel that this logic does not belong into buffers or `BufferBuilder`/`BufferConsumer`. Those should handle purely bytes without any knowledge of records.
I would suggest to change the `buffers` queue from holding `BufferConsumer` to holding `BufferConsumerWithOffsets` or so (maybe come up with a shorter name). That way we transport the same information, but not inject it into the buffers.
Some more things to watch out for in further refactoring:
- The *per record methods* of *ResultPartition* and its subclasses are highly performance sensitive. They should not become virtual methods. We currently can guarantee that because there is only one class implementing these per-record methods (BufferWritingResultPartition).
When we start having different implementations, we ideally have only one of them loaded in the JVM at any point, so that the de-virtualization works properly. That means design the classes/subclasses such that a type of job (batch, streaming, streaming with partial failover) would only ever rely on one of these partition types in a job.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] curcur commented on a change in pull request #13501: Single task result partition type
Posted by GitBox <gi...@apache.org>.
curcur commented on a change in pull request #13501:
URL: https://github.com/apache/flink/pull/13501#discussion_r498890005
##########
File path: flink-runtime/src/main/java/org/apache/flink/runtime/io/network/buffer/BufferBuilder.java
##########
@@ -86,11 +94,34 @@ public int append(ByteBuffer source) {
int available = getMaxCapacity() - positionMarker.getCached();
int toCopy = Math.min(needed, available);
+ // Each Data BufferBuilder starts with a 4-byte integer header
+ // Since length can only be 0 or positive numbers, the first bit of the integer
+ // is used to identify whether the first record is partial (1) or not (0)
+ // The remaining 31 bits stands for the length of the record remaining.
+ // The data written is not made visible to reader until {@link #commit()}, so the BufferBuilder
+ // ends either with a complete record or full buffer after append();
+ if (isEmptyBufferBuilder()) {
+ available = available - BUFFER_BUILDER_HEADER_SIZE;
+ toCopy = Math.min(needed, available);
+ int header = Header.headerEncode(isPartialRecord(source), toCopy);
+ memorySegment.putIntBigEndian(positionMarker.getCached(), header);
+ positionMarker.move(BUFFER_BUILDER_HEADER_SIZE);
+ }
+
Review comment:
1. `ByteBuffer source` contains the header length of a record, we use that length to decide where a record ends;
`Partial record` needs to address the problem that if a record spanning over multiple buffers and the first buffer is sent but lost due to failure. They are trying to address different problems.
2. The second question is more complicated. I will write my concerns a bit later, together with Stephan's question.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] curcur commented on a change in pull request #13501: Single task result partition type
Posted by GitBox <gi...@apache.org>.
curcur commented on a change in pull request #13501:
URL: https://github.com/apache/flink/pull/13501#discussion_r498890005
##########
File path: flink-runtime/src/main/java/org/apache/flink/runtime/io/network/buffer/BufferBuilder.java
##########
@@ -86,11 +94,34 @@ public int append(ByteBuffer source) {
int available = getMaxCapacity() - positionMarker.getCached();
int toCopy = Math.min(needed, available);
+ // Each Data BufferBuilder starts with a 4-byte integer header
+ // Since length can only be 0 or positive numbers, the first bit of the integer
+ // is used to identify whether the first record is partial (1) or not (0)
+ // The remaining 31 bits stands for the length of the record remaining.
+ // The data written is not made visible to reader until {@link #commit()}, so the BufferBuilder
+ // ends either with a complete record or full buffer after append();
+ if (isEmptyBufferBuilder()) {
+ available = available - BUFFER_BUILDER_HEADER_SIZE;
+ toCopy = Math.min(needed, available);
+ int header = Header.headerEncode(isPartialRecord(source), toCopy);
+ memorySegment.putIntBigEndian(positionMarker.getCached(), header);
+ positionMarker.move(BUFFER_BUILDER_HEADER_SIZE);
+ }
+
Review comment:
1. `ByteBuffer source` contains the header length of a record, we use that length to decide where a record ends;
`Partial record` needs to address the problem that if a record spanning over multiple buffers and the first buffer is sent but lost due to failure. They are trying to address different problems.
2. The second question is more complicated. I will write my concerns a bit later.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #13501: Single task result partition type
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #13501:
URL: https://github.com/apache/flink/pull/13501#issuecomment-699944339
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "63450ff4d3f109854d55980aeaa87ec8dcc7e9ca",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "63450ff4d3f109854d55980aeaa87ec8dcc7e9ca",
"triggerType" : "PUSH"
}, {
"hash" : "810706f4c5550bd8691799c78e44aa6a80a132b6",
"status" : "FAILURE",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=7032",
"triggerID" : "810706f4c5550bd8691799c78e44aa6a80a132b6",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 63450ff4d3f109854d55980aeaa87ec8dcc7e9ca UNKNOWN
* 810706f4c5550bd8691799c78e44aa6a80a132b6 Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=7032)
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] curcur commented on a change in pull request #13501: Single task result partition type
Posted by GitBox <gi...@apache.org>.
curcur commented on a change in pull request #13501:
URL: https://github.com/apache/flink/pull/13501#discussion_r498892692
##########
File path: flink-runtime/src/main/java/org/apache/flink/runtime/io/network/partition/PipelinedApproximateSubpartitionView.java
##########
@@ -0,0 +1,27 @@
+package org.apache.flink.runtime.io.network.partition;
+
+import static org.apache.flink.util.Preconditions.checkState;
+
+public class PipelinedApproximateSubpartitionView extends PipelinedSubpartitionView {
+
+ PipelinedApproximateSubpartitionView(PipelinedApproximateSubpartition parent, BufferAvailabilityListener listener) {
+ super(parent, listener);
+ }
+
+ @Override
+ public void releaseAllResources() {
+ if (isReleased.compareAndSet(false, true)) {
+ // The view doesn't hold any resources and the parent cannot be restarted. Therefore,
+ // it's OK to notify about consumption as well.
+ checkState(parent instanceof PipelinedApproximateSubpartition);
+ ((PipelinedApproximateSubpartition) parent).releaseView();
+ }
+ }
Review comment:
PipelinedSubpartitionView#releaseAllResources
```
@Override
public void releaseAllResources() {
if (isReleased.compareAndSet(false, true)) {
// The view doesn't hold any resources and the parent cannot be restarted. Therefore,
// it's OK to notify about consumption as well.
parent.onConsumedSubpartition();
}
}
```
They are different in the sense that `PipelinedSubpartitionView` release the subPartition => Partition as well
`PipelinedApproximateSubpartition` only releases view.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] flinkbot commented on pull request #13501: Single task result partition type
Posted by GitBox <gi...@apache.org>.
flinkbot commented on pull request #13501:
URL: https://github.com/apache/flink/pull/13501#issuecomment-699944339
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "63450ff4d3f109854d55980aeaa87ec8dcc7e9ca",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "63450ff4d3f109854d55980aeaa87ec8dcc7e9ca",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 63450ff4d3f109854d55980aeaa87ec8dcc7e9ca UNKNOWN
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] curcur commented on a change in pull request #13501: Single task result partition type
Posted by GitBox <gi...@apache.org>.
curcur commented on a change in pull request #13501:
URL: https://github.com/apache/flink/pull/13501#discussion_r497225512
##########
File path: flink-runtime/src/main/java/org/apache/flink/runtime/io/network/partition/PipelinedApproximateSubpartitionView.java
##########
@@ -0,0 +1,27 @@
+package org.apache.flink.runtime.io.network.partition;
+
+import static org.apache.flink.util.Preconditions.checkState;
+
+public class PipelinedApproximateSubpartitionView extends PipelinedSubpartitionView {
+
+ PipelinedApproximateSubpartitionView(PipelinedApproximateSubpartition parent, BufferAvailabilityListener listener) {
+ super(parent, listener);
+ }
+
+ @Override
+ public void releaseAllResources() {
+ if (isReleased.compareAndSet(false, true)) {
+ // The view doesn't hold any resources and the parent cannot be restarted. Therefore,
+ // it's OK to notify about consumption as well.
+ checkState(parent instanceof PipelinedApproximateSubpartition);
+ ((PipelinedApproximateSubpartition) parent).releaseView();
Review comment:
Yeah, I was also thinking of that. The problem is that I have to change all the common methods in the superclass that uses `parent` to `approximateParent` => a lot of redundant code.
`releaseView()` is one of the few classes that are different from the superclass.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] flinkbot commented on pull request #13501: Single task result partition type
Posted by GitBox <gi...@apache.org>.
flinkbot commented on pull request #13501:
URL: https://github.com/apache/flink/pull/13501#issuecomment-699941154
Thanks a lot for your contribution to the Apache Flink project. I'm the @flinkbot. I help the community
to review your pull request. We will use this comment to track the progress of the review.
## Automated Checks
Last check on commit 63450ff4d3f109854d55980aeaa87ec8dcc7e9ca (Mon Sep 28 11:11:28 UTC 2020)
**Warnings:**
* No documentation files were touched! Remember to keep the Flink docs up to date!
* **Invalid pull request title: No valid Jira ID provided**
<sub>Mention the bot in a comment to re-run the automated checks.</sub>
## Review Progress
* ❓ 1. The [description] looks good.
* ❓ 2. There is [consensus] that the contribution should go into to Flink.
* ❓ 3. Needs [attention] from.
* ❓ 4. The change fits into the overall [architecture].
* ❓ 5. Overall code [quality] is good.
Please see the [Pull Request Review Guide](https://flink.apache.org/contributing/reviewing-prs.html) for a full explanation of the review process.<details>
The Bot is tracking the review progress through labels. Labels are applied according to the order of the review items. For consensus, approval by a Flink committer of PMC member is required <summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot approve description` to approve one or more aspects (aspects: `description`, `consensus`, `architecture` and `quality`)
- `@flinkbot approve all` to approve all aspects
- `@flinkbot approve-until architecture` to approve everything until `architecture`
- `@flinkbot attention @username1 [@username2 ..]` to require somebody's attention
- `@flinkbot disapprove architecture` to remove an approval you gave earlier
</details>
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] curcur commented on pull request #13501: Single task result partition type
Posted by GitBox <gi...@apache.org>.
curcur commented on pull request #13501:
URL: https://github.com/apache/flink/pull/13501#issuecomment-701136832
Thank you very much @AHeise for reviewing!
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] curcur commented on a change in pull request #13501: Single task result partition type
Posted by GitBox <gi...@apache.org>.
curcur commented on a change in pull request #13501:
URL: https://github.com/apache/flink/pull/13501#discussion_r498883527
##########
File path: flink-runtime/src/main/java/org/apache/flink/runtime/io/network/partition/PipelinedApproximateSubpartition.java
##########
@@ -0,0 +1,138 @@
+package org.apache.flink.runtime.io.network.partition;
+
+import org.apache.flink.runtime.io.network.buffer.Buffer;
+import org.apache.flink.runtime.io.network.buffer.BufferConsumer;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.annotation.Nullable;
+
+import static org.apache.flink.util.Preconditions.checkState;
+
+public class PipelinedApproximateSubpartition extends PipelinedSubpartition {
+
+ private static final Logger LOG = LoggerFactory.getLogger(PipelinedApproximateSubpartition.class);
+
+ private boolean isPartialBuffer = false;
+
+ PipelinedApproximateSubpartition(int index, ResultPartition parent) {
+ super(index, parent);
+ }
+
+ public void releaseView() {
+ readView = null;
+ isPartialBuffer = true;
+ isBlockedByCheckpoint = false;
+ sequenceNumber = 0;
+ }
+
+ @Override
+ public PipelinedSubpartitionView createReadView(BufferAvailabilityListener availabilityListener) {
+ synchronized (buffers) {
+ checkState(!isReleased);
+
+ // if the view is not released yet
+ if (readView != null) {
+ releaseView();
+ }
+
+ LOG.debug("{}: Creating read view for subpartition {} of partition {}.",
+ parent.getOwningTaskName(), getSubPartitionIndex(), parent.getPartitionId());
+
+ readView = new PipelinedApproximateSubpartitionView(this, availabilityListener);
+ }
+
+ return readView;
+ }
+
+ @Nullable
+ @Override
+ BufferAndBacklog pollBuffer() {
Review comment:
the difference is :
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] curcur commented on pull request #13501: Single task result partition type
Posted by GitBox <gi...@apache.org>.
curcur commented on pull request #13501:
URL: https://github.com/apache/flink/pull/13501#issuecomment-702802919
1. What is the partial-record information:
- Whether the FIRST record BEGINS as a complete and new record or not.
- If YES, the recorded length = MIN(the entire record size, buffer size); If NOT, the recorded length = MIN(the remaining record size, buffer size)
the recorded length is used to decide how much data to skip in the NOT case; the recorded length is not used in the YES case.
Here, the **FIRST** record means: starting with memory segment position 0 for both writing (builder) and reading (consumer)
Partial-record information is set up like this because a record can miss its header part only when a bufferBuilder ends with a full buffer but not a full record; when flushing buffer to network, we either flush a complete buffer or a complete record;
So we never have a chance to start reading a partial record if reading position of bufferConsumer > 0 when polling buffers to send through the network.
2. Hence, partial-record information is used by the buffer reader to decide
1). whether needs to skip data when reading a buffer; and 2). how much data to skip;
I am lean-to to consider `partial-record information` as a buffer-level concept, instead of record-level; Or at least, as a record writer, it should not care about how data layout in the underlying memory segment as well.
and if I want to decide how much data to skip (which is the whole purpose for partial record clean-up), it seems that I have to have some way to manipulate buffer write/read anyway.
3. Currently, BufferConsumer is created and added into PrioritizedDeque<BufferConsumer> when requesting a new bufferBuilder in BufferWritingResultPartition#getNewSubpartitionBufferBuilder; (In broadcasting mode, it is similar, but adding multiple copies)
After that, write and read is completely separated/independent and only coordinated through the `write positionMarker`.
If I want to encode the `partial-record information` into PrioritizedDeque<BufferConsumerWithOffset>, I have to either encode offset information before writing (that's when BufferConsumerWithOffset is created, but offset information is available only when writing the FIRST RECORD);
or updating BufferConsumerWithOffset's offset when writing the FIRST RECORD, which is strange as well.
4. Since `partial-record information` is shared between BufferBuilder and BufferConsumer both, so I was wondering whether I can put this information (encoded in integer) as a field of MemorySegment?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] curcur commented on a change in pull request #13501: Single task result partition type
Posted by GitBox <gi...@apache.org>.
curcur commented on a change in pull request #13501:
URL: https://github.com/apache/flink/pull/13501#discussion_r497225677
##########
File path: flink-runtime/src/main/java/org/apache/flink/runtime/io/network/partition/PipelinedApproximateSubpartition.java
##########
@@ -0,0 +1,138 @@
+package org.apache.flink.runtime.io.network.partition;
+
+import org.apache.flink.runtime.io.network.buffer.Buffer;
+import org.apache.flink.runtime.io.network.buffer.BufferConsumer;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.annotation.Nullable;
+
+import static org.apache.flink.util.Preconditions.checkState;
+
+public class PipelinedApproximateSubpartition extends PipelinedSubpartition {
+
+ private static final Logger LOG = LoggerFactory.getLogger(PipelinedApproximateSubpartition.class);
+
+ private boolean isPartialBuffer = false;
+
+ PipelinedApproximateSubpartition(int index, ResultPartition parent) {
+ super(index, parent);
+ }
+
+ public void releaseView() {
+ readView = null;
+ isPartialBuffer = true;
+ isBlockedByCheckpoint = false;
+ sequenceNumber = 0;
+ }
+
+ @Override
+ public PipelinedSubpartitionView createReadView(BufferAvailabilityListener availabilityListener) {
+ synchronized (buffers) {
+ checkState(!isReleased);
+
+ // if the view is not released yet
+ if (readView != null) {
+ releaseView();
+ }
+
+ LOG.debug("{}: Creating read view for subpartition {} of partition {}.",
+ parent.getOwningTaskName(), getSubPartitionIndex(), parent.getPartitionId());
+
+ readView = new PipelinedApproximateSubpartitionView(this, availabilityListener);
+ }
+
+ return readView;
+ }
+
+ @Nullable
+ @Override
+ BufferAndBacklog pollBuffer() {
Review comment:
I totally agree. If we reach the agreement, I will definitely do that.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #13501: Single task result partition type --- the most original one
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #13501:
URL: https://github.com/apache/flink/pull/13501#issuecomment-699944339
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "810706f4c5550bd8691799c78e44aa6a80a132b6",
"status" : "FAILURE",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=7032",
"triggerID" : "810706f4c5550bd8691799c78e44aa6a80a132b6",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 810706f4c5550bd8691799c78e44aa6a80a132b6 Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=7032)
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run azure` re-run the last Azure build
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] curcur commented on a change in pull request #13501: Single task result partition type
Posted by GitBox <gi...@apache.org>.
curcur commented on a change in pull request #13501:
URL: https://github.com/apache/flink/pull/13501#discussion_r498891296
##########
File path: flink-runtime/src/main/java/org/apache/flink/runtime/io/network/buffer/BufferConsumer.java
##########
@@ -96,15 +98,43 @@ public boolean isFinished() {
return writerPosition.isFinished();
}
+ public boolean startOfDataBuffer() {
+ return buffer.getDataType() == DATA_BUFFER && currentReaderPosition == 0;
+ }
+
/**
+ * BufferConsumer skips the buffer header before building buffer.
* @return sliced {@link Buffer} containing the not yet consumed data. Returned {@link Buffer} shares the reference
* counter with the parent {@link BufferConsumer} - in order to recycle memory both of them must be recycled/closed.
*/
public Buffer build() {
writerPosition.update();
int cachedWriterPosition = writerPosition.getCached();
- Buffer slice = buffer.readOnlySlice(currentReaderPosition, cachedWriterPosition - currentReaderPosition);
+
+ Buffer slice = null;
+
+ // data buffer && starting from the beginning of the buffer
+ if (startOfDataBuffer()) {
+ // either do not have any data, or at least have 4 bytes (header + data)
+ checkState(
+ (cachedWriterPosition - currentReaderPosition > BUFFER_BUILDER_HEADER_SIZE)
+ || (currentReaderPosition == cachedWriterPosition)
+ );
+
+ // remove the header
+ if (cachedWriterPosition - currentReaderPosition > BUFFER_BUILDER_HEADER_SIZE) {
+ slice = buffer.readOnlySlice(
+ currentReaderPosition + BUFFER_BUILDER_HEADER_SIZE,
+ cachedWriterPosition - currentReaderPosition - BUFFER_BUILDER_HEADER_SIZE);
+ }
+ }
Review comment:
`SpillingAdaptiveSpanningRecordDeserializer#setNextBuffer` is on the receiver side? (downstream)
if we do it here, we do it on the sending side, which means the additional partial-record information is not sent over the network.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org