Skip to content

fix: the issue that plugins in global rule may be cached to route#4867

Merged
spacewander merged 2 commits into
apache:masterfrom
nic-chen:fix-plugins-cache
Aug 23, 2021
Merged

fix: the issue that plugins in global rule may be cached to route#4867
spacewander merged 2 commits into
apache:masterfrom
nic-chen:fix-plugins-cache

Conversation

@nic-chen

Copy link
Copy Markdown
Member

What this PR does / why we need it:

fix the issue that plugins in global rule may be cached to route

Pre-submission checklist:

  • Did you explain what problem does this PR solve? Or what new features have been added?
  • Have you added corresponding test cases?
  • Have you modified the corresponding document?
  • Is this PR backward compatible? If it is not backward compatible, please discuss on the mailing list first

Comment thread apisix/init.lua Outdated

core.ctx.release_vars(api_ctx)
if api_ctx.plugins and api_ctx.plugins ~= core.empty_tab then
if api_ctx.plugins and core.table.nkeys(api_ctx.plugins) > 0 then

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.

Empty plugins also need to be released.

Comment thread apisix/plugin.lua Outdated
-- when 'plugins' is given, always return 'plugins' itself instead
-- of another one
return plugins or core.empty_tab
return plugins or {}

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.

Suggested change
return plugins or {}
return plugins or core.tablepool.fetch("plugins", 0, 0)

Comment thread t/node/global-rule.t Outdated



=== TEST 17: delete global rules, ensure no stale data remain

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.

bad title, need to more detail

@spacewander
spacewander merged commit 1d5ecca into apache:master Aug 23, 2021
@nic-chen
nic-chen deleted the fix-plugins-cache branch August 23, 2021 09:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants