commit the index wtxn before the index-scheduler wtxn

This commit is contained in:
Tamo 2025-01-22 16:21:00 +01:00 committed by Louis Dureuil
parent eda09a54da
commit d4d82fbd0c
No known key found for this signature in database
2 changed files with 12 additions and 7 deletions

View File

@ -21,18 +21,22 @@ impl IndexScheduler {
indexes.len() as u32,
));
let index = self.index(uid)?;
let mut wtxn = index.write_txn()?;
let regen_stats = milli::update::upgrade::upgrade(&mut wtxn, &index, progress.clone())
.map_err(|e| Error::from_milli(e, Some(uid.to_string())))?;
if regen_stats {
let stats = crate::index_mapper::IndexStats::new(&index, &wtxn)
let mut index_wtxn = index.write_txn()?;
let regen_stats =
milli::update::upgrade::upgrade(&mut index_wtxn, &index, progress.clone())
.map_err(|e| Error::from_milli(e, Some(uid.to_string())))?;
if regen_stats {
let stats = crate::index_mapper::IndexStats::new(&index, &index_wtxn)
.map_err(|e| Error::from_milli(e, Some(uid.to_string())))?;
index_wtxn.commit()?;
// Release wtxn as soon as possible because it stops us from registering tasks
let mut index_schd_wtxn = self.env.write_txn()?;
self.index_mapper.store_stats_of(&mut index_schd_wtxn, uid, &stats)?;
index_schd_wtxn.commit()?;
} else {
index_wtxn.commit()?;
}
wtxn.commit()?;
}
Ok(())

View File

@ -406,7 +406,8 @@ impl IndexSchedulerHandle {
.recv_timeout(std::time::Duration::from_secs(1)) {
Ok((_, true)) => continue,
Ok((b, false)) => panic!("The scheduler was supposed to be down but successfully moved to the next breakpoint: {b:?}"),
Err(RecvTimeoutError::Timeout | RecvTimeoutError::Disconnected) => break,
Err(RecvTimeoutError::Timeout) => panic!(),
Err(RecvTimeoutError::Disconnected) => break,
}
}
}