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

Infinite loop in rate limit middleware #2687

Closed
jlucktay opened this issue Nov 22, 2019 · 0 comments · Fixed by #2696
Closed

Infinite loop in rate limit middleware #2687

jlucktay opened this issue Nov 22, 2019 · 0 comments · Fixed by #2696
Assignees
Labels

Comments

@jlucktay
Copy link
Contributor

Branch/Environment/Version

  • Branch/Version: tag v2.8.5
  • Environment: on-premise, though likely to affect others also

Describe the bug
In certain circumstances, requests passing through the rate limit/quota check middleware may fall into an infinite loop, due to a recursive function call that is not properly guarded and as such does not have an adequate exit condition.

Reproduction steps
TBD

Actual behavior
Some requests entering the gateway get stuck on an infinite/recursive loop, never get past the rate limit/quota check middleware, and cause a gradual increase in CPU usage and allocated memory.

Expected behavior
All requests entering the gateway are limit-/quota-checked and throttled/retried/completed appropriately.

Screenshots/Video
pprof output from the inuse_space sample of two heap profiles of an affected gateway are below.

Profile 1 is still receiving new traffic and Profile 2 is after the point where new traffic is no longer entering the gateway.

Corresponding increases in CPU time spent were also identified on the CPU profile in pprof (not shown).

image
image

CPU usage of the instance running this affected gateway, in contrast to some other healthy instances/gateways:

image

Configuration (tyk config file):
TBD

@jlucktay jlucktay added the bug label Nov 22, 2019
@jlucktay jlucktay self-assigned this Nov 22, 2019
jlucktay added a commit that referenced this issue Nov 26, 2019
Move guard statement forward to prevent infinite recursive loop.
jlucktay added a commit that referenced this issue Nov 28, 2019
- increases test coverage across issue described in #2687
- covers more throttle interval values as identified during
investigation of original issue
buger pushed a commit that referenced this issue Dec 27, 2019
Move guard statement forward to prevent infinite recursive loop.
buger pushed a commit that referenced this issue Dec 27, 2019
- increases test coverage across issue described in #2687
- covers more throttle interval values as identified during
investigation of original issue
buger pushed a commit that referenced this issue Dec 27, 2019
Fix #2687

Move guard statement forward to prevent infinite recursive loop.
Test coverage is forthcoming.
furkansenharputlu pushed a commit that referenced this issue Dec 30, 2019
Fix #2687

Move guard statement forward to prevent infinite recursive loop.
Test coverage is forthcoming.
furkansenharputlu pushed a commit that referenced this issue Dec 30, 2019
Fix #2687

Move guard statement forward to prevent infinite recursive loop.
Test coverage is forthcoming.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant