From b439abca902c381b0f39d29872e7853d58108b7e Mon Sep 17 00:00:00 2001 From: CalvinNeo Date: Mon, 22 Jul 2024 23:58:04 +0800 Subject: [PATCH] a Signed-off-by: CalvinNeo --- .../src/status_server/vendored_utils.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/proxy_components/proxy_server/src/status_server/vendored_utils.rs b/proxy_components/proxy_server/src/status_server/vendored_utils.rs index 4c2586f65ff..1e61c7e7de8 100644 --- a/proxy_components/proxy_server/src/status_server/vendored_utils.rs +++ b/proxy_components/proxy_server/src/status_server/vendored_utils.rs @@ -85,13 +85,27 @@ pub fn adhoc_dump(path: &str) -> tikv_alloc::error::ProfResult<()> { let mut bytes = std::ffi::CString::new(path)?.into_bytes_with_nul(); let mut ptr = bytes.as_mut_ptr() as *mut ::std::os::raw::c_char; let len = std::mem::size_of_val(&ptr) as u64; - issue_mallctl_args( + let r = issue_mallctl_args( "prof.dump", std::ptr::null_mut(), std::ptr::null_mut(), &mut ptr as *mut _ as *mut _, len, ); + if r != 0 { + unsafe { + let err = *libc::__errno_location(); + let err_msg = libc::strerror(err); + let c_str = std::ffi::CStr::from_ptr(err_msg); + let str_slice = c_str.to_str().unwrap_or("Unknown error"); + tikv_util::warn!( + "adhoc_dump returns non-zero {} error_code: {} error_message: {}", + r, + err, + str_slice + ); + } + } } Ok(()) }