Improve logging for connection state errors
This commit is contained in:
parent
a6c1cd3c35
commit
4fe81da953
|
@ -423,7 +423,11 @@ where
|
||||||
State::AwaitingResponse {
|
State::AwaitingResponse {
|
||||||
ref mut handler, ..
|
ref mut handler, ..
|
||||||
} => span.in_scope(|| handler.process_message(peer_msg)),
|
} => span.in_scope(|| handler.process_message(peer_msg)),
|
||||||
_ => unreachable!(),
|
_ => unreachable!("unexpected state after AwaitingResponse: {:?}, peer_msg: {:?}, client_receiver: {:?}",
|
||||||
|
self.state,
|
||||||
|
peer_msg,
|
||||||
|
self.client_rx,
|
||||||
|
),
|
||||||
};
|
};
|
||||||
// If the message was not consumed, check whether it
|
// If the message was not consumed, check whether it
|
||||||
// should be handled as a request.
|
// should be handled as a request.
|
||||||
|
@ -444,7 +448,10 @@ where
|
||||||
State::AwaitingRequest
|
State::AwaitingRequest
|
||||||
}
|
}
|
||||||
pending @ State::AwaitingResponse { .. } => pending,
|
pending @ State::AwaitingResponse { .. } => pending,
|
||||||
_ => unreachable!(),
|
_ => unreachable!(
|
||||||
|
"unexpected failed connection state while AwaitingResponse: client_receiver: {:?}",
|
||||||
|
self.client_rx
|
||||||
|
),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -465,7 +472,10 @@ where
|
||||||
let _ = tx.send(Err(e.into()));
|
let _ = tx.send(Err(e.into()));
|
||||||
State::AwaitingRequest
|
State::AwaitingRequest
|
||||||
}
|
}
|
||||||
_ => unreachable!(),
|
_ => unreachable!(
|
||||||
|
"unexpected failed connection state while AwaitingResponse: client_receiver: {:?}",
|
||||||
|
self.client_rx
|
||||||
|
),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
Either::Right((Either::Right(_), _peer_fut)) => {
|
Either::Right((Either::Right(_), _peer_fut)) => {
|
||||||
|
@ -481,7 +491,7 @@ where
|
||||||
Some(InProgressClientRequest { tx, span, .. }) => {
|
Some(InProgressClientRequest { tx, span, .. }) => {
|
||||||
trace!(
|
trace!(
|
||||||
parent: &span,
|
parent: &span,
|
||||||
"erroring pending request to failed connection"
|
"sending an error response to a pending request on a failed connection"
|
||||||
);
|
);
|
||||||
let e = self
|
let e = self
|
||||||
.error_slot
|
.error_slot
|
||||||
|
@ -504,7 +514,10 @@ where
|
||||||
E: Into<SharedPeerError>,
|
E: Into<SharedPeerError>,
|
||||||
{
|
{
|
||||||
let e = e.into();
|
let e = e.into();
|
||||||
debug!(%e, "failing peer service with error");
|
debug!(%e,
|
||||||
|
connection_state = ?self.state,
|
||||||
|
client_receiver = ?self.client_rx,
|
||||||
|
"failing peer service with error");
|
||||||
// Update the shared error slot
|
// Update the shared error slot
|
||||||
let mut guard = self
|
let mut guard = self
|
||||||
.error_slot
|
.error_slot
|
||||||
|
@ -575,9 +588,17 @@ where
|
||||||
|
|
||||||
// These matches return a Result with (new_state, Option<Sender>) or an (error, Sender)
|
// These matches return a Result with (new_state, Option<Sender>) or an (error, Sender)
|
||||||
let new_state_result = match (&self.state, request) {
|
let new_state_result = match (&self.state, request) {
|
||||||
(Failed, _) => panic!("failed connection cannot handle requests"),
|
(Failed, request) => panic!(
|
||||||
(AwaitingResponse { .. }, _) => panic!("tried to update pending request"),
|
"failed connection cannot handle new request: {:?}, client_receiver: {:?}",
|
||||||
|
request,
|
||||||
|
self.client_rx
|
||||||
|
),
|
||||||
|
(pending @ AwaitingResponse { .. }, request) => panic!(
|
||||||
|
"tried to process new request: {:?} while awaiting a response: {:?}, client_receiver: {:?}",
|
||||||
|
request,
|
||||||
|
pending,
|
||||||
|
self.client_rx
|
||||||
|
),
|
||||||
(AwaitingRequest, Peers) => match self.peer_tx.send(Message::GetAddr).await {
|
(AwaitingRequest, Peers) => match self.peer_tx.send(Message::GetAddr).await {
|
||||||
Ok(()) => Ok((
|
Ok(()) => Ok((
|
||||||
AwaitingResponse {
|
AwaitingResponse {
|
||||||
|
@ -875,7 +896,10 @@ where
|
||||||
self.fail_with(PeerError::Overloaded);
|
self.fail_with(PeerError::Overloaded);
|
||||||
} else {
|
} else {
|
||||||
// We could send a reject to the remote peer.
|
// We could send a reject to the remote peer.
|
||||||
error!(%e);
|
error!(%e,
|
||||||
|
connection_state = ?self.state,
|
||||||
|
client_receiver = ?self.client_rx,
|
||||||
|
"error processing peer request");
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue