sunhaibotb commented on a change in pull request #8124: [FLINK-11877] Implement
the runtime handling of the InputSelectable interface
URL: https://github.com/apache/flink/pull/8124#discussion_r276556081
##########
File path:
flink-runtime/src/main/java/org/apache/flink/runtime/io/network/partition/consumer/SingleInputGate.java
##########
@@ -184,6 +184,9 @@
/** A timer to retrigger local partition requests. Only initialized if
actually needed. */
private Timer retriggerLocalRequestTimer;
+ /** Flag indicating whether there is available data. */
+ private volatile boolean moreDataAvailable = false;
Review comment:
> We always should use either this BufferOrEvent#moreAvailable() or relay on
listeners/futures to inform us that the availability has changed
I don't think they can accurately determine the state (available or
unavailable). Considering the following execution sequences, the task thread
finally sees the same thing that `BufferOrEvent#moreAvailable` is unavailable
and receives a non-null notification, but the last actual state of `InputGate`
is different, the former is available, and the latter is unavailable.
Case 1:
1. Initial State: `InputGate` is data available
2. (**Task Thread**) Call `InputGate#pollNextBufferOrEvent()`
3. (**Task Thread**) `InputGate` become empty after being polled a
`BufferOrEvent`
4. (**Task Thread**) Assign `BufferOrEvent#moreAvailable` to false before
returning
5. (**Network Thread**) Data arrives at `InputGate` which triggers the
non-empty notification
6. (**Task Thread**) `InputGate#pollNextBufferOrEvent()` returns,
`BufferOrEvent#moreAvailable` is false and recieves a `non-empty` notification
Case 2:
1. Initial State: `InputGate` is data unavailable
2. (**Task Thread**) Call `InputGate#pollNextBufferOrEvent()`
3. (**Network Thread**) Data arrives at `InputGate` which triggers the
non-empty notification
4. (**Task Thread**) `InputGate` become empty after being polled a
`BufferOrEvent`
5. (**Task Thread**) Assign `BufferOrEvent#moreAvailable` to false before
returning
6. (**Task Thread**) `InputGate#pollNextBufferOrEvent()` returns,
`BufferOrEvent#moreAvailable` is false and recieves a `non-empty` notification
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services