Skip to content

Commit

Permalink
Fix: Keep rpc service running on panic.
Browse files Browse the repository at this point in the history
  • Loading branch information
vldm committed Jan 11, 2022
1 parent 3965d24 commit f03daf3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions core/src/rpc_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,14 +389,14 @@ impl JsonRpcService {
.core_threads(rpc_threads)
.threaded_scheduler()
.enable_all()
.thread_name("sol-rpc-el")
.thread_name("velas-rpc")
.build()
.unwrap()
};

let (close_handle_sender, close_handle_receiver) = channel();
let thread_hdl = Builder::new()
.name("solana-jsonrpc".to_string())
.name("velas-jsonrpc".to_string())
.spawn(move || {
let mut io = MetaIoHandler::default();

Expand Down
11 changes: 8 additions & 3 deletions metrics/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -437,10 +437,12 @@ pub fn set_panic_hook(program: &'static str) {
Some(location) => location.to_string(),
None => "?".to_string(),
};
let ct = thread::current();
let thread_name = ct.name().unwrap_or("?");
submit(
DataPoint::new("panic")
.add_field_str("program", program)
.add_field_str("thread", thread::current().name().unwrap_or("?"))
.add_field_str("thread", thread_name)
// The 'one' field exists to give Kapacitor Alerts a numerical value
// to filter on
.add_field_i64("one", 1)
Expand All @@ -452,8 +454,11 @@ pub fn set_panic_hook(program: &'static str) {
// Flush metrics immediately
flush();

// Exit cleanly so the process don't limp along in a half-dead state
std::process::exit(1);
// Keep only rpc threads to avoid DoS on panic
if thread_name != "velas-rpc" {
// Exit cleanly so the process don't limp along in a half-dead state
std::process::exit(1);
}
}));
});
}
Expand Down

0 comments on commit f03daf3

Please sign in to comment.