mirror of
https://github.com/neondatabase/neon.git
synced 2026-05-14 11:40:38 +00:00
Separate task is launched for each timeline and stopped when timeline doesn't need offloading. Decision who offloads is done through etcd leader election; currently there is no pre condition for participating, that's a TODO. neon_local and tests infrastructure for remote storage in safekeepers added, along with the test itself. ref #1009 Co-authored-by: Anton Shyrabokau <ahtoxa@Antons-MacBook-Pro.local>
26 lines
801 B
Rust
26 lines
801 B
Rust
//! Thread removing old WAL.
|
|
|
|
use std::{thread, time::Duration};
|
|
|
|
use tracing::*;
|
|
|
|
use crate::{timeline::GlobalTimelines, SafeKeeperConf};
|
|
|
|
pub fn thread_main(conf: SafeKeeperConf) {
|
|
let wal_removal_interval = Duration::from_millis(5000);
|
|
loop {
|
|
let active_tlis = GlobalTimelines::get_active_timelines();
|
|
for zttid in &active_tlis {
|
|
if let Ok(tli) = GlobalTimelines::get(&conf, *zttid, false) {
|
|
if let Err(e) = tli.remove_old_wal(conf.wal_backup_enabled) {
|
|
warn!(
|
|
"failed to remove WAL for tenant {} timeline {}: {}",
|
|
tli.zttid.tenant_id, tli.zttid.timeline_id, e
|
|
);
|
|
}
|
|
}
|
|
}
|
|
thread::sleep(wal_removal_interval)
|
|
}
|
|
}
|