Skip to content

fix(limit-count): use meta parent to identify plugin source#12900

Merged
nic-6443 merged 7 commits into
apache:masterfrom
shreemaan-abhishek:fix/limit-count-identifies-consumer-source
Jan 15, 2026
Merged

fix(limit-count): use meta parent to identify plugin source#12900
nic-6443 merged 7 commits into
apache:masterfrom
shreemaan-abhishek:fix/limit-count-identifies-consumer-source

Conversation

@shreemaan-abhishek

@shreemaan-abhishek shreemaan-abhishek commented Jan 13, 2026

Copy link
Copy Markdown
Contributor

Description

When configuring rate limiting plugin in different consumers, quota usage for one consumer would affect another consumer's quota too. This happened because the rate limiting key being constructed would be unaware of the source of the rate limiting plugin hence the rate limiting key for different consumer would produce same key for a given route.

To fix this we ensure that parent information is filled in to plugin configurations for plugins configured in a consumer.

Which issue(s) this PR fixes:

Fixes #12896

Checklist

  • I have explained the need for this PR and the problem it solves
  • I have explained the changes or the new features added to this PR
  • I have added tests corresponding to this change
  • I have updated the documentation to reflect this change
  • I have verified that this change is backward compatible (If not, please discuss on the APISIX mailing list first)

Signed-off-by: Abhishek Choudhary <[email protected]>
Signed-off-by: Abhishek Choudhary <[email protected]>
Signed-off-by: Abhishek Choudhary <[email protected]>
@shreemaan-abhishek
shreemaan-abhishek marked this pull request as ready for review January 14, 2026 08:02
@dosubot dosubot Bot added size:XL This PR changes 500-999 lines, ignoring generated files. bug Something isn't working labels Jan 14, 2026
@shreemaan-abhishek
shreemaan-abhishek requested review from bzp2010 and membphis and removed request for membphis January 14, 2026 08:03
Comment thread apisix/plugins/limit-count/init.lua Outdated
end

local match, err = ngx.re.match(parent.resource_key, [[/apisix/([^/]+)/([^/]+)]])

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

remove this useless line

Comment thread apisix/plugins/limit-count/init.lua Outdated
local match, err = ngx.re.match(parent.resource_key, [[/apisix/([^/]+)/([^/]+)]])

if not match then
core.log.error("failed to generate key invalid parent resource key, err: ", err)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think we can remove the etcd_prefix, then it should be enough

we can always use it directly, eg: routes/r1

etcd:
  host:
    - "http://127.0.0.1:2379" # Replace with your etcd cluster host(s)
  prefix: "/apisix" # The default prefix, modify as needed
  timeout: 30

Comment thread apisix/plugins/limit-count/init.lua Outdated
Signed-off-by: Abhishek Choudhary <[email protected]>
membphis
membphis previously approved these changes Jan 14, 2026
nic-6443
nic-6443 previously approved these changes Jan 14, 2026
Signed-off-by: Abhishek Choudhary <[email protected]>
@shreemaan-abhishek
shreemaan-abhishek dismissed stale reviews from nic-6443 and membphis via 5caff96 January 14, 2026 09:37
@nic-6443
nic-6443 requested a review from nic-chen January 15, 2026 04:13
@nic-6443
nic-6443 merged commit 2d6bff8 into apache:master Jan 15, 2026
23 checks passed
wistefan pushed a commit to wistefan/apisix that referenced this pull request Jun 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: ai-rate-limiting is applied globally instead of per consumer

4 participants