pub(crate) fn run_purge_with_stats(
        &self,
        from_slot: Slot,
        to_slot: Slot,
        purge_type: PurgeType,
        purge_stats: &mut PurgeStats,
    ) -> Result<bool> {
        let mut write_batch = self
            .db
            .batch()
            .expect("Database Error: Failed to get write batch");
        // delete range cf is not inclusive
        let to_slot = to_slot.checked_add(1).unwrap_or(std::u64::MAX);

        let mut delete_range_timer = Measure::start("delete_range");
        let mut columns_purged = self
            .db
            .delete_range_cf::<cf::SlotMeta>(&mut write_batch, from_slot, to_slot)
            .is_ok()
            & self
                .db
                .delete_range_cf::<cf::Root>(&mut write_batch, from_slot, to_slot)
                .is_ok()
            & self
                .db
                .delete_range_cf::<cf::ShredData>(&mut write_batch, from_slot, to_slot)
                .is_ok()
            & self
                .db
                .delete_range_cf::<cf::ShredCode>(&mut write_batch, from_slot, to_slot)
                .is_ok()
            & self
                .db
                .delete_range_cf::<cf::DeadSlots>(&mut write_batch, from_slot, to_slot)
                .is_ok()
            & self
                .db
                .delete_range_cf::<cf::DuplicateSlots>(&mut write_batch, from_slot, to_slot)
                .is_ok()
            & self
                .db
                .delete_range_cf::<cf::ErasureMeta>(&mut write_batch, from_slot, to_slot)
                .is_ok()
            & self
                .db
                .delete_range_cf::<cf::Orphans>(&mut write_batch, from_slot, to_slot)
                .is_ok()
            & self
                .db
                .delete_range_cf::<cf::Index>(&mut write_batch, from_slot, to_slot)
                .is_ok()
            & self
                .db
                .delete_range_cf::<cf::Rewards>(&mut write_batch, from_slot, to_slot)
                .is_ok()
            & self
                .db
                .delete_range_cf::<cf::Blocktime>(&mut write_batch, from_slot, to_slot)
                .is_ok()
            & self
                .db
                .delete_range_cf::<cf::PerfSamples>(&mut write_batch, from_slot, to_slot)
                .is_ok();
        let mut w_active_transaction_status_index =
            self.active_transaction_status_index.write().unwrap();
        match purge_type {
            PurgeType::Exact => {
                self.purge_special_columns_exact(&mut write_batch, from_slot, to_slot)?;
            }
            PurgeType::PrimaryIndex => {
                self.purge_special_columns_with_primary_index(
                    &mut write_batch,
                    &mut columns_purged,
                    &mut w_active_transaction_status_index,
                    to_slot,
                )?;
            }
        }
        delete_range_timer.stop();
        let mut write_timer = Measure::start("write_batch");
        if let Err(e) = self.db.write(write_batch) {
            error!(
                "Error: {:?} while submitting write batch for slot {:?} retrying...",
                e, from_slot
            );
            return Err(e);
        }
        write_timer.stop();
        purge_stats.delete_range += delete_range_timer.as_us();
        purge_stats.write_batch += write_timer.as_us();
        Ok(columns_purged)
    }
// Returns whether or not all columns successfully purged the slot range
Returns whether or not all columns successfully purged the slot range
Returns whether or not all columns successfully purged the slot range
pub(crate) fn run_purge_with_stats(
        &self,
        from_slot: Slot,
        to_slot: Slot,
        purge_type: PurgeType,
        purge_stats: &mut PurgeStats,
    ) -> Result<bool> {
        let mut write_batch = self
            .db
            .batch()
            .expect("Database Error: Failed to get write batch");
        // delete range cf is not inclusive
        let to_slot = to_slot.checked_add(1).unwrap_or(std::u64::MAX);
        let mut delete_range_timer = Measure::start("delete_range");
        let mut columns_purged = self
            .db
            .delete_range_cf::<cf::SlotMeta>(&mut write_batch, from_slot, to_slot)
            .is_ok()
            & self
                .db
                .delete_range_cf::<cf::Root>(&mut write_batch, from_slot, to_slot)
                .is_ok()
            & self
                .db
                .delete_range_cf::<cf::ShredData>(&mut write_batch, from_slot, to_slot)
                .is_ok()
            & self
                .db
                .delete_range_cf::<cf::ShredCode>(&mut write_batch, from_slot, to_slot)
                .is_ok()
            & self
                .db
                .delete_range_cf::<cf::DeadSlots>(&mut write_batch, from_slot, to_slot)
                .is_ok()
            & self
                .db
                .delete_range_cf::<cf::DuplicateSlots>(&mut write_batch, from_slot, to_slot)
                .is_ok()
            & self
                .db
                .delete_range_cf::<cf::ErasureMeta>(&mut write_batch, from_slot, to_slot)
                .is_ok()
            & self
                .db
                .delete_range_cf::<cf::Orphans>(&mut write_batch, from_slot, to_slot)
                .is_ok()
            & self
                .db
                .delete_range_cf::<cf::Index>(&mut write_batch, from_slot, to_slot)
                .is_ok()
            & self
                .db
                .delete_range_cf::<cf::Rewards>(&mut write_batch, from_slot, to_slot)
                .is_ok()
            & self
                .db
                .delete_range_cf::<cf::Blocktime>(&mut write_batch, from_slot, to_slot)
                .is_ok()
            & self
                .db
                .delete_range_cf::<cf::PerfSamples>(&mut write_batch, from_slot, to_slot)
                .is_ok();
        let mut w_active_transaction_status_index =
            self.active_transaction_status_index.write().unwrap();
        match purge_type {
            PurgeType::Exact => {
                self.purge_special_columns_exact(&mut write_batch, from_slot, to_slot)?;
            }
            PurgeType::PrimaryIndex => {
                self.purge_special_columns_with_primary_index(
                    &mut write_batch,
                    &mut columns_purged,
                    &mut w_active_transaction_status_index,
                    to_slot,
                )?;
            }
        }
        delete_range_timer.stop();
        let mut write_timer = Measure::start("write_batch");
        if let Err(e) = self.db.write(write_batch) {
            error!(
                "Error: {:?} while submitting write batch for slot {:?} retrying...",
                e, from_slot
            );
            return Err(e);
        }
        write_timer.stop();
        purge_stats.delete_range += delete_range_timer.as_us();
        purge_stats.write_batch += write_timer.as_us();
        Ok(columns_purged)
    }
pub ( crate ) fn run_purge_with_stats ( & self , from_slot : Slot , to_slot : Slot , purge_type : PurgeType , purge_stats : & mut PurgeStats , ) -> Result < bool > { let mut write_batch = self . db . batch ( ) . expect ( " " ) ; // delete range cf is not inclusive let to_slot = to_slot . checked_add ( 1 ) . unwrap_or ( std :: u64 :: MAX ) ; let mut delete_range_timer = Measure :: start ( " " ) ; let mut columns_purged = self . db . delete_range_cf :: < cf :: SlotMeta > ( & mut write_batch , from_slot , to_slot ) . is_ok ( ) & self . db . delete_range_cf :: < cf :: Root > ( & mut write_batch , from_slot , to_slot ) . is_ok ( ) & self . db . delete_range_cf :: < cf :: ShredData > ( & mut write_batch , from_slot , to_slot ) . is_ok ( ) & self . db . delete_range_cf :: < cf :: ShredCode > ( & mut write_batch , from_slot , to_slot ) . is_ok ( ) & self . db . delete_range_cf :: < cf :: DeadSlots > ( & mut write_batch , from_slot , to_slot ) . is_ok ( ) & self . db . delete_range_cf :: < cf :: DuplicateSlots > ( & mut write_batch , from_slot , to_slot ) . is_ok ( ) & self . db . delete_range_cf :: < cf :: ErasureMeta > ( & mut write_batch , from_slot , to_slot ) . is_ok ( ) & self . db . delete_range_cf :: < cf :: Orphans > ( & mut write_batch , from_slot , to_slot ) . is_ok ( ) & self . db . delete_range_cf :: < cf :: Index > ( & mut write_batch , from_slot , to_slot ) . is_ok ( ) & self . db . delete_range_cf :: < cf :: Rewards > ( & mut write_batch , from_slot , to_slot ) . is_ok ( ) & self . db . delete_range_cf :: < cf :: Blocktime > ( & mut write_batch , from_slot , to_slot ) . is_ok ( ) & self . db . delete_range_cf :: < cf :: PerfSamples > ( & mut write_batch , from_slot , to_slot ) . is_ok ( ) ; let mut w_active_transaction_status_index = self . active_transaction_status_index . write ( ) . unwrap ( ) ; match purge_type { PurgeType :: Exact => { self . purge_special_columns_exact ( & mut write_batch , from_slot , to_slot ) ? ; } PurgeType :: PrimaryIndex => { self . purge_special_columns_with_primary_index ( & mut write_batch , & mut columns_purged , & mut w_active_transaction_status_index , to_slot , ) ? ; } } delete_range_timer . stop ( ) ; let mut write_timer = Measure :: start ( " " ) ; if let Err ( e ) = self . db . write ( write_batch ) { error ! ( " " e from_slot ) ; return Err ( e ) ; } write_timer . stop ( ) ; purge_stats . delete_range += delete_range_timer . as_us ( ) ; purge_stats . write_batch += write_timer . as_us ( ) ; Ok ( columns_purged ) }
Returns whether or not all columns successfully purged the slot range
Returns whether or not all columns successfully purged the slot range
&self
from_slot
Slot
to_slot
Slot
purge_type
PurgeType
purge_stats
&mut PurgeStats