Do not return the EnvClosingEvent

This commit is contained in:
Kerollmops
2025-10-08 15:37:36 +02:00
parent 3aca010b42
commit 9a36c090bf
3 changed files with 13 additions and 16 deletions

View File

@@ -220,9 +220,11 @@ impl IndexMap {
uuid: &Uuid,
enable_mdb_writemap: bool,
map_size_growth: usize,
) -> Option<EnvClosingEvent> {
let index = self.available.remove(uuid)?;
Some(self.close(*uuid, index, enable_mdb_writemap, map_size_growth))
) {
let Some(index) = self.available.remove(uuid) else {
return;
};
self.close(*uuid, index, enable_mdb_writemap, map_size_growth);
}
fn close(
@@ -231,21 +233,14 @@ impl IndexMap {
index: Index,
enable_mdb_writemap: bool,
map_size_growth: usize,
) -> EnvClosingEvent {
) {
let map_size = index.map_size() + map_size_growth;
let closing_event = index.prepare_for_closing();
let generation = self.next_generation();
self.unavailable.insert(
uuid,
Some(ClosingIndex {
uuid,
closing_event: closing_event.clone(),
enable_mdb_writemap,
map_size,
generation,
}),
Some(ClosingIndex { uuid, closing_event, enable_mdb_writemap, map_size, generation }),
);
closing_event
}
/// Attempts to delete and index.

View File

@@ -4,7 +4,7 @@ use std::time::Duration;
use std::{fs, thread};
use meilisearch_types::heed::types::{SerdeJson, Str};
use meilisearch_types::heed::{Database, Env, EnvClosingEvent, RoTxn, RwTxn, WithoutTls};
use meilisearch_types::heed::{Database, Env, RoTxn, RwTxn, WithoutTls};
use meilisearch_types::milli;
use meilisearch_types::milli::database_stats::DatabaseStats;
use meilisearch_types::milli::index::RollbackOutcome;
@@ -349,14 +349,16 @@ impl IndexMapper {
///
/// - If the Index corresponding to the passed name is concurrently being deleted/resized or cannot be found in the
/// in memory hash map.
pub fn close_index(&self, rtxn: &RoTxn, name: &str) -> Result<Option<EnvClosingEvent>> {
pub fn close_index(&self, rtxn: &RoTxn, name: &str) -> Result<()> {
let uuid = self
.index_mapping
.get(rtxn, name)?
.ok_or_else(|| Error::IndexNotFound(name.to_string()))?;
// We remove the index from the in-memory index map.
Ok(self.index_map.write().unwrap().close_for_resize(&uuid, self.enable_mdb_writemap, 0))
self.index_map.write().unwrap().close_for_resize(&uuid, self.enable_mdb_writemap, 0);
Ok(())
}
/// Return an index, may open it if it wasn't already opened.

View File

@@ -578,7 +578,7 @@ impl IndexScheduler {
// 5. Prepare to close the index
progress.update_progress(IndexCompaction::CloseTheIndex);
let _closing_event = self.index_mapper.close_index(rtxn, index_uid)?;
self.index_mapper.close_index(rtxn, index_uid)?;
drop(index);
progress.update_progress(IndexCompaction::ReopenTheIndex);