fix the index creation. When an index is being created we insert it in the index_map straight away to avoid someone else from trying to re-open it. The definitive fix should be made on milli's side

This commit is contained in:
Irevoire 2022-10-26 13:46:11 +02:00 committed by Clément Renault
parent 9b43528bbb
commit 64e55b4db9
No known key found for this signature in database
GPG Key ID: 92ADA4E935E71FA4

View File

@ -83,7 +83,14 @@ impl IndexMapper {
let index_path = self.base_path.join(uuid.to_string()); let index_path = self.base_path.join(uuid.to_string());
fs::create_dir_all(&index_path)?; fs::create_dir_all(&index_path)?;
self.create_or_open_index(&index_path) let index = self.create_or_open_index(&index_path)?;
// TODO: this is far from perfect. If the caller don't commit or fail his commit
// then we end up with an available index that should not exist and is actually
// not available in the index_mapping database.
self.index_map.write().unwrap().insert(uuid, Available(index.clone()));
Ok(index)
} }
error => error, error => error,
} }