Skip to content

fix(query): remove unexpected strong ref for http query #13807

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

Merged
merged 7 commits into from
Nov 27, 2023
18 changes: 14 additions & 4 deletions src/query/service/src/servers/http/v1/query/http_query_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,20 +78,30 @@ impl HttpQueryManager {

let self_clone = self.clone();
let query_id_clone = query_id.to_string();
let query_clone = query.clone();
let http_query_weak = Arc::downgrade(&query);
let query_result_timeout_secs = query.result_timeout_secs;
GlobalIORuntime::instance().spawn(query_id, async move {
loop {
match query_clone.check_expire().await {
let expire_res = match http_query_weak.upgrade() {
None => {
break;
}
Some(query) => query.check_expire().await,
};

match expire_res {
ExpireResult::Expired => {
let msg = format!(
"http query {} timeout after {} s",
&query_id_clone, query_clone.result_timeout_secs
&query_id_clone, query_result_timeout_secs
);
if self_clone.remove_query(&query_id_clone).await.is_none() {
warn!("{msg}, but fail to remove");
} else {
warn!("{msg}");
query.kill(&msg).await;
if let Some(query) = http_query_weak.upgrade() {
query.kill(&msg).await;
}
};
break;
}
Expand Down