Expose the env closing event so we can wait for the index to close

This commit is contained in:
Clément Renault
2025-10-07 14:29:42 +02:00
parent 8fb8f389ae
commit 9530e72d04
2 changed files with 13 additions and 6 deletions

View File

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

View File

@@ -4,7 +4,7 @@ use std::time::Duration;
use std::{fs, thread}; use std::{fs, thread};
use meilisearch_types::heed::types::{SerdeJson, Str}; use meilisearch_types::heed::types::{SerdeJson, Str};
use meilisearch_types::heed::{Database, Env, RoTxn, RwTxn, WithoutTls}; use meilisearch_types::heed::{Database, Env, EnvClosingEvent, RoTxn, RwTxn, WithoutTls};
use meilisearch_types::milli; use meilisearch_types::milli;
use meilisearch_types::milli::database_stats::DatabaseStats; use meilisearch_types::milli::database_stats::DatabaseStats;
use meilisearch_types::milli::index::RollbackOutcome; use meilisearch_types::milli::index::RollbackOutcome;