From 6768d01dbab70243b12b026c04f682b5d2345b7b Mon Sep 17 00:00:00 2001 From: trinity-1686a Date: Thu, 5 Sep 2024 17:24:43 +0200 Subject: [PATCH] fix flaky test on gc (#5391) --- .../quickwit-index-management/src/garbage_collection.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/quickwit/quickwit-index-management/src/garbage_collection.rs b/quickwit/quickwit-index-management/src/garbage_collection.rs index 91fcb7312a9..1aae3409d1e 100644 --- a/quickwit/quickwit-index-management/src/garbage_collection.rs +++ b/quickwit/quickwit-index-management/src/garbage_collection.rs @@ -183,6 +183,7 @@ async fn delete_splits_marked_for_deletion( let mut failed_splits = Vec::new(); 'outer: loop { + let mut exit = false; let query = ListSplitsQuery::try_from_index_uids(index_uids.clone())? .with_split_state(SplitState::MarkedForDeletion) .with_update_timestamp_lte(updated_before_timestamp) @@ -248,11 +249,13 @@ async fn delete_splits_marked_for_deletion( Err(delete_splits_error) => { failed_splits.extend(delete_splits_error.storage_failures); failed_splits.extend(delete_splits_error.metastore_failures); - break; + exit = true; } } } - if num_splits_to_delete < DELETE_SPLITS_BATCH_SIZE { + if num_splits_to_delete < DELETE_SPLITS_BATCH_SIZE || exit { + // stop the gc if this was the last batch or we encountered an error + // (otherwise we might try deleting the same splits in an endless loop) break; } }