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

Return connection errors from the heartbeat task to the Client #4733

Closed
Tracked by #3263
teor2345 opened this issue Jul 4, 2022 · 1 comment · Fixed by #4756
Closed
Tracked by #3263

Return connection errors from the heartbeat task to the Client #4733

teor2345 opened this issue Jul 4, 2022 · 1 comment · Fixed by #4756
Assignees
Labels
A-network Area: Network protocol updates or fixes C-security Category: Security issues I-panic Zebra panics with an internal error message

Comments

@teor2345
Copy link
Contributor

teor2345 commented Jul 4, 2022

Motivation

We're seeing "failed servers must set their error slot" panics when Zebra is overloaded.

This panic is caused by the design of the Client connection code. Currently, the Client tasks share an ErrorSlot mutex, which must be updated before they exit.

This ticket stops using the error slot in the heartbeat task.

Designs

Instead of using the error slot, Client tasks should exit and return an error to the client instance.
The Client should exit when any task errors or stops.

We could try something like this:
(click for details)

Replace Client.error_slot with returning a PeerError:

  • end the task when there is a permanent connection error, returning `Result<(), PeerError>’
  • check the error via the JoinHandle in the Client
  • shut down the Client when the heartbeat task exits or errors

Related Work

This is part of:

@teor2345 teor2345 added S-needs-triage Status: A bug report needs triage P-Medium ⚡ C-security Category: Security issues I-panic Zebra panics with an internal error message A-network Area: Network protocol updates or fixes labels Jul 4, 2022
@oxarbitrage oxarbitrage self-assigned this Jul 6, 2022
@teor2345
Copy link
Contributor Author

teor2345 commented Jul 6, 2022

Here's the code we need to return an error from:

/// Send periodical heartbeats to `server_tx`, and update the peer status through
/// `heartbeat_ts_collector`.
///
/// # Correctness
///
/// To prevent hangs:
/// - every await that depends on the network must have a timeout (or interval)
/// - every error/shutdown must update the address book state and return
///
/// The address book state can be updated via `ClientRequest.tx`, or the
/// heartbeat_ts_collector.
///
/// Returning from this function terminates the connection's heartbeat task.
async fn send_periodic_heartbeats_with_shutdown_handle(
connected_addr: ConnectedAddr,
remote_services: PeerServices,
shutdown_rx: oneshot::Receiver<CancelHeartbeatTask>,
server_tx: futures::channel::mpsc::Sender<ClientRequest>,
mut heartbeat_ts_collector: tokio::sync::mpsc::Sender<MetaAddrChange>,
) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-network Area: Network protocol updates or fixes C-security Category: Security issues I-panic Zebra panics with an internal error message
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants