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

[Bug] RetryBackoffLayer can trigger a div-by-zero if CU misconfigured #1761

Open
mothran opened this issue Dec 6, 2024 · 4 comments
Open
Labels
bug Something isn't working

Comments

@mothran
Copy link

mothran commented Dec 6, 2024

Component

transports

What version of Alloy are you on?

0.6.4

Operating System

Linux

Describe the bug

When running the RetryBackOffLayer with a low (lower than AVG_COST) it is possible trigger a div-by-zero in the layer:

thread 'main' panicked at /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/alloy-transport-0.6.4/src/layers/retry.rs:230:53:
attempt to divide by zero

With the configured params:

        RetryBackoffLayer::new(10, 1000, 10);

Having a sanity check for the configured CU, or bounding that div would be nice to avoid the panic.

@mothran mothran added the bug Something isn't working label Dec 6, 2024
@mattsse
Copy link
Member

mattsse commented Dec 6, 2024

makes sense,

do you want to provide a fix for this?

@mothran
Copy link
Author

mothran commented Dec 6, 2024

makes sense,

do you want to provide a fix for this?

I can take a crack at it (maybe next week), is there a example of unit testing tower layers in the codebase I can use to work off?

@yash-atreya
Copy link
Member

makes sense,
do you want to provide a fix for this?

I can take a crack at it (maybe next week), is there a example of unit testing tower layers in the codebase I can use to work off?

@mothran ptal here

async fn test_custom_retry_policy() {

@Evalir
Copy link
Contributor

Evalir commented Dec 23, 2024

What's the fix we want to do here? bound the div to always be at least one? Or just handle the case where CU < AVG_COST separately?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants