debug(session): 添加 handle_message 和 session 恢复的 tracing 日志
用于排查 restart 后 session 恢复和 TTL 刷新问题。
This commit is contained in:
parent
dcb2d552d9
commit
e1681e0424
@ -206,6 +206,7 @@ impl Session {
|
||||
|
||||
// Sync message_count to Storage
|
||||
if persist {
|
||||
tracing::debug!(session_id = %self.id, last_active_at = %now, message_count = %self.message_count, "Persisting session meta after add_message");
|
||||
if let Err(e) = self.persist_session_meta().await {
|
||||
tracing::warn!("failed to persist session meta: {}", e);
|
||||
}
|
||||
@ -891,6 +892,7 @@ impl SessionManager {
|
||||
// Try to restore from Storage
|
||||
match self.storage.get_session(&session_id_str).await {
|
||||
Ok(meta) => {
|
||||
tracing::debug!(session_id = %session_id_str, last_active_at = %meta.last_active_at, message_count = %meta.message_count, "Restoring session from Storage");
|
||||
let (user_tx, _rx) = mpsc::channel::<WsOutbound>(100);
|
||||
let session = Session::from_storage(
|
||||
unified_id.clone(),
|
||||
@ -1070,11 +1072,14 @@ impl SessionManager {
|
||||
} else {
|
||||
// No current session tracked, find active or create new
|
||||
let ttl_millis = self.inner.lock().await.session_ttl.as_millis() as i64;
|
||||
tracing::debug!(channel, chat_id, ttl_millis, "No current_sessions entry, searching Storage for active session");
|
||||
match self.storage.find_active_session(channel, chat_id, ttl_millis).await {
|
||||
Ok(Some(meta)) => {
|
||||
tracing::debug!(session_id = %meta.id, dialog_id = %meta.dialog_id, last_active_at = %meta.last_active_at, "Found active session in Storage");
|
||||
UnifiedSessionId::new(channel, chat_id, &meta.dialog_id)
|
||||
}
|
||||
Ok(None) | Err(_) => {
|
||||
tracing::debug!("No active session found in Storage, creating new session");
|
||||
// Create new session
|
||||
let (new_id, _) = self.create_session(channel, chat_id, None, String::new()).await?;
|
||||
new_id
|
||||
@ -1082,6 +1087,7 @@ impl SessionManager {
|
||||
}
|
||||
}
|
||||
};
|
||||
tracing::debug!(unified_id = %unified_id, "handle_message resolved unified_id");
|
||||
let session = self.get_or_create_session(&unified_id).await?;
|
||||
|
||||
// Check for slash command
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user