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

Fix experimental_retry #6338

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from
Open

Fix experimental_retry #6338

wants to merge 4 commits into from

Conversation

bnjjj
Copy link
Contributor

@bnjjj bnjjj commented Nov 26, 2024

Fix the behavior of experimental_retry and make sure both the feature and metrics are working.
An entry in the context was also added, which would be useful later to implement a new standard attribute and selector for advanced telemetry.


Checklist

Complete the checklist (and note appropriate exceptions) before the PR is marked ready-for-review.

  • Changes are compatible1
  • Documentation2 completed
  • Performance impact assessed and acceptable
  • Tests added and passing3
    • Unit Tests
    • Integration Tests
    • Manual Tests

Exceptions

Note any exceptions here

Notes

Footnotes

  1. It may be appropriate to bring upcoming changes to the attention of other (impacted) groups. Please endeavour to do this before seeking PR approval. The mechanism for doing this will vary considerably, so use your judgement as to how and when to do this.

  2. Configuration is an important part of many changes. Where applicable please try to document configuration examples.

  3. Tick whichever testing boxes are applicable. If you are adding Manual Tests, please document the manual testing (extensively) in the Exceptions.

Signed-off-by: Benjamin <5719034+bnjjj@users.noreply.github.com>
Signed-off-by: Benjamin <5719034+bnjjj@users.noreply.github.com>
@bnjjj bnjjj requested review from a team as code owners November 26, 2024 16:07
@svc-apollo-docs
Copy link
Collaborator

svc-apollo-docs commented Nov 26, 2024

✅ Docs Preview Ready

No new or changed pages found.

This comment has been minimized.

@router-perf
Copy link

router-perf bot commented Nov 26, 2024

CI performance tests

  • connectors-const - Connectors stress test that runs with a constant number of users
  • const - Basic stress test that runs with a constant number of users
  • demand-control-instrumented - A copy of the step test, but with demand control monitoring and metrics enabled
  • demand-control-uninstrumented - A copy of the step test, but with demand control monitoring enabled
  • enhanced-signature - Enhanced signature enabled
  • events - Stress test for events with a lot of users and deduplication ENABLED
  • events_big_cap_high_rate - Stress test for events with a lot of users, deduplication enabled and high rate event with a big queue capacity
  • events_big_cap_high_rate_callback - Stress test for events with a lot of users, deduplication enabled and high rate event with a big queue capacity using callback mode
  • events_callback - Stress test for events with a lot of users and deduplication ENABLED in callback mode
  • events_without_dedup - Stress test for events with a lot of users and deduplication DISABLED
  • events_without_dedup_callback - Stress test for events with a lot of users and deduplication DISABLED using callback mode
  • extended-reference-mode - Extended reference mode enabled
  • large-request - Stress test with a 1 MB request payload
  • no-tracing - Basic stress test, no tracing
  • reload - Reload test over a long period of time at a constant rate of users
  • step-jemalloc-tuning - Clone of the basic stress test for jemalloc tuning
  • step-local-metrics - Field stats that are generated from the router rather than FTV1
  • step-with-prometheus - A copy of the step test with the Prometheus metrics exporter enabled
  • step - Basic stress test that steps up the number of users over time
  • xlarge-request - Stress test with 10 MB request payload
  • xxlarge-request - Stress test with 100 MB request payload

Signed-off-by: Benjamin <5719034+bnjjj@users.noreply.github.com>
@bnjjj bnjjj requested a review from a team as a code owner November 26, 2024 16:08
Copy link
Contributor

@garypen garypen left a comment

Choose a reason for hiding this comment

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

Some things to consider changing. Definitely change "retry" to "retries" though.

self.budget.deposit();
None
Ok(resp) => {
if resp.response.status() >= http::StatusCode::BAD_REQUEST {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this correct? I mean, what if the subgraph does something "weird" like returning a redirect?

i.e.: should this be:

if resp.response.status() != http::StatusCode::OK {

?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I recently saw users using 302 status code as a correct status code and they were making some stuffs in rhai about this. So I prefer to be conservative and use 400 status code as a threshold

Copy link
Contributor

Choose a reason for hiding this comment

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

It seems weird to me. If we go with this, then it means that we are encoding "weird" behaviour into the router and that might not be what some customers want.

My preference is to do the expected thing, rather than produce something which fits into a "weird" behaviour of a customer. See what other people think, since I may really be in the minority here.

Copy link
Member

Choose a reason for hiding this comment

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

If a subgraph returns a redirect, I would not expect it to be retried

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It seems weird to me. If we go with this, then it means that we are encoding "weird" behaviour into the router and that might not be what some customers want.

I agree, but I also agree with what @goto-bus-stop why would we retry on 3XX ?

Copy link
Contributor

Choose a reason for hiding this comment

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

To be honest: I find the concept of the retry module a bit weird. Maybe the best thing to do is to define exactly which codes we will retry on and document that?

@goto-bus-stop Says definitely on a 429. I'd probably also want to retry a 503. Apart for those two, I probably wouldn't want to retry.

Copy link
Member

Choose a reason for hiding this comment

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

I like starting with a small selection of codes.

I'm second-guessing 429 because we don't support Retry-After in this implementation and maybe that's something that clients should be doing, rather than us? If we just retry instantly then there is a good chance that we get a 429 again.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member

@goto-bus-stop goto-bus-stop Nov 28, 2024

Choose a reason for hiding this comment

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

I don't think it says that. I read that the user agent should wait Retry-After seconds before following the redirect, not that it should retry the original request:

When sent with any 3xx (Redirection) response, Retry-After indicates the minimum time that the user agent is asked to wait before issuing the redirected request.

Copy link
Contributor

Choose a reason for hiding this comment

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

Would we want to do that? Retry to the redirected request?

apollo-router/src/plugins/traffic_shaping/retry.rs Outdated Show resolved Hide resolved
Comment on lines +226 to +235
assert!(retry
.retry(
&subgraph_req,
Ok::<&subgraph::Response, &BoxError>(
&subgraph::Response::fake_builder()
.status_code(StatusCode::BAD_REQUEST)
.build()
)
)
.is_some());
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a test for a redirect: MOVED_PERMANENTLY

Signed-off-by: Benjamin <5719034+bnjjj@users.noreply.github.com>
@bnjjj bnjjj changed the title Bnjjj/fix retry metric Fix experimental_retry Nov 28, 2024
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.

5 participants