solana-validator exit now uses process::exit() to ensure prompt termination (#17107)

(cherry picked from commit ec2b06d81d)

Co-authored-by: Michael Vines <mvines@gmail.com>
This commit is contained in:
mergify[bot]
2021-05-07 18:49:36 +00:00
committed by GitHub
parent dc95663de7
commit 072e884c24

View File

@ -11,8 +11,8 @@ use {
net::SocketAddr,
path::Path,
sync::{Arc, RwLock},
thread::Builder,
time::SystemTime,
thread::{self, Builder},
time::{Duration, SystemTime},
},
};
@ -58,10 +58,22 @@ impl AdminRpc for AdminRpcImpl {
fn exit(&self, meta: Self::Metadata) -> Result<()> {
debug!("exit admin rpc request received");
thread::spawn(move || {
// Delay exit signal until this RPC request completes, otherwise the caller of `exit` might
// receive a confusing error as the validator shuts down before a response is sent back.
tokio::spawn(async move {
thread::sleep(Duration::from_millis(100));
warn!("validator exit requested");
meta.validator_exit.write().unwrap().exit();
// TODO: Debug why ValidatorExit doesn't always cause the validator to fully exit
// (rocksdb background processing or some other stuck thread perhaps?).
//
// If the process is still alive after five seconds, exit harder
thread::sleep(Duration::from_secs(5));
warn!("validator exit timeout");
std::process::exit(0);
});
Ok(())
}