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

t.a.i.backoffPolicy fails after a certain number of retries (builtins.OverflowError) #9476

Closed
twisted-trac opened this issue Jul 2, 2018 · 4 comments

Comments

@twisted-trac
Copy link

wiml's avatar @wiml reported
Trac ID trac#9476
Type defect
Created 2018-07-02 21:05:08Z

I have some connections which can go down for a while, but I want to keep checking (once per minute, e.g.) until they become reachable again. Supposedly, I can do this with the maxDelay parameter of backoffPolicy.

After a while, though, instead of continuing to re-try, policy will start raising an exception:

Jul 02 12:59:22 [8534]: File ".../python3.6/site-packages/automat/_methodical.py", line 135, in _connectionFailed
Jul 02 12:59:22 [8534]: value = output(oself, *args, **kwargs)
Jul 02 12:59:22 [8534]: File ".../python3.6/site-packages/automat/_methodical.py", line 169, in __call__
Jul 02 12:59:22 [8534]: return self.method(oself, *args, **kwargs)
Jul 02 12:59:22 [8534]: File ".../python3.6/site-packages/twisted/application/internet.py", line 740, in _ignoreAndWait
Jul 02 12:59:22 [8534]: return self._doWait()
Jul 02 12:59:22 [8534]: File ".../python3.6/site-packages/twisted/application/internet.py", line 744, in _doWait
Jul 02 12:59:22 [8534]: delay = self._timeoutForAttempt(self._failedAttempts)
Jul 02 12:59:22 [8534]: File ".../python3.6/site-packages/twisted/application/internet.py", line 520, in policy
Jul 02 12:59:22 [8534]: return min(initialDelay * (factor ** attempt), maxDelay) + jitter()
Jul 02 12:59:22 [8534]: builtins.OverflowError: (34, 'Numerical result out of range')

(Some pathnames sanitized.) A little investigation shows that once the attempt count exceeds 1750, the intermediate result is too large to represent in a float, and so even though it will be discarded and replaced by maxDelay this will cause retries to fail:

>>> factor = 1.5
>>> (factor ** 1750)
1.4444527745742028e+308
>>> (factor ** 1751)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OverflowError: (34, 'Numerical result out of range')

This will take only a couple of days at maxDelay=60.0: less than a weekend.

Versions:

  • Twisted==18.4.0
  • Python 3.6.3 (default, Jan 4 2018, 16:40:53)
  • [GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux
  • CentOS Linux release 7.4.1708 (Core)
Searchable metadata
trac-id__9476 9476
type__defect defect
reporter__wiml wiml
priority__normal normal
milestone__None None
branch__ 
branch_author__ 
status__closed closed
resolution__fixed fixed
component__core core
keywords__None None
time__1530565508694370 1530565508694370
changetime__1558292011336444 1558292011336444
version__None None
owner__jandelgado jandelgado

@twisted-trac
Copy link
Author

jandelgado's avatar @jandelgado commented

Fixed with #1141

@twisted-trac
Copy link
Author

twm's avatar @twm set owner to @twm

@twisted-trac
Copy link
Author

twm's avatar @twm set owner to @jandelgado

Review here: #1141 (review)

@twisted-trac
Copy link
Author

twm's avatar @twm set status to closed

In changeset dea4e9c

#!CommitTicketReference repository="" revision="dea4e9cfaee8a81fc8c5515d908eb5696f6473a8"
Merge pull request #1142 from twisted/9476-merge-1141

Author: jandelgado
Reviewer: twm
Fixes: ticket:9476

Merge PR #1141 to correct backoffPolicy() behavior on numeric overflow.

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

No branches or pull requests

1 participant