You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by "shreemaan-abhishek (via GitHub)" <gi...@apache.org> on 2026/06/26 12:43:50 UTC
[PR] fix(workflow): skip the action plugin in the chain to avoid double execution [apisix]
shreemaan-abhishek opened a new pull request, #13617:
URL: https://github.com/apache/apisix/pull/13617
### Description
The `workflow` Plugin (priority 1006) can run a plugin such as `limit-count` (priority 1002) or `limit-conn` (priority 1003) as an action. When the same plugin is *also* configured directly in the normal plugin chain on the same Route/Service/Consumer/Global Rule, the plugin ends up running twice per request:
1. once via the `workflow` action handler, and
2. once in the normal chain (the `workflow` access handler returns `nil` on the non-rejected path, so it does not short-circuit the chain).
The visible impact is that a request is counted/limited twice. For `limit-count` the quota is consumed at 2x; the same applies to `limit-conn` (which is also double-counted in both `access` and `log`). This is reachable with stock plugins and a non-exotic configuration.
This PR adds `plugin.skip_plugin(ctx, name)` to mark the action plugin as skipped for the rest of the request, so once `workflow` runs it as an action it is not executed again in the normal chain. The skip is honored in both `run_plugin` loops (access/rewrite and log/header_filter/body_filter), so `limit-conn`'s `log`-phase decrement is also handled only by the `workflow` action.
#### Which issue(s) this PR fixes:
N/A
### Checklist
- [x] I have explained the need for this PR and the problem it solves
- [x] I have explained the changes or the new features added to this PR
- [x] I have added tests corresponding to this change
- [x] I have updated the documentation to reflect this change
- [x] I have verified that this change is backward compatible
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(workflow): skip the action plugin in the chain to avoid double execution [apisix]
Posted by "shreemaan-abhishek (via GitHub)" <gi...@apache.org>.
shreemaan-abhishek commented on code in PR #13617:
URL: https://github.com/apache/apisix/pull/13617#discussion_r3489328231
##########
apisix/plugin.lua:
##########
@@ -1329,6 +1339,9 @@ function _M.run_plugin(phase, plugins, api_ctx)
run_meta_pre_function(conf, api_ctx, plugins[i]["name"])
plugin_run = true
api_ctx._plugin_name = plugins[i]["name"]
+ if api_ctx._skip_plugins and api_ctx._skip_plugins[api_ctx._plugin_name] then
+ goto CONTINUE
+ end
Review Comment:
Good catch. Addressed in a62881902: the `_skip_plugins` check now runs right after `meta_filter` and before `run_meta_pre_function`/`_plugin_name`/`plugin_run` in both loops, so a skipped action plugin no longer fires its meta pre_function or leaves stale state.
##########
apisix/plugin.lua:
##########
@@ -1367,12 +1380,17 @@ function _M.run_plugin(phase, plugins, api_ctx)
plugin_run = true
run_meta_pre_function(conf, api_ctx, plugins[i]["name"])
api_ctx._plugin_name = plugins[i]["name"]
+ if api_ctx._skip_plugins and api_ctx._skip_plugins[api_ctx._plugin_name] then
+ goto CONTINUE
+ end
Review Comment:
Good catch. Addressed in a62881902: the `_skip_plugins` check now runs right after `meta_filter` and before `run_meta_pre_function`/`_plugin_name`/`plugin_run` in both loops, so a skipped action plugin no longer fires its meta pre_function or leaves stale state.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(workflow): skip the action plugin in the chain to avoid double execution [apisix]
Posted by "shreemaan-abhishek (via GitHub)" <gi...@apache.org>.
shreemaan-abhishek merged PR #13617:
URL: https://github.com/apache/apisix/pull/13617
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(workflow): skip the action plugin in the chain to avoid double execution [apisix]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #13617:
URL: https://github.com/apache/apisix/pull/13617#discussion_r3489239228
##########
apisix/plugin.lua:
##########
@@ -1329,6 +1339,9 @@ function _M.run_plugin(phase, plugins, api_ctx)
run_meta_pre_function(conf, api_ctx, plugins[i]["name"])
plugin_run = true
api_ctx._plugin_name = plugins[i]["name"]
+ if api_ctx._skip_plugins and api_ctx._skip_plugins[api_ctx._plugin_name] then
+ goto CONTINUE
+ end
Review Comment:
The skip logic uses `goto CONTINUE` after setting `api_ctx._plugin_name` and after running the plugin meta `pre_function`, but it never clears `_plugin_name` and still sets `plugin_run = true`. This can leak the previous plugin name into subsequent iterations/phases and can unexpectedly execute meta pre-functions for a plugin that is intentionally skipped.
##########
apisix/plugin.lua:
##########
@@ -1367,12 +1380,17 @@ function _M.run_plugin(phase, plugins, api_ctx)
plugin_run = true
run_meta_pre_function(conf, api_ctx, plugins[i]["name"])
api_ctx._plugin_name = plugins[i]["name"]
+ if api_ctx._skip_plugins and api_ctx._skip_plugins[api_ctx._plugin_name] then
+ goto CONTINUE
+ end
Review Comment:
Same issue in the log/header/body filter plugin loop: `run_meta_pre_function` and `api_ctx._plugin_name` are set before checking `_skip_plugins`, and a `goto CONTINUE` skips cleanup (`api_ctx._plugin_name = nil`) and still marks `plugin_run = true`. Skipping should happen before meta hooks and `_plugin_name` assignment to avoid leaking state.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org