mirror of
https://github.com/neondatabase/neon.git
synced 2026-06-04 22:10:39 +00:00
utils: add ?force=true hint for CPU profiler (#10368)
This makes it less annoying to try to take a CPU profile when a continuous profile is already running.
This commit is contained in:
@@ -372,7 +372,11 @@ pub async fn profile_cpu_handler(req: Request<Body>) -> Result<Response<Body>, A
|
||||
match PROFILE_LOCK.try_lock() {
|
||||
Ok(lock) => break lock,
|
||||
Err(_) if force => PROFILE_CANCEL.notify_waiters(),
|
||||
Err(_) => return Err(ApiError::Conflict("profiler already running".into())),
|
||||
Err(_) => {
|
||||
return Err(ApiError::Conflict(
|
||||
"profiler already running (use ?force=true to cancel it)".into(),
|
||||
))
|
||||
}
|
||||
}
|
||||
tokio::time::sleep(Duration::from_millis(1)).await; // don't busy-wait
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user