From a6e731f394e5d55ee1ab909fceda9313a010fba4 Mon Sep 17 00:00:00 2001 From: Ashwin Sekar Date: Fri, 8 Mar 2024 15:30:05 -0800 Subject: [PATCH] v1.18: blockstore: relax parent slot meta check for clear_unconfirmed_slot (#68) blockstore: relax parent slot meta check for clear_unconfirmed_slot --- ledger/src/blockstore.rs | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/ledger/src/blockstore.rs b/ledger/src/blockstore.rs index dd372e811bda0c..5c086d057dae38 100644 --- a/ledger/src/blockstore.rs +++ b/ledger/src/blockstore.rs @@ -1179,18 +1179,25 @@ impl Blockstore { // Clear this slot as a next slot from parent if let Some(parent_slot) = slot_meta.parent_slot { - let mut parent_slot_meta = self + if let Some(mut parent_slot_meta) = self .meta(parent_slot) .expect("Couldn't fetch from SlotMeta column family") - .expect("Unconfirmed slot should have had parent slot set"); - // .retain() is a linear scan; however, next_slots should - // only contain several elements so this isn't so bad - parent_slot_meta - .next_slots - .retain(|&next_slot| next_slot != slot); - self.meta_cf - .put(parent_slot, &parent_slot_meta) - .expect("Couldn't insert into SlotMeta column family"); + { + // .retain() is a linear scan; however, next_slots should + // only contain several elements so this isn't so bad + parent_slot_meta + .next_slots + .retain(|&next_slot| next_slot != slot); + self.meta_cf + .put(parent_slot, &parent_slot_meta) + .expect("Couldn't insert into SlotMeta column family"); + } else { + error!( + "Parent slot meta {} for child {} is missing or cleaned up. + Falling back to orphan repair to remedy the situation", + parent_slot, slot + ); + } } // Reinsert parts of `slot_meta` that are important to retain, like the `next_slots` // field.