Skip to content

Commit

Permalink
fix: prevent empty indexes when using --reindex always
Browse files Browse the repository at this point in the history
When reindexing, the indexes are "reset", which basically means that
new indexes are being created. However, the loop still holds on to the
old writers. So when resetting the indexes, we must also create new
writers.

Otherwise the logic will write to the old indexes, and the new ones
will stay empty.
  • Loading branch information
ctron committed Jan 17, 2024
1 parent 131379f commit 58ab567
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions indexer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,18 @@ where
async fn handle_reindex(&mut self, writers: &mut Vec<IndexWriter>) -> anyhow::Result<()> {
log::info!("Reindexing all documents");

// set the indexes
for index in &mut self.indexes {
index.reset()?;
}

// after resetting, we need to acquire new writers, as the old indexes are gone
writers.clear();
for index in self.indexes.iter_mut() {
writers.push(block_in_place(|| index.writer())?);
}

// now walk the full content with the new (empty) indexes
const MAX_RETRIES: usize = 3;
let mut retries = MAX_RETRIES;
let mut token = ContinuationToken::default();
Expand Down

0 comments on commit 58ab567

Please sign in to comment.