Fix race with LedgerCleanupService (#5622)

This commit is contained in:
carllin 2019-08-23 23:40:20 -07:00 committed by Michael Vines
parent 4e827af392
commit 6e82978931
1 changed files with 16 additions and 9 deletions

View File

@ -29,16 +29,23 @@ impl<'a> Iterator for RootedSlotIterator<'a> {
.find(|x| self.blocktree.is_root(**x)) .find(|x| self.blocktree.is_root(**x))
.cloned(); .cloned();
rooted_slot.map(|rooted_slot| { rooted_slot
let slot_meta = self .map(|rooted_slot| {
.blocktree let slot_meta = self
.meta(rooted_slot) .blocktree
.expect("Database failure, couldnt fetch SlotMeta") .meta(rooted_slot)
.expect("SlotMeta in iterator didn't exist"); .expect("Database failure, couldnt fetch SlotMeta");
self.next_slots = slot_meta.next_slots.clone(); if slot_meta.is_none() {
(rooted_slot, slot_meta) warn!("Rooted SlotMeta was deleted in between checking is_root and fetch");
}) }
slot_meta.map(|slot_meta| {
self.next_slots = slot_meta.next_slots.clone();
(rooted_slot, slot_meta)
})
})
.unwrap_or(None)
} }
} }