Demote terminate-on-drop to a debug message rather than an error
This commit is contained in:
parent
e501d0f76a
commit
1ff222b291
|
@ -88,7 +88,28 @@ pub type ActorError = Box<dyn std::error::Error + Sync + Send + 'static>;
|
||||||
pub type ActorResult = Result<(), ActorError>;
|
pub type ActorResult = Result<(), ActorError>;
|
||||||
|
|
||||||
/// Final exit status of an actor.
|
/// Final exit status of an actor.
|
||||||
pub type ExitStatus = Result<(), Error>;
|
#[derive(Clone, PartialEq, Eq)]
|
||||||
|
pub enum ExitStatus {
|
||||||
|
Normal,
|
||||||
|
Dropped,
|
||||||
|
Error(Error),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<ExitStatus> for Result<(), Error> {
|
||||||
|
fn from(status: ExitStatus) -> Self {
|
||||||
|
match status {
|
||||||
|
ExitStatus::Normal => Ok(()),
|
||||||
|
ExitStatus::Dropped => Ok(()),
|
||||||
|
ExitStatus::Error(e) => Err(e),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<ExitStatus> for ActorResult {
|
||||||
|
fn from(status: ExitStatus) -> Self {
|
||||||
|
Result::<(), Error>::from(status).map_err(|e| e.into())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// The [`Actor::boot`] method returns an `ActorHandle`, representing
|
/// The [`Actor::boot`] method returns an `ActorHandle`, representing
|
||||||
/// the actor's mainloop task.
|
/// the actor's mainloop task.
|
||||||
|
@ -672,8 +693,12 @@ impl FacetRef {
|
||||||
|
|
||||||
match maybe_exit_status {
|
match maybe_exit_status {
|
||||||
None => true,
|
None => true,
|
||||||
Some(exit_status) => {
|
Some(result) => {
|
||||||
g.terminate(exit_status.map_err(|e| e.into()), &self.actor, &account.trace_collector);
|
let exit_status = match result {
|
||||||
|
Ok(()) => ExitStatus::Normal,
|
||||||
|
Err(e) => ExitStatus::Error(e.into()),
|
||||||
|
};
|
||||||
|
g.terminate(exit_status, &self.actor, &account.trace_collector);
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2006,7 +2031,7 @@ impl ActorRef {
|
||||||
pub fn exit_status(&self) -> Option<ActorResult> {
|
pub fn exit_status(&self) -> Option<ActorResult> {
|
||||||
self.access(|state| match state {
|
self.access(|state| match state {
|
||||||
ActorState::Running(_) => None,
|
ActorState::Running(_) => None,
|
||||||
ActorState::Terminated { exit_status } => Some((**exit_status).clone().map_err(|e| e.into())),
|
ActorState::Terminated { exit_status } => Some((**exit_status).clone().into()),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2074,15 +2099,16 @@ impl ActorState {
|
||||||
}
|
}
|
||||||
|
|
||||||
match &*exit_status {
|
match &*exit_status {
|
||||||
Ok(()) => tracing::trace!(actor_id=?actor.actor_id, "normal stop"),
|
ExitStatus::Normal => tracing::trace!(actor_id=?actor.actor_id, "normal stop"),
|
||||||
Err(e) => tracing::error!(actor_id=?actor.actor_id, %e, "error stop"),
|
ExitStatus::Dropped => tracing::debug!(actor_id=?actor.actor_id, "force-terminated by Actor::drop"),
|
||||||
|
ExitStatus::Error(e) => tracing::error!(actor_id=?actor.actor_id, %e, "error stop"),
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(c) = trace_collector {
|
if let Some(c) = trace_collector {
|
||||||
c.record(actor.actor_id, trace::ActorActivation::Stop {
|
c.record(actor.actor_id, trace::ActorActivation::Stop {
|
||||||
status: Box::new(match &*exit_status {
|
status: Box::new(match &*exit_status {
|
||||||
Ok(()) => trace::ExitStatus::Ok,
|
ExitStatus::Normal | ExitStatus::Dropped => trace::ExitStatus::Ok,
|
||||||
Err(e) => trace::ExitStatus::Error(Box::new(e.clone())),
|
ExitStatus::Error(e) => trace::ExitStatus::Error(Box::new(e.clone())),
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -2155,8 +2181,9 @@ impl RunningActor {
|
||||||
exit_status: Arc<ExitStatus>,
|
exit_status: Arc<ExitStatus>,
|
||||||
trace_collector: Option<trace::TraceCollector>,
|
trace_collector: Option<trace::TraceCollector>,
|
||||||
) {
|
) {
|
||||||
if exit_status.is_ok() {
|
match &*exit_status {
|
||||||
assert!(self.get_facet(self.root).is_none());
|
ExitStatus::Normal => assert!(self.get_facet(self.root).is_none()),
|
||||||
|
ExitStatus::Dropped | ExitStatus::Error(_) => (),
|
||||||
}
|
}
|
||||||
|
|
||||||
let cause = Some(trace::TurnCause::Cleanup);
|
let cause = Some(trace::TurnCause::Cleanup);
|
||||||
|
@ -2218,9 +2245,7 @@ impl Drop for Actor {
|
||||||
// let _scope = tracing::info_span!(parent: None, "actor", actor_id = ?self.ac_ref.actor_id).entered();
|
// let _scope = tracing::info_span!(parent: None, "actor", actor_id = ?self.ac_ref.actor_id).entered();
|
||||||
let mut g = self.ac_ref.state.lock();
|
let mut g = self.ac_ref.state.lock();
|
||||||
if g.is_running() {
|
if g.is_running() {
|
||||||
g.terminate(Err(error("Force-terminated by Actor::drop", AnyValue::new(false))),
|
g.terminate(ExitStatus::Dropped, &self.ac_ref, &self.trace_collector);
|
||||||
&self.ac_ref,
|
|
||||||
&self.trace_collector);
|
|
||||||
}
|
}
|
||||||
tracing::debug!("Actor::drop");
|
tracing::debug!("Actor::drop");
|
||||||
}
|
}
|
||||||
|
|
|
@ -735,7 +735,7 @@ async fn output_loop(
|
||||||
|
|
||||||
impl Entity<()> for TunnelRefEntity {
|
impl Entity<()> for TunnelRefEntity {
|
||||||
fn exit_hook(&mut self, t: &mut Activation, exit_status: &Arc<ExitStatus>) {
|
fn exit_hook(&mut self, t: &mut Activation, exit_status: &Arc<ExitStatus>) {
|
||||||
if let Err(e) = &**exit_status {
|
if let ExitStatus::Error(e) = &**exit_status {
|
||||||
let e = e.clone();
|
let e = e.clone();
|
||||||
let mut g = self.relay_ref.lock();
|
let mut g = self.relay_ref.lock();
|
||||||
let tr = g.as_mut().expect("initialized");
|
let tr = g.as_mut().expect("initialized");
|
||||||
|
|
Loading…
Reference in New Issue