diff --git a/bucket_map/src/bucket.rs b/bucket_map/src/bucket.rs index 924aa8b173ee42..e727e8424a8a10 100644 --- a/bucket_map/src/bucket.rs +++ b/bucket_map/src/bucket.rs @@ -679,11 +679,20 @@ impl<'b, T: Clone + Copy + PartialEq + std::fmt::Debug + 'static> Bucket { } } - pub fn apply_grow_index(&mut self, index: BucketStorage>) { + pub fn apply_grow_index(&mut self, mut index: BucketStorage>) { self.stats .index .resize_grow(self.index.capacity_bytes(), index.capacity_bytes()); + if self.restartable_bucket.restart.is_some() { + // we are keeping track of which files we use for restart. + // And we are resizing. + // So, delete the old file and set the new file to NOT delete. + // This way the new file will still be around on startup. + // We are completely done with the old file. + self.index.delete_file_on_drop = true; + index.delete_file_on_drop = false; + } self.index = index; }