Skip to content

Conversation

dnwiebe
Copy link
Collaborator

@dnwiebe dnwiebe commented Aug 15, 2025

No description provided.

@dnwiebe dnwiebe changed the title Are Chunked Responses Being Handled Wrong? GH-818 Are Chunked Responses Being Handled Wrong? Aug 15, 2025
use tokio::prelude::Future;

pub const CRASH_KEY: &str = "PROXYSERVER";
pub const RETURN_ROUTE_TTL: Duration = Duration::from_secs(120);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now there are two TtlHashMaps, so we need two TTLs.

.get(&msg.stream_key)
.unwrap_or_else(|| {
panic!("AddRouteResultMessage Handler: stream key: {} not found within dns_failure_retries", msg.stream_key);
});
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Took out the panic, replaced it with an error log. This panic doesn't happen because of something that arrives from outside, but it does happen because of something that doesn't arrive from outside; that should be against The Rule as well.

let return_route_id = match self.rri_from_remaining_route(&msg.remaining_route) {
Some(rri) => rri,
None => return, // TODO: Eventually we'll have to do something better here, but we'll probably need some heuristics.
};
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get_return_route_info() has been modified to accept only the return_route_id (a u32) rather than the whole Route; so here we're pulling the return_route_id out of the Route we have.

}
}

fn get_return_route_info(
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is hard to read, but I split the original get_return_route_info() into two:

rri_from_remaining_route() that pulls the ID out of the Route
get_return_route_info() (accepting an ID, not a whole Route) to traverse the TtlHashMaps

source: &str,
) -> Option<Rc<AddReturnRouteMessage>> {
match self.route_ids_to_return_routes_first_chance.remove(&return_route_id) {
Some(rri) => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no use case in which we leave a matching RRI in the _first_chance map. If we find it, we'll transfer it over to the _stragglers map, where it is subject to a much shorter TTL and will probably expire and be killed unless it's part of a stream.

self.route_ids_to_return_routes_stragglers.insert(return_route_id, (*rri).clone());
Some(rri)
},
None => match self.route_ids_to_return_routes_stragglers.get(&return_route_id) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we don't find matching RRI in the _first_chance map, we immediately look in the _stragglers map.

self
}
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The following tests address get_return_route_info() directly (white-box tests) and make sure it operates as intended.

#[test]
#[should_panic(
expected = "AddRouteResultMessage Handler: stream key: AAAAAAAAAAAAAAAAAAAAAAAAAAA not found within dns_failure_retries"
)]
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Converted panic to error log

let stream_key = StreamKey::make_meaningful_stream_key(test_name);
subject
.keys_and_addrs
.insert(stream_key.clone(), socket_addr.clone());
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rest of this file is just renames.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants