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

[ratelimiting] bug when cassandra counter exceeds the limit #289

Closed
smanolache opened this issue Jun 3, 2015 · 4 comments
Closed

[ratelimiting] bug when cassandra counter exceeds the limit #289

smanolache opened this issue Jun 3, 2015 · 4 comments
Labels
idea/new plugin [legacy] those issues belong to Kong Nation, since GitHub issues are reserved for bug reports. task/bug

Comments

@smanolache
Copy link
Contributor

Hello,

For some reason (non-atomicity of the read-modify-write counter operation in cassandra?) the request counter of the ratelimiting_metrics may exceed the configured limit. In this case

local remaining = conf.limit - current_usage

in kong/plugins/ratelimiting/access.lua becomes negative.

The condition

if remaining == 0 then

is then false and the request is passed through even if the limit is exceeded.

I propose to replace the condition with

if remaining <= 0 then
@thibaultcha
Copy link
Member

Yes, the atomicity of the read-write operation is absolutely not guaranteed. I've been wanting to tweak the consistency but even for a single node Kong, single node Cassandra cluster, there is no atomicity, so there is an error rate especially for the second period.

I agree with the proposed change, if you want to submit a PR.

@thibaultcha thibaultcha added task/bug idea/new plugin [legacy] those issues belong to Kong Nation, since GitHub issues are reserved for bug reports. labels Jun 3, 2015
@smanolache
Copy link
Contributor Author

Submitted the pull request.

@sonicaghi
Copy link
Member

thank you!

@thibaultcha
Copy link
Member

Yep closing this now

Tieske added a commit that referenced this issue Sep 22, 2020
  - `compat.wrap` a `coroutine.wrap` implementation that works like plain Lua
    on OpenResty. (#342)

  - In `pl.class`, `_init` can now be inherited from grandparent (or older ancestor) classes. [#289](lunarmodules/Penlight#289)
  - Using `compat.wrap` it now fixes `dir.dirtree`, `pl.lexer` on OpenResty. [#342](lunarmodules/Penlight#342)
bungle pushed a commit that referenced this issue Sep 23, 2020
  - `compat.wrap` a `coroutine.wrap` implementation that works like plain Lua
    on OpenResty. (#342)

  - In `pl.class`, `_init` can now be inherited from grandparent (or older ancestor) classes. [#289](lunarmodules/Penlight#289)
  - Using `compat.wrap` it now fixes `dir.dirtree`, `pl.lexer` on OpenResty. [#342](lunarmodules/Penlight#342)
bungle pushed a commit that referenced this issue Sep 24, 2020
Fixes

    In pl.class, _init can now be inherited from grandparent (or older ancestor) classes. #289
    Fixes dir, lexer, and permute to no longer use coroutines. #344
Tieske added a commit that referenced this issue Sep 27, 2020
Fixes

    In pl.class, _init can now be inherited from grandparent (or older ancestor) classes. #289
    Fixes dir, lexer, and permute to no longer use coroutines. #344
bungle pushed a commit that referenced this issue Sep 27, 2020
Fixes

    In pl.class, _init can now be inherited from grandparent (or older ancestor) classes. #289
    Fixes dir, lexer, and permute to no longer use coroutines. #344
hutchic added a commit that referenced this issue Jun 10, 2022
Update dependency stevedore to v2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
idea/new plugin [legacy] those issues belong to Kong Nation, since GitHub issues are reserved for bug reports. task/bug
Projects
None yet
Development

No branches or pull requests

3 participants