-
Notifications
You must be signed in to change notification settings - Fork 600
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(batch): Stop polling after data stream returns None
#4371
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -288,54 +288,54 @@ impl<C: BatchTaskContext> BatchTaskExecution<C> { | |
mut shutdown_rx: Receiver<u64>, | ||
) -> Result<()> { | ||
let mut data_chunk_stream = root.execute(); | ||
let mut state = TaskStatus::Unspecified; | ||
loop { | ||
tokio::select! { | ||
// We prioritize abort signal over normal data chunks. | ||
biased; | ||
_ = &mut shutdown_rx => { | ||
if let Err(e) = sender.send(None).await { | ||
match e { | ||
BatchError::SenderError => { | ||
// This is possible since when we have limit executor in parent | ||
// stage, it may early stop receiving data from downstream, which | ||
// leads to close of channel. | ||
warn!("Task receiver closed!"); | ||
break; | ||
}, | ||
x => { | ||
return Err(InternalError(format!("Failed to send data: {:?}", x)))?; | ||
} | ||
} | ||
} | ||
*self.state.lock() = TaskStatus::Aborted; | ||
state = TaskStatus::Aborted; | ||
break; | ||
} | ||
res = data_chunk_stream.next() => { | ||
let data_chunk = match res { | ||
Some(data_chunk) => Some(data_chunk?), | ||
None => { | ||
trace!("data chunk stream shuts down"); | ||
None | ||
} | ||
}; | ||
|
||
if let Err(e) = sender.send(data_chunk).await { | ||
match e { | ||
BatchError::SenderError => { | ||
// This is possible since when we have limit executor in parent | ||
// stage, it may early stop receiving data from downstream, which | ||
// leads to close of channel. | ||
warn!("Task receiver closed!"); | ||
break; | ||
}, | ||
x => { | ||
return Err(InternalError(format!("Failed to send data: {:?}", x)))?; | ||
if let Some(data_chunk) = res { | ||
if let Err(e) = sender.send(Some(data_chunk?)).await { | ||
match e { | ||
BatchError::SenderError => { | ||
// This is possible since when we have limit executor in parent | ||
// stage, it may early stop receiving data from downstream, which | ||
// leads to close of channel. | ||
warn!("Task receiver closed!"); | ||
break; | ||
}, | ||
x => { | ||
return Err(InternalError(format!("Failed to send data: {:?}", x)))?; | ||
} | ||
} | ||
} | ||
} else { | ||
state = TaskStatus::Finished; | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
|
||
info!("Task finished with status: {:?}", state); | ||
*self.state.lock() = state; | ||
if let Err(e) = sender.send(None).await { | ||
match e { | ||
BatchError::SenderError => { | ||
// This is possible since when we have limit executor in parent | ||
// stage, it may early stop receiving data from downstream, which | ||
// leads to close of channel. | ||
Comment on lines
+329
to
+331
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I doubt whether this statement is still valid. Seems like I can directly unwrap... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, it's valid. LimitExecutor or TopNExecutor still may early stop receiver. |
||
warn!("Task receiver closed when sending None!"); | ||
} | ||
x => { | ||
return Err(InternalError(format!("Failed to send data: {:?}", x)))?; | ||
} | ||
} | ||
} | ||
Ok(()) | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the chunk is Some, I think unwrap on send error is make sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, this is possible with
LimitExecutor