Skip to content

Commit 74d77ce

Browse files
committed
Improve root search cancellation states
1 parent a79d168 commit 74d77ce

File tree

1 file changed

+11
-13
lines changed
  • quickwit/quickwit-search/src

1 file changed

+11
-13
lines changed

quickwit/quickwit-search/src/root.rs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,7 +1208,7 @@ pub async fn root_search(
12081208
let current_span = tracing::Span::current();
12091209
current_span.record("num_docs", num_docs);
12101210
current_span.record("num_splits", num_splits);
1211-
target_split_sender.send(0).ok();
1211+
target_split_sender.send(num_splits).ok();
12121212

12131213
let mut search_response_result = root_search_aux(
12141214
searcher_context,
@@ -1765,21 +1765,19 @@ pub fn jobs_to_fetch_docs_requests(
17651765
async fn start_root_search_metric_recording(
17661766
start_instant: tokio::time::Instant,
17671767
) -> (oneshot::Sender<bool>, oneshot::Sender<usize>) {
1768-
let (completion_tx, completion_rx) = tokio::sync::oneshot::channel();
1769-
let (target_split_tx, target_split_rx) = tokio::sync::oneshot::channel();
1768+
let (completion_tx, completion_rx) = oneshot::channel();
1769+
let (target_split_tx, target_split_rx) = oneshot::channel();
17701770
tokio::spawn(async move {
17711771
let (completion_res, target_split_res) = tokio::join!(completion_rx, target_split_rx);
1772-
let label_values = if let Ok(is_success) = completion_res {
1773-
if is_success {
1774-
["success"]
1775-
} else {
1776-
["error"]
1777-
}
1778-
} else {
1779-
["cancelled"]
1780-
};
17811772

1782-
let num_splits = target_split_res.unwrap_or(0);
1773+
let (label_values, num_splits) = match (completion_res, target_split_res) {
1774+
(Ok(true), Ok(num_splits)) => (["success"], num_splits),
1775+
(Ok(false), Ok(num_splits)) => (["error"], num_splits),
1776+
(Err(_), Ok(num_splits)) => (["cancelled"], num_splits),
1777+
(Err(_), Err(_)) => (["planning-failed"], 0),
1778+
// Should not happen, num split is resolved before the query
1779+
(Ok(_), Err(_)) => (["unexpected"], 0),
1780+
};
17831781

17841782
SEARCH_METRICS
17851783
.root_search_requests_total

0 commit comments

Comments
 (0)