20260605 移除audit rule index和DB trace

This commit is contained in:
2026-06-05 16:02:25 +08:00
parent 9579f65501
commit e597c7c124
29 changed files with 4032 additions and 2298 deletions

View File

@@ -5,7 +5,6 @@ pub const CF_RAW_BY_HASH: &str = "raw_by_hash";
pub const CF_RAW_BLOB: &str = "raw_blob";
pub const CF_VCIR: &str = "vcir";
pub const CF_MANIFEST_REPLAY_META: &str = "manifest_replay_meta";
pub const CF_AUDIT_RULE_INDEX: &str = "audit_rule_index";
pub const CF_RRDP_SOURCE: &str = "rrdp_source";
pub const CF_RRDP_SOURCE_MEMBER: &str = "rrdp_source_member";
pub const CF_RRDP_URI_OWNER: &str = "rrdp_uri_owner";
@@ -16,7 +15,6 @@ pub const ALL_COLUMN_FAMILY_NAMES: &[&str] = &[
CF_RAW_BLOB,
CF_VCIR,
CF_MANIFEST_REPLAY_META,
CF_AUDIT_RULE_INDEX,
CF_RRDP_SOURCE,
CF_RRDP_SOURCE_MEMBER,
CF_RRDP_URI_OWNER,
@@ -27,14 +25,12 @@ pub(super) const RAW_BY_HASH_KEY_PREFIX: &str = "rawbyhash:";
pub(super) const RAW_BLOB_KEY_PREFIX: &str = "rawblob:";
pub(super) const VCIR_KEY_PREFIX: &str = "vcir:";
pub(super) const MANIFEST_REPLAY_META_KEY_PREFIX: &str = "manifest_replay_meta:";
pub(super) const AUDIT_ROA_RULE_KEY_PREFIX: &str = "audit:roa_rule:";
pub(super) const AUDIT_ASPA_RULE_KEY_PREFIX: &str = "audit:aspa_rule:";
pub(super) const AUDIT_ROUTER_KEY_RULE_KEY_PREFIX: &str = "audit:router_key_rule:";
pub(super) const RRDP_SOURCE_KEY_PREFIX: &str = "rrdp_source:";
pub(super) const RRDP_SOURCE_MEMBER_KEY_PREFIX: &str = "rrdp_source_member:";
pub(super) const RRDP_URI_OWNER_KEY_PREFIX: &str = "rrdp_uri_owner:";
const WORK_DB_BLOB_MODE_ENV: &str = "RPKI_WORK_DB_BLOB_MODE";
const WORK_DB_MEMORY_PROFILE_ENV: &str = "RPKI_WORK_DB_MEMORY_PROFILE";
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub(super) enum WorkDbBlobMode {
@@ -43,6 +39,12 @@ pub(super) enum WorkDbBlobMode {
Lz4,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub(super) enum WorkDbMemoryProfile {
Default,
Compact,
}
pub(super) fn parse_work_db_blob_mode(raw: &str) -> Option<WorkDbBlobMode> {
match raw.trim().to_ascii_lowercase().as_str() {
"" | "default" => Some(default_work_db_blob_mode()),
@@ -74,8 +76,36 @@ pub(super) fn work_db_blob_mode_from_env() -> WorkDbBlobMode {
}
}
pub(super) fn configure_work_db_options(opts: &mut Options, blob_mode: WorkDbBlobMode) {
pub(super) fn parse_work_db_memory_profile(raw: &str) -> Option<WorkDbMemoryProfile> {
match raw.trim().to_ascii_lowercase().as_str() {
"" | "default" | "off" | "none" => Some(WorkDbMemoryProfile::Default),
"compact" | "low" | "low_memory" | "low-memory" => Some(WorkDbMemoryProfile::Compact),
_ => None,
}
}
pub(super) fn work_db_memory_profile_from_env() -> WorkDbMemoryProfile {
let Ok(raw) = std::env::var(WORK_DB_MEMORY_PROFILE_ENV) else {
return WorkDbMemoryProfile::Default;
};
match parse_work_db_memory_profile(&raw) {
Some(profile) => profile,
None => {
eprintln!(
"warning: unsupported {WORK_DB_MEMORY_PROFILE_ENV}={raw:?}; using default work-db memory profile"
);
WorkDbMemoryProfile::Default
}
}
}
pub(super) fn configure_work_db_options(
opts: &mut Options,
blob_mode: WorkDbBlobMode,
memory_profile: WorkDbMemoryProfile,
) {
opts.set_compression_type(DBCompressionType::Lz4);
apply_work_db_memory_profile(opts, memory_profile);
match blob_mode {
WorkDbBlobMode::Current => enable_blobdb_current(opts),
WorkDbBlobMode::Disabled => {}
@@ -86,9 +116,9 @@ pub(super) fn configure_work_db_options(opts: &mut Options, blob_mode: WorkDbBlo
}
}
pub(super) fn cf_opts(blob_mode: WorkDbBlobMode) -> Options {
pub(super) fn cf_opts(blob_mode: WorkDbBlobMode, memory_profile: WorkDbMemoryProfile) -> Options {
let mut opts = Options::default();
configure_work_db_options(&mut opts, blob_mode);
configure_work_db_options(&mut opts, blob_mode, memory_profile);
opts
}
@@ -99,12 +129,23 @@ pub fn column_family_descriptors() -> Vec<ColumnFamilyDescriptor> {
pub(super) fn column_family_descriptors_for_blob_mode(
blob_mode: WorkDbBlobMode,
) -> Vec<ColumnFamilyDescriptor> {
let memory_profile = work_db_memory_profile_from_env();
ALL_COLUMN_FAMILY_NAMES
.iter()
.map(|name| ColumnFamilyDescriptor::new(*name, cf_opts(blob_mode)))
.map(|name| ColumnFamilyDescriptor::new(*name, cf_opts(blob_mode, memory_profile)))
.collect()
}
fn apply_work_db_memory_profile(opts: &mut Options, memory_profile: WorkDbMemoryProfile) {
match memory_profile {
WorkDbMemoryProfile::Default => {}
WorkDbMemoryProfile::Compact => {
opts.set_write_buffer_size(16 * 1024 * 1024);
opts.set_max_write_buffer_number(1);
}
}
}
pub(super) fn enable_blobdb_current(opts: &mut Options) {
#[allow(unused_mut)]
let mut _enabled = false;