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

ref(actix): Update the Outcome services #1441

Merged
merged 28 commits into from
Sep 7, 2022

Conversation

tobias-wilfert
Copy link
Member

@tobias-wilfert tobias-wilfert commented Aug 31, 2022

General

This PR updates the services contained in outcome.rs namely HttpOutcomeProducer,
ClientReportOutcomeProducer and OutcomeProducer and the OutcomeAggregator
service in outcome_aggregator.rs since it is heavily intertwined with the others.

Design choices

  • The services that had a run_later mechanic now use tokio::time:sleep in combination
    with future::Pending. This allows for the use of tokio::select!inside the main message
    handle loop of the services. Other options of doing this with internal channels were
    considered but deemed undesirable since they are less performant.

Future Steps

  • Two tests are currently failing since our new Registry doesn't return a dummy
    address if the Service isn't created/started. This will need to be addressed by
    either emulating the behaviour of the old Actix Register or by Mocking the
    Services necessary in the Tests. The later approach might require a significant change of
    the Registry we currently have.

#skip-changelog

@jan-auer jan-auer changed the title Updated the HttpOutcomeProducer service ref(actix): Update the HTTP outcome producer service Aug 31, 2022
@tobias-wilfert tobias-wilfert changed the title ref(actix): Update the HTTP outcome producer service ref(actix): Update the Outcome services Sep 2, 2022
@tobias-wilfert tobias-wilfert marked this pull request as ready for review September 2, 2022 14:48
@tobias-wilfert tobias-wilfert requested a review from a team September 2, 2022 14:48
@tobias-wilfert tobias-wilfert mentioned this pull request Sep 5, 2022
30 tasks
relay-server/src/actors/outcome.rs Outdated Show resolved Hide resolved
relay-server/src/actors/outcome.rs Outdated Show resolved Hide resolved
relay-server/src/actors/outcome.rs Outdated Show resolved Hide resolved
relay-server/src/actors/outcome_aggregator.rs Outdated Show resolved Hide resolved
@@ -2276,6 +2276,8 @@ mod tests {
}

#[test]
#[ignore = "The current Register panics if the Addr of an Actor (that is not yet started) is
Copy link
Member

Choose a reason for hiding this comment

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

Leaving a comment here to make this visible. These tests must be fixed in a follow up when Addrs allow to mock services.

let outcome_producer = OutcomeProducer::create(config.clone())?;
let outcome_producer = Arbiter::start(|_| outcome_producer);
registry.set(outcome_producer.clone());
// TODO(tobias): Check if this is good enough or if we want this to have its own tokio runtime?
Copy link
Member

Choose a reason for hiding this comment

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

The Kafka producer used to consume a fair amount of CPU and introduced delays for other services sharing the same runtime in the past. We can benchmark this again at a later point.

For now, let's create a dedicated runtime for the outcome producer. Feel free to add the OutcomeAggregator into that same runtime, though.

Copy link
Contributor

@flub flub left a comment

Choose a reason for hiding this comment

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

This actor doesn't need to handle the shutdown message? I'm a bit surprised by this as I would expect this to try and flush all things on shutdown. But I guess we only have a timeout somewhere and hope things happen in time?

(pressing submit review now on an incomplete review as the refresh button has appeared)

relay-server/src/actors/outcome.rs Outdated Show resolved Hide resolved
relay-server/src/actors/outcome.rs Outdated Show resolved Hide resolved
relay-server/src/actors/outcome.rs Show resolved Hide resolved
relay-server/src/actors/outcome.rs Show resolved Hide resolved
relay-server/src/actors/outcome.rs Outdated Show resolved Hide resolved
match compat::send(UpstreamRelay::from_registry(), SendQuery(request)).await {
Ok(_) => relay_log::trace!("outcome batch sent."),
Err(error) => {
relay_log::error!("outcome batch sending failed with: {}", LogError(&error))
Copy link
Contributor

Choose a reason for hiding this comment

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

Not this PR, but I'm rather surprised to find we just drop the outcomes onto the floor here.

relay-server/src/utils/sleep_handle.rs Show resolved Hide resolved
Copy link
Member

@jan-auer jan-auer left a comment

Choose a reason for hiding this comment

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

Just noticed two more points to solve, therefore retracting my approval:

  1. We're still implementing actix::Message on some messages.
  2. Through your refactor it became apparent that we're swallowing errors when producing outcomes to Kafka. Thank you for uncovering that! We should log this error in the OutcomeProducer, instead.

@tobias-wilfert tobias-wilfert merged commit 1a6544e into master Sep 7, 2022
@tobias-wilfert tobias-wilfert deleted the tobias-wilfert/update-outcome-actor branch September 7, 2022 10:56
@HazAT HazAT added this to the Upgrade Tokio in Relay milestone Nov 21, 2022
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.

4 participants