Skip to content
This repository has been archived by the owner on Oct 18, 2023. It is now read-only.

primary idle shutdown #242

Merged
merged 5 commits into from
Feb 22, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
remove SHUTDOWN global
  • Loading branch information
MarinPostma committed Feb 22, 2023
commit 886d92b83ea0e03ca613ccc1f8431b8a4d8bf61f
8 changes: 3 additions & 5 deletions sqld/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ type Result<T> = std::result::Result<T, Error>;
///
/// /!\ use with caution.
pub(crate) static HARD_RESET: Lazy<Arc<Notify>> = Lazy::new(|| Arc::new(Notify::new()));
/// Clean shutdown of the server.
pub(crate) static SHUTDOWN: Lazy<Arc<Notify>> = Lazy::new(|| Arc::new(Notify::new()));

#[cfg(feature = "mwal_backend")]
pub(crate) static VWAL_METHODS: OnceCell<
Expand Down Expand Up @@ -239,9 +237,10 @@ pub async fn run_server(config: Config) -> anyhow::Result<()> {
}
let mut join_set = JoinSet::new();

let shutdown_notify: Arc<Notify> = Arc::new(Notify::new());
let idle_shutdown_layer = config
.idle_shutdown_timeout
.map(|d| IdleShutdownLayer::new(d, SHUTDOWN.clone()));
.map(|d| IdleShutdownLayer::new(d, shutdown_notify.clone()));

match config.writer_rpc_addr {
Some(ref addr) => {
Expand All @@ -251,14 +250,13 @@ pub async fn run_server(config: Config) -> anyhow::Result<()> {
}

let reset = HARD_RESET.clone();
let shutdown = SHUTDOWN.clone();
loop {
tokio::select! {
_ = reset.notified() => {
hard_reset(&config, join_set).await?;
break;
},
_ = shutdown.notified() => {
_ = shutdown_notify.notified() => {
return Ok(())
}
Some(res) = join_set.join_next() => {
Expand Down
1 change: 1 addition & 0 deletions sqld/src/rpc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use crate::utils::services::idle_shutdown::IdleShutdownLayer;
pub mod proxy;
pub mod replication_log;

#[allow(clippy::too_many_arguments)]
pub async fn run_rpc_server(
addr: SocketAddr,
tls: bool,
Expand Down