Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(read_handler): log when max hearbeat missed #151

Merged
merged 5 commits into from
Oct 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions amqprs/src/net/reader_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@

/////////////////////////////////////////////////////////////////////////////

const MAX_HEARTBEAT_MISS: u64 = 3;
/// After two missed heartbeats, the peer is considered to be unreachable according to [spec](https://www.rabbitmq.com/docs/heartbeats#heartbeats-interval)
const MAX_HEARTBEAT_MISS: u64 = 2;
RoloEdits marked this conversation as resolved.
Show resolved Hide resolved

pub(crate) struct ReaderHandler {
stream: BufIoReader,
Expand Down Expand Up @@ -261,7 +262,7 @@
match res {
Ok((channel_id, frame)) => {
if let Err(err) = self.handle_frame(channel_id, frame).await {
// notifiy network failure
// notify network failure
is_network_failure = true;
#[cfg(feature="traces")]
error!("socket will be closed due to error of handling frame, cause: {}", err);
Expand All @@ -275,7 +276,7 @@
}
},
Err(err) => {
// notifiy network failure
// notify network failure

Check warning on line 279 in amqprs/src/net/reader_handler.rs

View check run for this annotation

Codecov / codecov/patch

amqprs/src/net/reader_handler.rs#L279

Added line #L279 was not covered by tests
is_network_failure = true;
#[cfg(feature="traces")]
error!("socket will be closed due to failure of reading frame, cause: {}", err);
Expand All @@ -291,9 +292,11 @@

// should call self.io_failure_notify.notify_one();?
#[cfg(feature="traces")]
error!("missing heartbeat from server for {}", self.amqp_connection);
warn!("missing heartbeat from server for {}: {heartbeat_miss}/{MAX_HEARTBEAT_MISS}", self.amqp_connection);

Check warning on line 295 in amqprs/src/net/reader_handler.rs

View check run for this annotation

Codecov / codecov/patch

amqprs/src/net/reader_handler.rs#L295

Added line #L295 was not covered by tests
heartbeat_miss += 1;
if heartbeat_miss >= MAX_HEARTBEAT_MISS {
#[cfg(feature="traces")]
error!("heartbeat was missed `{heartbeat_miss}` times in a row, closing connection");

Check warning on line 299 in amqprs/src/net/reader_handler.rs

View check run for this annotation

Codecov / codecov/patch

amqprs/src/net/reader_handler.rs#L299

Added line #L299 was not covered by tests
// Shutdown connection due to heartbeat timeout
is_network_failure = true;
break;
Expand Down
Loading