mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-23 02:27:40 +08:00
ensure we never early exit when we have a permit and remove the warning when we implicitely drop a permit
This commit is contained in:
parent
241746e7f4
commit
69ab09c149
@ -93,8 +93,9 @@ pub async fn search(
|
|||||||
locales,
|
locales,
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.await?;
|
.await;
|
||||||
permit.drop().await;
|
permit.drop().await;
|
||||||
|
let search_result = search_result?;
|
||||||
|
|
||||||
if let Ok(ref search_result) = search_result {
|
if let Ok(ref search_result) = search_result {
|
||||||
aggregate.succeed(search_result);
|
aggregate.succeed(search_result);
|
||||||
|
@ -237,8 +237,9 @@ pub async fn search_with_url_query(
|
|||||||
let search_result = tokio::task::spawn_blocking(move || {
|
let search_result = tokio::task::spawn_blocking(move || {
|
||||||
perform_search(&index, query, search_kind, retrieve_vector, index_scheduler.features())
|
perform_search(&index, query, search_kind, retrieve_vector, index_scheduler.features())
|
||||||
})
|
})
|
||||||
.await?;
|
.await;
|
||||||
permit.drop().await;
|
permit.drop().await;
|
||||||
|
let search_result = search_result?;
|
||||||
if let Ok(ref search_result) = search_result {
|
if let Ok(ref search_result) = search_result {
|
||||||
aggregate.succeed(search_result);
|
aggregate.succeed(search_result);
|
||||||
}
|
}
|
||||||
@ -281,8 +282,9 @@ pub async fn search_with_post(
|
|||||||
let search_result = tokio::task::spawn_blocking(move || {
|
let search_result = tokio::task::spawn_blocking(move || {
|
||||||
perform_search(&index, query, search_kind, retrieve_vectors, index_scheduler.features())
|
perform_search(&index, query, search_kind, retrieve_vectors, index_scheduler.features())
|
||||||
})
|
})
|
||||||
.await?;
|
.await;
|
||||||
permit.drop().await;
|
permit.drop().await;
|
||||||
|
let search_result = search_result?;
|
||||||
if let Ok(ref search_result) = search_result {
|
if let Ok(ref search_result) = search_result {
|
||||||
aggregate.succeed(search_result);
|
aggregate.succeed(search_result);
|
||||||
if search_result.degraded {
|
if search_result.degraded {
|
||||||
|
@ -81,6 +81,7 @@ pub async fn multi_search_with_post(
|
|||||||
perform_federated_search(&index_scheduler, queries, federation, features)
|
perform_federated_search(&index_scheduler, queries, federation, features)
|
||||||
})
|
})
|
||||||
.await;
|
.await;
|
||||||
|
permit.drop().await;
|
||||||
|
|
||||||
if let Ok(Ok(_)) = search_result {
|
if let Ok(Ok(_)) = search_result {
|
||||||
multi_aggregate.succeed();
|
multi_aggregate.succeed();
|
||||||
@ -143,6 +144,7 @@ pub async fn multi_search_with_post(
|
|||||||
Ok(search_results)
|
Ok(search_results)
|
||||||
}
|
}
|
||||||
.await;
|
.await;
|
||||||
|
permit.drop().await;
|
||||||
|
|
||||||
if search_results.is_ok() {
|
if search_results.is_ok() {
|
||||||
multi_aggregate.succeed();
|
multi_aggregate.succeed();
|
||||||
@ -162,7 +164,6 @@ pub async fn multi_search_with_post(
|
|||||||
HttpResponse::Ok().json(SearchResults { results: search_results })
|
HttpResponse::Ok().json(SearchResults { results: search_results })
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
permit.drop().await;
|
|
||||||
|
|
||||||
Ok(response)
|
Ok(response)
|
||||||
}
|
}
|
||||||
|
@ -48,8 +48,10 @@ impl Permit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Drop for Permit {
|
impl Drop for Permit {
|
||||||
|
/// The implicit drop implementation can still be called in multiple cases:
|
||||||
|
/// - We forgot to call the explicit one somewhere => this should be fixed on our side asap
|
||||||
|
/// - The future is cancelled while running and the permit dropped with it
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
tracing::warn!("Internal error, a search permit was lazily dropped. If you see this message, please open an issue on the meilisearch repository at <https://github.com/meilisearch/meilisearch/issues/new?template=bug_report.md&title=[INTERNAL%20ERROR]%20Meilisearch%20lazily%20dropped%20a%20search%20permit>");
|
|
||||||
let sender = self.sender.clone();
|
let sender = self.sender.clone();
|
||||||
// if the channel is closed then the whole instance is down
|
// if the channel is closed then the whole instance is down
|
||||||
std::mem::drop(tokio::spawn(async move { sender.send(()).await }));
|
std::mem::drop(tokio::spawn(async move { sender.send(()).await }));
|
||||||
|
Loading…
Reference in New Issue
Block a user