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

For first retry compute_backoff always return value below min_backoff settings #651

Open
7 tasks done
spumer opened this issue Sep 12, 2024 · 0 comments
Open
7 tasks done

Comments

@spumer
Copy link

spumer commented Sep 12, 2024

Checklist

  • Does your title concisely summarize the problem?
  • Did you include a minimal, reproducible example?
  • What OS are you using?
  • What version of Dramatiq are you using? - 1.17.0
  • What did you do?
  • What did you expect would happen?
  • What happened?

Dramatiq calculate delay time like this:

            min_backoff = message.options.get("min_backoff", actor.options.get("min_backoff", self.min_backoff))
            max_backoff = message.options.get("max_backoff", actor.options.get("max_backoff", self.max_backoff))
            max_backoff = min(max_backoff, DEFAULT_MAX_BACKOFF)
            _, delay = compute_backoff(retries, factor=min_backoff, max_backoff=max_backoff)

_, delay = compute_backoff(retries, factor=min_backoff, max_backoff=max_backoff)

When message retries first time we have a retries = 0 in this scope.
Then compute_backoff return value always below min_backoff
This happend due default jitter=True flag in compute_backoff function

You can check it manually:

from dramatiq.common import compute_backoff
retries = 0
compute_backoff(retries, factor=1000, max_backoff=5000)
Out[4]: (1, 734)
compute_backoff(retries, factor=1000, max_backoff=5000)
Out[5]: (1, 527)
compute_backoff(retries, factor=1000, max_backoff=5000)
Out[6]: (1, 924)
compute_backoff(retries, factor=1000, max_backoff=5000)
Out[7]: (1, 625)

What OS are you using?

macOS 14.4.1

What version of Dramatiq are you using?

1.17.0

What did you do?

Run task with expected delay

What did you expect would happen?

Delay should be between min_backoff and max_backoff

What happened?

Calculated delay below min_backoff

@spumer spumer changed the title For first retry compute_backoff always return value below min_backoff settings For first retry compute_backoff always return value below min_backoff settings Sep 12, 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

No branches or pull requests

1 participant