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

Add maxbackoff and backoffincrement options #1626

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

cdelguercio
Copy link

@cdelguercio cdelguercio commented Feb 28, 2024

  • maxbackoff - the maximum number of seconds that supervisor will backoff before restart

  • backoffincrement - the number of seconds to add to the backoff after each retry

based on #1529

Fixes #323

@cdelguercio
Copy link
Author

If maxbackoff and backoffincrement are both set, adding backoffincrement to backoff may result in the remaining retries having a backoff value higher than maxbackoff.

Ex:
maxbackoff = 25
backoffincrement = 10

backoff will go from
1, 11, 21, 31, 31, 31, 31...

@@ -168,7 +168,8 @@ def change_state(self, new_state, expected=True):
self.state = new_state
if new_state == ProcessStates.BACKOFF:
now = time.time()
self.backoff += 1
if self.backoff < self.config.maxbackoff or self.config.maxbackoff == 0:
self.backoff += self.config.backoffincrement

Choose a reason for hiding this comment

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

@cdelguercio to prevent the issue you mentioned in #1626 (comment) you can use min:

self.backoff = min(self.backoff + self.config.backoffincrement, self.config.maxbackoff)

Copy link
Author

Choose a reason for hiding this comment

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

I think you'd have to do something like:

self.backoff = self.config.maxbackoff == 0 ? self.backoff + self.config.backoffincrement : min(self.backoff + self.config.backoffincrement, self.config.maxbackoff);

The question is: what's preferred?

Choose a reason for hiding this comment

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

Yeah I see what you are saying, I missed the self.config.maxbackoff == 0 case.

What you have suggested looks correct 👍

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

Successfully merging this pull request may close these issues.

RFE: Ability to specify delay time, algorithm within supervisor
2 participants