From 279317cb1ee8594ca109031a755e3e56dff9b188 Mon Sep 17 00:00:00 2001 From: Vadzim Dambrouski Date: Tue, 16 Apr 2024 12:36:45 +0200 Subject: [PATCH] Fix crash in replication logic when removing logs from interval. (#933) * Fix crash in replication logic when removing logs from interval. Closes #931 --- .../zenoh-plugin-storage-manager/src/replica/digest.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/plugins/zenoh-plugin-storage-manager/src/replica/digest.rs b/plugins/zenoh-plugin-storage-manager/src/replica/digest.rs index 98faa24aa2..e64e81f3d6 100644 --- a/plugins/zenoh-plugin-storage-manager/src/replica/digest.rs +++ b/plugins/zenoh-plugin-storage-manager/src/replica/digest.rs @@ -309,6 +309,7 @@ impl Digest { for int in intervals_to_update { let interval = intervals.get_mut(&int).unwrap(); + interval.content.retain(|x| subintervals.contains_key(x)); let content = &interval.content; if !content.is_empty() { // order the content, hash them @@ -325,6 +326,7 @@ impl Digest { for era_type in eras_to_update { let era = eras.get_mut(&era_type).unwrap(); + era.content.retain(|x| intervals.contains_key(x)); let content = &era.content; if !content.is_empty() { // order the content, hash them @@ -491,11 +493,7 @@ impl Digest { .get_mut(&subinterval) .unwrap() .content - .retain(|x| { - x.timestamp.get_time() != entry.timestamp.get_time() - && x.timestamp.get_id() != entry.timestamp.get_id() - && x.key != entry.key - }); + .retain(|x| x.timestamp != entry.timestamp || x.key != entry.key); subintervals_to_update.insert(subinterval); } if current.intervals.contains_key(&interval) {