mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-16 01:42:55 +00:00
spawn passthrough as a separate task to reduce influence from the handshake task
This commit is contained in:
@@ -154,34 +154,42 @@ pub async fn task_main(
|
||||
.boxed()
|
||||
.await;
|
||||
|
||||
match res {
|
||||
let passthrough = match res {
|
||||
Err(e) => {
|
||||
ctx.set_error_kind(e.get_error_kind());
|
||||
warn!(parent: &ctx.span(), "per-client task finished with an error: {e:#}");
|
||||
return;
|
||||
}
|
||||
Ok(None) => {
|
||||
ctx.set_success();
|
||||
return;
|
||||
}
|
||||
Ok(Some(p)) => {
|
||||
ctx.set_success();
|
||||
let _disconnect = ctx.log_connect();
|
||||
match p.proxy_pass(&config.connect_to_compute).await {
|
||||
Ok(()) => {}
|
||||
Err(ErrorSource::Client(e)) => {
|
||||
warn!(
|
||||
?session_id,
|
||||
"per-client task finished with an IO error from the client: {e:#}"
|
||||
);
|
||||
}
|
||||
Err(ErrorSource::Compute(e)) => {
|
||||
error!(
|
||||
?session_id,
|
||||
"per-client task finished with an IO error from the compute: {e:#}"
|
||||
);
|
||||
}
|
||||
p
|
||||
}
|
||||
};
|
||||
|
||||
// spawn passthrough as a new task.
|
||||
// holds a task tracker token to prevent the proxy shutting down early.
|
||||
tokio::spawn(async move {
|
||||
let _disconnect = ctx.log_connect();
|
||||
match passthrough.proxy_pass(&config.connect_to_compute).await {
|
||||
Ok(()) => {}
|
||||
Err(ErrorSource::Client(e)) => {
|
||||
warn!(
|
||||
?session_id,
|
||||
"per-client task finished with an IO error from the client: {e:#}"
|
||||
);
|
||||
}
|
||||
Err(ErrorSource::Compute(e)) => {
|
||||
error!(
|
||||
?session_id,
|
||||
"per-client task finished with an IO error from the compute: {e:#}"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user