From d4ce5389cecb4d5996c09bd2ed862bdb44906741 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danie=CC=88l=20de=20Kok?= Date: Tue, 16 Jul 2024 10:20:11 +0000 Subject: [PATCH] Add another problematic case --- router/src/infer/v3/block_allocator.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/router/src/infer/v3/block_allocator.rs b/router/src/infer/v3/block_allocator.rs index 65e75be8..f9bc6764 100644 --- a/router/src/infer/v3/block_allocator.rs +++ b/router/src/infer/v3/block_allocator.rs @@ -420,4 +420,14 @@ mod tests { assert_eq!(allocation3.blocks, vec![3, 2]); assert_eq!(allocation3.slots, vec![6, 7, 4, 5]); } + + #[test] + fn test_overlapping_prefixes_in_flight() { + let mut cache = PrefixCacheAllocator::new(2, 5, None); + let allocation1 = cache.alloc(4, &[0, 1, 2, 3]).unwrap(); + let allocation2 = cache.alloc(4, &[0, 1, 2, 3]).unwrap(); + + cache.free(&allocation2.blocks, &allocation2.prefix_hashes); + cache.free(&allocation1.blocks, &allocation1.prefix_hashes); + } }