(Ledger Store) Improve comments for blockstore_purge (#22808)
This commit is contained in:
parent
c7ca2f41f5
commit
37afdd1a65
|
@ -104,9 +104,16 @@ pub struct SignatureInfosForAddress {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy)]
|
||||||
|
/// Controls how `blockstore::purge_slots` purges the data.
|
||||||
pub enum PurgeType {
|
pub enum PurgeType {
|
||||||
|
/// A slower but more accurate way to purge slots by also ensuring higher
|
||||||
|
/// level of consistency between data during the clean up process.
|
||||||
Exact,
|
Exact,
|
||||||
|
/// A faster approximation of `Exact` where the purge process only takes
|
||||||
|
/// care of the primary index and does not update the associated entries.
|
||||||
PrimaryIndex,
|
PrimaryIndex,
|
||||||
|
/// The fastest purge mode that relies on the slot-id based TTL
|
||||||
|
/// compaction filter to do the cleanup.
|
||||||
CompactionFilter,
|
CompactionFilter,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,10 +7,21 @@ pub struct PurgeStats {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Blockstore {
|
impl Blockstore {
|
||||||
/// Silently deletes all blockstore column families in the range \[from_slot,to_slot\]
|
/// Performs cleanup based on the specified deletion range. After this
|
||||||
/// Dangerous; Use with care:
|
/// function call, entries within \[`from_slot`, `to_slot`\] will become
|
||||||
/// Does not check for integrity and does not update slot metas that refer to deleted slots
|
/// unavailable to the reader immediately, while its disk space occupied
|
||||||
/// Modifies multiple column families simultaneously
|
/// by the deletion entries are reclaimed later via RocksDB's background
|
||||||
|
/// compaction.
|
||||||
|
///
|
||||||
|
/// Note that this function modifies multiple column families at the same
|
||||||
|
/// time and might break the consistency between different column families
|
||||||
|
/// as it does not update the associated slot-meta entries that refer to
|
||||||
|
/// the deleted entries.
|
||||||
|
///
|
||||||
|
/// For slot-id based column families, the purge is done by range deletion,
|
||||||
|
/// while the non-slot-id based column families, `cf::TransactionStatus`,
|
||||||
|
/// `AddressSignature`, and `cf::TransactionStatusIndex`, are cleaned-up
|
||||||
|
/// based on the `purge_type` setting.
|
||||||
pub fn purge_slots(&self, from_slot: Slot, to_slot: Slot, purge_type: PurgeType) {
|
pub fn purge_slots(&self, from_slot: Slot, to_slot: Slot, purge_type: PurgeType) {
|
||||||
let mut purge_stats = PurgeStats::default();
|
let mut purge_stats = PurgeStats::default();
|
||||||
let purge_result =
|
let purge_result =
|
||||||
|
@ -114,7 +125,8 @@ impl Blockstore {
|
||||||
self.run_purge_with_stats(from_slot, to_slot, purge_type, &mut PurgeStats::default())
|
self.run_purge_with_stats(from_slot, to_slot, purge_type, &mut PurgeStats::default())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns whether or not all columns successfully purged the slot range
|
/// A helper function to `purge_slots` that executes the ledger clean up
|
||||||
|
/// from `from_slot` to `to_slot`.
|
||||||
pub(crate) fn run_purge_with_stats(
|
pub(crate) fn run_purge_with_stats(
|
||||||
&self,
|
&self,
|
||||||
from_slot: Slot,
|
from_slot: Slot,
|
||||||
|
@ -314,9 +326,11 @@ impl Blockstore {
|
||||||
Ok(result)
|
Ok(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Purges special columns (using a non-Slot primary-index) exactly, by deserializing each slot
|
/// Purges special columns (using a non-Slot primary-index) exactly, by
|
||||||
/// being purged and iterating through all transactions to determine the keys of individual
|
/// deserializing each slot being purged and iterating through all
|
||||||
/// records. **This method is very slow.**
|
/// transactions to determine the keys of individual records.
|
||||||
|
///
|
||||||
|
/// **This method is very slow.**
|
||||||
fn purge_special_columns_exact(
|
fn purge_special_columns_exact(
|
||||||
&self,
|
&self,
|
||||||
batch: &mut WriteBatch,
|
batch: &mut WriteBatch,
|
||||||
|
@ -360,8 +374,9 @@ impl Blockstore {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Purges special columns (using a non-Slot primary-index) by range. Purge occurs if frozen
|
/// Purges special columns (using a non-Slot primary-index) by range. Purge
|
||||||
/// primary index has a max-slot less than the highest slot being purged.
|
/// occurs if frozen primary index has a max-slot less than the highest slot
|
||||||
|
/// being purged.
|
||||||
fn purge_special_columns_with_primary_index(
|
fn purge_special_columns_with_primary_index(
|
||||||
&self,
|
&self,
|
||||||
write_batch: &mut WriteBatch,
|
write_batch: &mut WriteBatch,
|
||||||
|
|
Loading…
Reference in New Issue