Skip to content

Commit

Permalink
fixes(handler): fix clickhouse handler dead loop when panic
Browse files Browse the repository at this point in the history
  • Loading branch information
zhang2014 committed May 17, 2022
1 parent b97c58f commit 83da2d5
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions query/src/servers/clickhouse/interactive_worker_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,34 @@ impl InteractiveWorkerBase {
Err(e)
}
Ok(mut data_stream) => {
while let Some(block) = data_stream.next().await {
data_tx.send(BlockItem::Block(block)).await.ok();
'worker: loop {
match data_stream.next().await {
None => {
break 'worker;
}
Some(Ok(data)) => {
if let Err(cause) = data_tx.send(BlockItem::Block(Ok(data))).await {
tracing::warn!(
"Cannot send data to channel, cause: {:?}",
cause
);
break 'worker;
}
}
Some(Err(error_code)) => {
if let Err(cause) =
data_tx.send(BlockItem::Block(Err(error_code))).await
{
tracing::warn!(
"Cannot send data to channel, cause: {:?}",
cause
);
}
break 'worker;
}
}
}

let _ = interpreter
.finish()
.await
Expand Down

0 comments on commit 83da2d5

Please sign in to comment.