-
Notifications
You must be signed in to change notification settings - Fork 443
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start and stop per timeline recovery task.
Slightly refactors init: now load_tenant_timelines is also async to properly init the timeline, but to keep global map lock sync we just acquire it anew for each timeline. Recovery task itself is just a stub here. part of #4875
- Loading branch information
Showing
6 changed files
with
146 additions
and
65 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
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,40 @@ | ||
//! This module implements pulling WAL from peer safekeepers if compute can't | ||
//! provide it, i.e. safekeeper lags too much. | ||
|
||
use std::sync::Arc; | ||
|
||
use tokio::{select, time::sleep, time::Duration}; | ||
use tracing::{info, instrument}; | ||
|
||
use crate::{timeline::Timeline, SafeKeeperConf}; | ||
|
||
/// Entrypoint for per timeline task which always runs, checking whether | ||
/// recovery for this safekeeper is needed and starting it if so. | ||
#[instrument(name = "recovery task", skip_all, fields(ttid = %tli.ttid))] | ||
pub async fn recovery_main(tli: Arc<Timeline>, _conf: SafeKeeperConf) { | ||
info!("started"); | ||
let mut cancellation_rx = match tli.get_cancellation_rx() { | ||
Ok(rx) => rx, | ||
Err(_) => { | ||
info!("timeline canceled during task start"); | ||
return; | ||
} | ||
}; | ||
|
||
select! { | ||
_ = recovery_main_loop(tli) => { unreachable!() } | ||
_ = cancellation_rx.changed() => { | ||
info!("stopped"); | ||
} | ||
} | ||
} | ||
|
||
const CHECK_INTERVAL_MS: u64 = 2000; | ||
|
||
/// Check regularly whether we need to start recovery. | ||
async fn recovery_main_loop(_tli: Arc<Timeline>) { | ||
let check_duration = Duration::from_millis(CHECK_INTERVAL_MS); | ||
loop { | ||
sleep(check_duration).await; | ||
} | ||
} |
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
Oops, something went wrong.