diff --git a/quickwit/quickwit-index-management/src/garbage_collection.rs b/quickwit/quickwit-index-management/src/garbage_collection.rs index 880caafd90f..f38add10d4d 100644 --- a/quickwit/quickwit-index-management/src/garbage_collection.rs +++ b/quickwit/quickwit-index-management/src/garbage_collection.rs @@ -94,23 +94,23 @@ pub async fn run_garbage_collect( dry_run: bool, progress_opt: Option<&Progress>, ) -> anyhow::Result { - - - let grace_period_timestamp = OffsetDateTime::now_utc().unix_timestamp() - staged_grace_period.as_secs() as i64; let index_uids: Vec = indexes.keys().cloned().collect(); - let Some(list_splits_query_for_index_uids) = ListSplitsQuery::try_from_index_uids(index_uids.clone()) else { - return Ok(SplitRemovalInfo::default()) + let Some(list_splits_query_for_index_uids) = + ListSplitsQuery::try_from_index_uids(index_uids.clone()) + else { + return Ok(SplitRemovalInfo::default()); }; let list_splits_query = list_splits_query_for_index_uids .clone() .with_split_state(SplitState::Staged) .with_update_timestamp_lte(grace_period_timestamp); - let list_deletable_staged_request = ListSplitsRequest::try_from_list_splits_query(&list_splits_query)?; + let list_deletable_staged_request = + ListSplitsRequest::try_from_list_splits_query(&list_splits_query)?; let deletable_staged_splits: Vec = protect_future( progress_opt, metastore.list_splits(list_deletable_staged_request), @@ -120,8 +120,8 @@ pub async fn run_garbage_collect( .await?; if dry_run { - let marked_for_deletion_query = list_splits_query_for_index_uids - .with_split_state(SplitState::MarkedForDeletion); + let marked_for_deletion_query = + list_splits_query_for_index_uids.with_split_state(SplitState::MarkedForDeletion); let marked_for_deletion_request = ListSplitsRequest::try_from_list_splits_query(&marked_for_deletion_query)?; let mut splits_marked_for_deletion: Vec = protect_future( @@ -244,15 +244,20 @@ async fn delete_splits( use anyhow::Context; /// Fetch the list metadata from the metastore and returns them as a Vec. -async fn list_splits_metadata(metastore: &MetastoreServiceClient, query: &ListSplitsQuery) -> anyhow::Result> { +async fn list_splits_metadata( + metastore: &MetastoreServiceClient, + query: &ListSplitsQuery, +) -> anyhow::Result> { let list_splits_request = ListSplitsRequest::try_from_list_splits_query(&query) .context("failed to build list splits request")?; let metastore = metastore.clone(); - let splits_to_delete_stream = - metastore - .list_splits(list_splits_request).await - .context("failed to fetch stream splits")?; - let splits = splits_to_delete_stream.collect_splits_metadata().await + let splits_to_delete_stream = metastore + .list_splits(list_splits_request) + .await + .context("failed to fetch stream splits")?; + let splits = splits_to_delete_stream + .collect_splits_metadata() + .await .context("failed to collect splits")?; Ok(splits) } @@ -284,7 +289,12 @@ async fn delete_splits_marked_for_deletion_several_indexes( .sort_by_index_uid(); loop { - let splits_metadata_to_delete: Vec = match protect_future(progress_opt, list_splits_metadata(&metastore, &list_splits_query)).await { + let splits_metadata_to_delete: Vec = match protect_future( + progress_opt, + list_splits_metadata(&metastore, &list_splits_query), + ) + .await + { Ok(splits) => splits, Err(list_splits_err) => { error!(error=?list_splits_err, "failed to list splits"); diff --git a/quickwit/quickwit-search/src/list_terms.rs b/quickwit/quickwit-search/src/list_terms.rs index acde5d0f39d..0a781355162 100644 --- a/quickwit/quickwit-search/src/list_terms.rs +++ b/quickwit/quickwit-search/src/list_terms.rs @@ -91,7 +91,8 @@ pub async fn root_list_terms( .map(|index_metadata| index_metadata.index_uid.clone()) .collect(); - let Some(mut query) = quickwit_metastore::ListSplitsQuery::try_from_index_uids(index_uids) else { + let Some(mut query) = quickwit_metastore::ListSplitsQuery::try_from_index_uids(index_uids) + else { return Ok(ListTermsResponse::default()); }; query = query.with_split_state(quickwit_metastore::SplitState::Published);