mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-02-06 19:06:43 +08:00
move the commit before the insertion in the map
This commit is contained in:
parent
4e1b6b514e
commit
6c98752922
@ -75,8 +75,11 @@ impl IndexMapper {
|
|||||||
|
|
||||||
/// Get or create the index.
|
/// Get or create the index.
|
||||||
pub fn create_index(&self, mut wtxn: RwTxn, name: &str) -> Result<Index> {
|
pub fn create_index(&self, mut wtxn: RwTxn, name: &str) -> Result<Index> {
|
||||||
let ret = match self.index(&mut wtxn, name) {
|
match self.index(&mut wtxn, name) {
|
||||||
Ok(index) => Ok(index),
|
Ok(index) => {
|
||||||
|
wtxn.commit()?;
|
||||||
|
Ok(index)
|
||||||
|
}
|
||||||
Err(Error::IndexNotFound(_)) => {
|
Err(Error::IndexNotFound(_)) => {
|
||||||
let uuid = Uuid::new_v4();
|
let uuid = Uuid::new_v4();
|
||||||
self.index_mapping.put(&mut wtxn, name, &uuid)?;
|
self.index_mapping.put(&mut wtxn, name, &uuid)?;
|
||||||
@ -85,6 +88,7 @@ impl IndexMapper {
|
|||||||
fs::create_dir_all(&index_path)?;
|
fs::create_dir_all(&index_path)?;
|
||||||
let index = self.create_or_open_index(&index_path)?;
|
let index = self.create_or_open_index(&index_path)?;
|
||||||
|
|
||||||
|
wtxn.commit()?;
|
||||||
// TODO: it would be better to lazyly create the index. But we need an Index::open function for milli.
|
// TODO: it would be better to lazyly create the index. But we need an Index::open function for milli.
|
||||||
if let Some(BeingDeleted) =
|
if let Some(BeingDeleted) =
|
||||||
self.index_map.write().unwrap().insert(uuid, Available(index.clone()))
|
self.index_map.write().unwrap().insert(uuid, Available(index.clone()))
|
||||||
@ -95,10 +99,7 @@ impl IndexMapper {
|
|||||||
Ok(index)
|
Ok(index)
|
||||||
}
|
}
|
||||||
error => error,
|
error => error,
|
||||||
};
|
}
|
||||||
let index = ret?;
|
|
||||||
wtxn.commit()?;
|
|
||||||
Ok(index)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Removes the index from the mapping table and the in-memory index map
|
/// Removes the index from the mapping table and the in-memory index map
|
||||||
|
Loading…
x
Reference in New Issue
Block a user