From 64e55b4db903554be0615c27bc104a8b05aad318 Mon Sep 17 00:00:00 2001 From: Irevoire Date: Wed, 26 Oct 2022 13:46:11 +0200 Subject: [PATCH] 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 --- index-scheduler/src/index_mapper.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/index-scheduler/src/index_mapper.rs b/index-scheduler/src/index_mapper.rs index 3fc6f9281..a35ec2f0a 100644 --- a/index-scheduler/src/index_mapper.rs +++ b/index-scheduler/src/index_mapper.rs @@ -83,7 +83,14 @@ impl IndexMapper { let index_path = self.base_path.join(uuid.to_string()); 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, }