diff --git a/meilisearch-http/src/index_controller/update_actor/store/mod.rs b/meilisearch-http/src/index_controller/update_actor/store/mod.rs index 99593cac8..8e85429ca 100644 --- a/meilisearch-http/src/index_controller/update_actor/store/mod.rs +++ b/meilisearch-http/src/index_controller/update_actor/store/mod.rs @@ -442,13 +442,16 @@ impl UpdateStore { while let Some(Ok(((_, uuid, _), pending))) = pendings.next() { if uuid == index_uuid { - unsafe { - pendings.del_current()?; - } let mut pending = pending.decode()?; if let Some(update_uuid) = pending.content.take() { uuids_to_remove.push(update_uuid); } + + // Invariant check: we can only delete the current entry when we don't hold + // references to it anymore. This must be done after we have retrieved its content. + unsafe { + pendings.del_current()?; + } } }