Skip to content

Conversation

@abel-von
Copy link
Collaborator

@abel-von abel-von commented Apr 2, 2025

We introduced a preemptable receiver feature so that the new start containerd can preempt the old stdio streaming process routine.

but it has a bug that when io copy thread finished, it will remove the io channel, which has a preemption signal sender in it, the removal of the sender may preempt the stream receiver to stop early, without all message processed.

After this PR change, after copy of stdout and stderr finished, we don't call remove of the iochannel, but just set a flag of sender_closed to true. Before stream handle return, it just determin if the io channel should be removed by this flag.

Copilot AI review requested due to automatic review settings April 2, 2025 01:53
@abel-von abel-von requested a review from a team as a code owner April 2, 2025 01:53
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a bug in the stdout/stderr preemption logic by preventing premature removal of the IO channel and using a flag (sender_closed) to control when the channel should be removed. Key changes include:

  • Adding a new flag (sender_closed) to IOChannel.
  • Changing the behavior of return_preempted_receiver to return a boolean and conditionally remove the channel.
  • Updating error handling in data send/update cases to remove the channel rather than reassigning the sender.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
vmm/task/src/streaming.rs Adjusts preemption receiver logic and channel removal logic
vmm/task/src/io.rs Updates imports and replaces remove_channel with close_stdout

Comment on lines 145 to 146
// only return the receiver when sender is already moved to the io thread, and sender is not closed
if let None = self.sender {
Copy link

Copilot AI Apr 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function return_preempted_receiver checks self.sender, but the IOChannel struct defines the preemption sender as preemption_sender. This inconsistency may cause logic errors; consider using the correct field name.

Suggested change
// only return the receiver when sender is already moved to the io thread, and sender is not closed
if let None = self.sender {
// only return the receiver when preemption_sender is already moved to the io thread, and sender is not closed
if let None = self.preemption_sender {

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we have sender and preemption sender in IOChannel, sender is actually the data sender, preemption sender is only for send preemption message.

abel-von added 2 commits April 2, 2025 10:35
We introduced a preemptable receiver feature so that the new start containerd
can preempt the old stdio streaming process routine.

but it has a bug that when io copy thread finished, it will remove the
io channel, which has a preemption signal sender in it, the removal of
the sender may preempt the stream receiver to stop early, without all
message processed.

After this PR change, after copy of stdout and stderr finished, we don't
call remove of the iochannel, but just set a flag of sender_closed to
true. Before stream handle return, it just determin if the io channel
should be removed by this flag.

Signed-off-by: Abel Feng <[email protected]>
@abel-von abel-von force-pushed the fix-preemption-out branch from a714876 to 92e66ba Compare April 2, 2025 02:57
@abel-von abel-von closed this Jun 10, 2025
@abel-von abel-von reopened this Jun 10, 2025
@abel-von
Copy link
Collaborator Author

/retest

@abel-von abel-von closed this Jul 15, 2025
@abel-von abel-von reopened this Jul 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant