Skip to content

[Backport] FrameChannelMerger: Fix incorrect behavior of finished(). (#17088)#17194

Merged
kfaraz merged 1 commit intoapache:31.0.0from
kfaraz:backport_17088
Sep 30, 2024
Merged

[Backport] FrameChannelMerger: Fix incorrect behavior of finished(). (#17088)#17194
kfaraz merged 1 commit intoapache:31.0.0from
kfaraz:backport_17088

Conversation

@kfaraz
Copy link
Copy Markdown
Contributor

@kfaraz kfaraz commented Sep 30, 2024

Backport #17088

Previously, the processor used "remainingChannels" to track the number of
non-null entries of currentFrame. Now, "remainingChannels" tracks the
number of channels that are unfinished.

The difference is subtle. In the previous code, when an input channel
was blocked upon exiting nextFrame(), the "currentFrames" entry would be
null, and therefore the "remainingChannels" variable would be decremented.
After the next await and call to populateCurrentFramesAndTournamentTree(),
"remainingChannels" would be incremented if the channel had become
unblocked after awaiting.

This means that finished(), which returned true if remainingChannels was
zero, would not be reliable if called between nextFrame() and the
next await + populateCurrentFramesAndTournamentTree().

This patch changes things such that finished() is always reliable. This
fixes a regression introduced in PR apache#16911, which added a call to
finished() that was, at that time, unsafe.
@kfaraz kfaraz added this to the 31.0.0 milestone Sep 30, 2024
@kfaraz kfaraz merged commit f4ad5d0 into apache:31.0.0 Sep 30, 2024
@kfaraz kfaraz deleted the backport_17088 branch September 30, 2024 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants