Skip to content

fix(workflow): skip the action plugin in the chain to avoid double execution#13617

Open
shreemaan-abhishek wants to merge 1 commit into
apache:masterfrom
shreemaan-abhishek:fix/workflow-plugin-double-exec
Open

fix(workflow): skip the action plugin in the chain to avoid double execution#13617
shreemaan-abhishek wants to merge 1 commit into
apache:masterfrom
shreemaan-abhishek:fix/workflow-plugin-double-exec

Conversation

@shreemaan-abhishek

Copy link
Copy Markdown
Contributor

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

  • 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

…ecution

When a plugin such as limit-count or limit-conn runs as a workflow action
and the same plugin is also configured in the normal plugin chain, the plugin
runs twice per request (e.g. a request is counted twice against a rate limit).

Mark the action plugin as skipped for the rest of the request so it does not
run again in the chain.

Signed-off-by: shreemaan-abhishek <shreemaan.abhishek@gmail.com>
@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Jun 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant