Cluster: the `Terminated` answers to a refreshed watch pile up on a lane which cannot connect

Open Beginner friendly
#590 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
84/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
rust

Research direction

Start with tellus/src/cluster/watch.rs, especially on_watch, answer_terminated, and the neighboring a_watch_on_an_unknown_target_is_answered test. Compare the disconnected-lane checks in tellus/src/cluster/endpoint.rs for watch refresh, reachability, and gossip. Run the focused cluster watch test; done means repeated watches on a lane that never connected leave only one queued Terminated frame.

Written by the indexing model from the issue text.

Description

bug

A node answers a Watch frame for an actor it does not know with a Terminated frame and drops the watch. The watching node re-sends every remote watch each watch_refresh_interval (2 s by default), so until an answer arrives, every refresh is answered with one more frame. That frame is queued on the lane toward the watching node without a check whether the lane is connected, and as a system frame it bypasses outbound_capacity. On a one-way broken link, where this node cannot dial the watching node but still receives its frames, none of these frames leaves the queue. Each stale watch then adds a frame every 2 s for as long as the link stays broken, which docs/cluster.md 1391 to 1394 leaves to an operator. Point 2 of #268 is the cost of the refreshed Watch frames themselves, not of these answers.

docs/cluster.md 377 to 379, in the Gossip section: "A member with a currently disconnected lane is skipped. The skip is keyed on transport connectivity, never on suspicion. The uncounted system-frame queues hence stay bounded while a member is retried". The code states the same intent for two other senders of uncounted frames, watch_refresh_loop (endpoint.rs 2598 to 2599): "like gossip it skips a disconnected lane, whose uncounted queues would otherwise grow", and push_reachability (1562): "Skips a disconnected lane, whose uncounted queues would otherwise grow."

A test for the tests of tellus/src/cluster/watch.rs, next to a_watch_on_an_unknown_target_is_answered. It calls on_watch 100 times for one watch, as the reader does for each Watch frame (peer.rs 1509). In the test endpoint no lane ever connects, the state of a lane whose dials fail:

    /// A lane toward the watching peer which never connected holds one `Terminated` frame for a
    /// watch on an unknown target, however often the watch is refreshed.
    #[tokio::test]
    async fn a_lane_which_never_connected_holds_one_answer_to_a_refreshed_watch() {
        let (endpoint, mut lane_dials, _join_requests) = EndpointInner::for_tests(
            EndpointConfig::new("127.0.0.1:1".parse().expect("valid address")),
        );
        let peer = peer();
        endpoint.update(|membership, _| membership.add_up(peer));
        let (target, watcher_id) = (ActorId::new(), ActorId::new());

        for _ in 0..100 {
            on_watch(endpoint, peer, target, watcher_id);
        }

        let mut lane = lane_dials.try_recv().expect("the watching peer is dialed");
        assert_eq!(
            lane.control_rx.try_iter().count(),
            1,
            "Terminated frames queued after 100 refreshes"
        );
    }

cargo test -p tellus --features cluster --lib a_lane_which_never_connected fails in 10 of 10 runs on 392a3bf:

thread 'cluster::watch::tests::a_lane_which_never_connected_holds_one_answer_to_a_refreshed_watch' (18211492) panicked at tellus/src/cluster/watch.rs:611:9:
assertion `left == right` failed: Terminated frames queued after 100 refreshes
  left: 100
 right: 1
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 585 filtered out; finished in 0.00s

on_watch takes the wire watch of an unknown or terminated target and passes it to answer_terminated (watch.rs 330 to 333), which sends one frame per watcher with endpoint.send and checks no lane (467 to 490). The skips the comments name are in watch_refresh_loop (endpoint.rs 2610 to 2615), in push_reachability (1569 to 1571) and in the gossip tick, as LaneFilter::NotDisconnected (1194). ReplyDropped frames are queued without a lane check too: one per reply tag of a message or reply which cannot be delivered (reply::on_undeliverable, reply.rs 596 to 607) and one per reply destination dropped unanswered (ReplyGuard, 730 to 755). These grow only with the requests the peer sends, and no refresh sends them again.

Suggestion: skip a disconnected lane when answering a Watch frame, as the refresh, the reachability push and gossip do. The watching node keeps refreshing, so the first refresh after the lane has connected is answered. That answer still queues behind every message queued toward the watcher before it, so a terminated signal stays behind the messages.

Dominant language
Rust
Stars
37
Forks
1
Avg merge
4h 56m
Merged PRs (30d)
219

Getting set up

  • Ships a Dockerfile or Docker Compose file
  • No pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from tellus-rs/tellus

All issues in tellus-rs/tellus

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.