Skip to content

Commit

Permalink
Explicit permit drop for list term
Browse files Browse the repository at this point in the history
  • Loading branch information
rdettai committed Dec 2, 2024
1 parent c34ce22 commit f1d9fa2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions quickwit/quickwit-directories/src/caching_directory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub struct CachingDirectory {
impl CachingDirectory {
/// Creates a new CachingDirectory.
///
/// Warming: The resulting CacheDirectory will cache all information without ever
/// Warning: The resulting CacheDirectory will cache all information without ever
/// removing any item from the cache.
pub fn new_unbounded(underlying: Arc<dyn Directory>) -> CachingDirectory {
let byte_range_cache = ByteRangeCache::with_infinite_capacity(
Expand All @@ -50,7 +50,7 @@ impl CachingDirectory {

/// Creates a new CachingDirectory.
///
/// Warming: The resulting CacheDirectory will cache all information without ever
/// Warning: The resulting CacheDirectory will cache all information without ever
/// removing any item from the cache.
pub fn new(underlying: Arc<dyn Directory>, cache: ByteRangeCache) -> CachingDirectory {
CachingDirectory { underlying, cache }
Expand Down
3 changes: 2 additions & 1 deletion quickwit/quickwit-search/src/leaf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1402,7 +1402,8 @@ async fn leaf_search_single_split_wrapper(
)
.await;

// We explicitly drop it, to highlight it to the reader
// Explicitly drop the permit for readability.
// This should always happen after the ephemeral search cache is dropped.
std::mem::drop(search_permit);

if leaf_search_single_split_res.is_ok() {
Expand Down
8 changes: 5 additions & 3 deletions quickwit/quickwit-search/src/list_terms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ use tracing::{debug, error, info, instrument};

use crate::leaf::open_index_with_caches;
use crate::search_job_placer::group_jobs_by_index_id;
use crate::search_permit_provider::SearchPermit;
use crate::{resolve_index_patterns, ClusterClient, SearchError, SearchJob, SearcherContext};

/// Performs a distributed list terms.
Expand Down Expand Up @@ -216,7 +215,6 @@ async fn leaf_list_terms_single_split(
search_request: &ListTermsRequest,
storage: Arc<dyn Storage>,
split: SplitIdAndFooterOffsets,
_search_permit: SearchPermit,
) -> crate::Result<LeafListTermsResponse> {
let cache =
ByteRangeCache::with_infinite_capacity(&quickwit_storage::STORAGE_METRICS.shortlived_cache);
Expand Down Expand Up @@ -352,10 +350,14 @@ pub async fn leaf_list_terms(
request,
index_storage_clone,
split.clone(),
leaf_split_search_permit,
)
.await;
timer.observe_duration();

// Explicitly drop the permit for readability.
// This should always happen after the ephemeral search cache is dropped.
std::mem::drop(leaf_split_search_permit);

leaf_search_single_split_res.map_err(|err| (split.split_id.clone(), err))
}
})
Expand Down

0 comments on commit f1d9fa2

Please sign in to comment.