Skip to content

Commit d0a8ddd

Browse files
committed
Log reason of lost worker on info level
1 parent fe25de8 commit d0a8ddd

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

crates/tako/src/gateway.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use serde::{Deserialize, Serialize, Serializer};
2+
use std::fmt::Display;
23

34
use crate::internal::common::error::DsError;
45
use crate::internal::messages::common::TaskFailInfo;
@@ -303,6 +304,18 @@ impl LostWorkerReason {
303304
}
304305
}
305306

307+
impl Display for LostWorkerReason {
308+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
309+
f.write_str(match self {
310+
LostWorkerReason::Stopped => "stopped",
311+
LostWorkerReason::ConnectionLost => "connection lost",
312+
LostWorkerReason::HeartbeatLost => "heartbeat lost",
313+
LostWorkerReason::IdleTimeout => "idle timeout",
314+
LostWorkerReason::TimeLimitReached => "time limit reached",
315+
})
316+
}
317+
}
318+
306319
#[derive(Serialize, Deserialize, Debug)]
307320
pub struct LostWorkerMessage {
308321
pub worker_id: WorkerId,

crates/tako/src/internal/server/rpc.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,10 @@ async fn worker_rpc_loop(
230230
};
231231

232232
log::info!(
233-
"Worker {} connection closed (connection: {})",
233+
"Worker {} ({}) connection closed: {}",
234234
worker_id,
235-
connection.address
235+
connection.address,
236+
reason
236237
);
237238
let mut core = core_ref.get_mut();
238239
let mut comm = comm_ref.get_mut();

0 commit comments

Comments
 (0)