Remove dummy entries in Blockstore special columns (part 2) (#33649)
* Always call initialize_transaction_status_index() at startup, doing so will ensure dummy entries are actually cleaned * Rename initialize_transaction_status_index() * Stop initializing TransactionStatusIndex column entries, these are no longer needed and old software will initialize if needed
This commit is contained in:
parent
0f82662a7f
commit
6009d49cc3
|
@ -325,12 +325,6 @@ impl Blockstore {
|
|||
.unwrap_or(0);
|
||||
let last_root = RwLock::new(max_root);
|
||||
|
||||
// Initialize transaction status index if entries are not present
|
||||
let initialize_transaction_status_index = db
|
||||
.iter::<cf::TransactionStatusIndex>(IteratorMode::Start)?
|
||||
.next()
|
||||
.is_none();
|
||||
|
||||
measure.stop();
|
||||
info!("{:?} {}", blockstore_path, measure);
|
||||
let blockstore = Blockstore {
|
||||
|
@ -364,9 +358,8 @@ impl Blockstore {
|
|||
lowest_cleanup_slot: RwLock::<Slot>::default(),
|
||||
slots_stats: SlotsStats::default(),
|
||||
};
|
||||
if initialize_transaction_status_index {
|
||||
blockstore.initialize_transaction_status_index()?;
|
||||
}
|
||||
blockstore.cleanup_old_entries()?;
|
||||
|
||||
Ok(blockstore)
|
||||
}
|
||||
|
||||
|
@ -2109,16 +2102,10 @@ impl Blockstore {
|
|||
.collect()
|
||||
}
|
||||
|
||||
/// Initializes the TransactionStatusIndex column family with two records, `0` and `1`,
|
||||
/// which are used as the primary index for entries in the TransactionStatus and
|
||||
/// AddressSignatures columns. At any given time, one primary index is active (ie. new records
|
||||
/// are stored under this index), the other is frozen.
|
||||
fn initialize_transaction_status_index(&self) -> Result<()> {
|
||||
self.transaction_status_index_cf
|
||||
.put(0, &TransactionStatusIndexMeta::default())?;
|
||||
self.transaction_status_index_cf
|
||||
.put(1, &TransactionStatusIndexMeta::default())?;
|
||||
|
||||
fn cleanup_old_entries(&self) -> Result<()> {
|
||||
if !self.is_primary_access() {
|
||||
return Ok(());
|
||||
}
|
||||
// If present, delete dummy entries inserted by old software
|
||||
// https://github.com/solana-labs/solana/blob/bc2b372/ledger/src/blockstore.rs#L2130-L2137
|
||||
let transaction_status_dummy_key = cf::TransactionStatus::as_index(2);
|
||||
|
|
|
@ -761,7 +761,7 @@ pub mod tests {
|
|||
.transaction_status_index_cf
|
||||
.get(0)
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
.unwrap_or_default();
|
||||
index0.frozen = true;
|
||||
index0.max_slot = 4;
|
||||
blockstore
|
||||
|
@ -772,7 +772,7 @@ pub mod tests {
|
|||
.transaction_status_index_cf
|
||||
.get(1)
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
.unwrap_or_default();
|
||||
index1.frozen = false;
|
||||
index1.max_slot = 9;
|
||||
blockstore
|
||||
|
|
Loading…
Reference in New Issue