diff options
author | Alex Auvolat <alex@adnab.me> | 2024-03-14 18:21:37 +0100 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2024-03-15 13:51:31 +0100 |
commit | 1e42808a59c35aae297d9dfd1c166c09f0b99347 (patch) | |
tree | ddc935f1ef7f99b0ef9634cbdf911ce03323d1ff /src/model/garage.rs | |
parent | 8dff278b7227007d8a2c2f6c6d6f76c0c5d7a1ac (diff) | |
download | garage-1e42808a59c35aae297d9dfd1c166c09f0b99347.tar.gz garage-1e42808a59c35aae297d9dfd1c166c09f0b99347.zip |
[db-snapshot] implement meta_auto_snapshot_interval
Diffstat (limited to 'src/model/garage.rs')
-rw-r--r-- | src/model/garage.rs | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/model/garage.rs b/src/model/garage.rs index acf943f6..a6f60546 100644 --- a/src/model/garage.rs +++ b/src/model/garage.rs @@ -278,7 +278,7 @@ impl Garage { })) } - pub fn spawn_workers(self: &Arc<Self>, bg: &BackgroundRunner) { + pub fn spawn_workers(self: &Arc<Self>, bg: &BackgroundRunner) -> Result<(), Error> { self.block_manager.spawn_workers(bg); self.bucket_table.spawn_workers(bg); @@ -299,6 +299,23 @@ impl Garage { #[cfg(feature = "k2v")] self.k2v.spawn_workers(bg); + + if let Some(itv) = self.config.metadata_auto_snapshot_interval.as_deref() { + let interval = parse_duration::parse(itv) + .ok_or_message("Invalid `metadata_auto_snapshot_interval`")?; + if interval < std::time::Duration::from_secs(600) { + return Err(Error::Message( + "metadata_auto_snapshot_interval too small or negative".into(), + )); + } + + bg.spawn_worker(crate::snapshot::AutoSnapshotWorker::new( + self.clone(), + interval, + )); + } + + Ok(()) } pub fn bucket_helper(&self) -> helper::bucket::BucketHelper { |