Skip to content

Commit 20ed793

Browse files
Preslav LeConvex, Inc.
Preslav Le
authored and
Convex, Inc.
committed
Don't run retention for backfilling indexes (#24036)
It is not safe to run retention while index is backfilling for longer than the retention period. To fix the correctness issue, simply don't run retention. We will send a separate PR where index backfill is responsible for catching up retention before enabling the index for reads. GitOrigin-RevId: 86b14762d5a9ba7323309f7617c42e7669dde08c
1 parent 22d2d73 commit 20ed793

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

crates/database/src/retention.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ use async_trait::async_trait;
2424
use common::{
2525
backoff::Backoff,
2626
bootstrap_model::index::{
27-
database_index::IndexedFields,
27+
database_index::{
28+
DatabaseIndexState,
29+
IndexedFields,
30+
},
2831
IndexConfig,
2932
IndexMetadata,
3033
},
@@ -854,11 +857,22 @@ impl<RT: Runtime> LeaderRetentionManager<RT> {
854857
let index: ParsedDocument<IndexMetadata<TableId>> = doc.try_into()?;
855858
let index = index.into_value();
856859
let IndexConfig::Database {
857-
developer_config, ..
860+
developer_config,
861+
on_disk_state,
858862
} = index.config
859863
else {
860864
return Ok(());
861865
};
866+
867+
// Don't run retention for indexes that are currently backfilling. This
868+
// is important for correctness since IndexBackfilling and retention
869+
// interact poorly. NOTE that accumulate only adds indexes. Thus we won't
870+
// stop running retention if index is deleted or goes from Enabled to
871+
// Backfilling.
872+
if let DatabaseIndexState::Backfilling { .. } = on_disk_state {
873+
return Ok(());
874+
}
875+
862876
all_indexes.insert(index_id, (index.name, developer_config.fields));
863877
Ok(())
864878
}

0 commit comments

Comments
 (0)