move backtrace

This commit is contained in:
Peter Zhang 2024-11-13 16:32:12 +08:00
parent 8c57422be1
commit acd17bcfa7

View File

@ -140,6 +140,9 @@ impl Store {
{ {
let store = self.store.clone(); let store = self.store.clone();
let (tx, rx) = oneshot::channel(); let (tx, rx) = oneshot::channel();
let mut backtrace = Backtrace::new();
let frames = backtrace.frames().to_vec();
backtrace = frames.into();
self.executor.spawn_blocking( self.executor.spawn_blocking(
move || { move || {
@ -147,22 +150,15 @@ impl Store {
let res = f(&*store); let res = f(&*store);
if tx.send(res).is_err() { if tx.send(res).is_err() {
warn!("Backtrace: {:?}", backtrace);
error!("Unable to complete async storage operation: the receiver dropped"); error!("Unable to complete async storage operation: the receiver dropped");
} }
}, },
WORKER_TASK_NAME, WORKER_TASK_NAME,
); );
rx.await.unwrap_or_else(|_| { rx.await
let mut backtrace = Backtrace::new(); .unwrap_or_else(|_| bail!(error::Error::Custom("Receiver error".to_string())))
let mut frames = backtrace.frames().to_vec();
if frames.len() > 3 {
frames.drain(0..); //Remove the first 3 unnecessary frames to simplify// backtrace
backtrace = frames.into();
Some(format!("{:?}", backtrace));
}
bail!(error::Error::Custom("Receiver error".to_string()))
})
} }
// FIXME(zz): Refactor the lock and async call here. // FIXME(zz): Refactor the lock and async call here.