Exclude stubbed ProgramCosts column from compaction (#18840)
This commit is contained in:
@ -22,7 +22,7 @@ use solana_sdk::{
|
|||||||
};
|
};
|
||||||
use solana_storage_proto::convert::generated;
|
use solana_storage_proto::convert::generated;
|
||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
collections::{HashMap, HashSet},
|
||||||
ffi::{CStr, CString},
|
ffi::{CStr, CString},
|
||||||
fs,
|
fs,
|
||||||
marker::PhantomData,
|
marker::PhantomData,
|
||||||
@ -421,9 +421,9 @@ impl Rocks {
|
|||||||
// this is only needed for LedgerCleanupService. so guard with PrimaryOnly (i.e. running solana-validator)
|
// this is only needed for LedgerCleanupService. so guard with PrimaryOnly (i.e. running solana-validator)
|
||||||
if matches!(access_type, AccessType::PrimaryOnly) {
|
if matches!(access_type, AccessType::PrimaryOnly) {
|
||||||
for cf_name in cf_names {
|
for cf_name in cf_names {
|
||||||
// this special column family must be excluded from LedgerCleanupService's rocksdb
|
// these special column families must be excluded from LedgerCleanupService's rocksdb
|
||||||
// compactions
|
// compactions
|
||||||
if cf_name == TransactionStatusIndex::NAME {
|
if excludes_from_compaction(cf_name) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1319,9 +1319,7 @@ fn get_cf_options<C: 'static + Column + ColumnName>(
|
|||||||
|
|
||||||
// TransactionStatusIndex must be excluded from LedgerCleanupService's rocksdb
|
// TransactionStatusIndex must be excluded from LedgerCleanupService's rocksdb
|
||||||
// compactions....
|
// compactions....
|
||||||
if matches!(access_type, AccessType::PrimaryOnly)
|
if matches!(access_type, AccessType::PrimaryOnly) && !excludes_from_compaction(C::NAME) {
|
||||||
&& C::NAME != columns::TransactionStatusIndex::NAME
|
|
||||||
{
|
|
||||||
options.set_compaction_filter_factory(PurgedSlotFilterFactory::<C> {
|
options.set_compaction_filter_factory(PurgedSlotFilterFactory::<C> {
|
||||||
oldest_slot: oldest_slot.clone(),
|
oldest_slot: oldest_slot.clone(),
|
||||||
name: CString::new(format!("purged_slot_filter_factory({})", C::NAME)).unwrap(),
|
name: CString::new(format!("purged_slot_filter_factory({})", C::NAME)).unwrap(),
|
||||||
@ -1361,6 +1359,18 @@ fn get_db_options(access_type: &AccessType) -> Options {
|
|||||||
options
|
options
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn excludes_from_compaction(cf_name: &str) -> bool {
|
||||||
|
// list of Column Families must be excluded from compaction:
|
||||||
|
let no_compaction_cfs: HashSet<&'static str> = vec![
|
||||||
|
columns::TransactionStatusIndex::NAME,
|
||||||
|
columns::ProgramCosts::NAME,
|
||||||
|
]
|
||||||
|
.into_iter()
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
no_compaction_cfs.get(cf_name).is_some()
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
pub mod tests {
|
pub mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
@ -1413,4 +1423,14 @@ pub mod tests {
|
|||||||
CompactionDecision::Keep
|
CompactionDecision::Keep
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_excludes_from_compaction() {
|
||||||
|
// currently there are two CFs are excluded from compaction:
|
||||||
|
assert!(excludes_from_compaction(
|
||||||
|
columns::TransactionStatusIndex::NAME
|
||||||
|
));
|
||||||
|
assert!(excludes_from_compaction(columns::ProgramCosts::NAME));
|
||||||
|
assert!(!excludes_from_compaction("something else"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user