Merge pull request #241 from meilisearch/fix-dead-locks

Fix dead locks
This commit is contained in:
Clément Renault 2019-10-28 18:20:01 +01:00 committed by GitHub
commit af96050944
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions

View File

@ -35,11 +35,14 @@ fn update_awaiter(receiver: Receiver<()>, env: heed::Env, update_fn: Arc<ArcSwap
match update::update_task(&mut writer, index.clone()) { match update::update_task(&mut writer, index.clone()) {
Ok(Some(status)) => { Ok(Some(status)) => {
if status.result.is_ok() { match status.result {
Ok(_) => {
if let Err(e) = writer.commit() { if let Err(e) = writer.commit() {
error!("update transaction failed: {}", e) error!("update transaction failed: {}", e)
} }
} }
Err(_) => writer.abort(),
}
if let Some(ref callback) = *update_fn.load() { if let Some(ref callback) = *update_fn.load() {
(callback)(status); (callback)(status);

View File

@ -167,6 +167,7 @@ impl Index {
} }
pub fn clear_all(&self, writer: &mut heed::RwTxn) -> MResult<u64> { pub fn clear_all(&self, writer: &mut heed::RwTxn) -> MResult<u64> {
let _ = self.updates_notifier.send(());
update::push_clear_all(writer, self.updates, self.updates_results) update::push_clear_all(writer, self.updates, self.updates_results)
} }