-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow manual wal pruning via CLI (#349)
- Loading branch information
Showing
5 changed files
with
68 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
use miette::{bail, Context, IntoDiagnostic}; | ||
use tracing::info; | ||
|
||
#[derive(Debug, clap::Args)] | ||
pub struct Args { | ||
/// the maximum number of slots to keep in the WAL | ||
#[arg(long)] | ||
max_slots: Option<u64>, | ||
|
||
/// the maximum number of slots to prune in a single operation | ||
#[arg(long)] | ||
max_prune: Option<u64>, | ||
} | ||
|
||
pub fn run(config: &crate::Config, args: &Args) -> miette::Result<()> { | ||
crate::common::setup_tracing(&config.logging)?; | ||
|
||
let (mut wal, _) = crate::common::open_data_stores(config).context("opening data stores")?; | ||
|
||
let max_slots = match args.max_slots { | ||
Some(x) => x, | ||
None => match config.storage.max_wal_history { | ||
Some(x) => x, | ||
None => bail!("neither args or config provided for max_slots"), | ||
}, | ||
}; | ||
|
||
info!(max_slots, "prunning to max slots"); | ||
|
||
wal.prune_history(max_slots, args.max_prune) | ||
.into_diagnostic() | ||
.context("removing range from WAL")?; | ||
|
||
let db = wal.db_mut().unwrap(); | ||
|
||
while db.compact().into_diagnostic()? { | ||
info!("wal compaction round"); | ||
} | ||
|
||
info!("wal segment trimmed"); | ||
|
||
Ok(()) | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters