Skip to content

fix: preserve stream service plugin context#13402

Merged
nic-6443 merged 2 commits into
apache:masterfrom
nic-6443:fix-stream-service-plugin-cache-157
May 21, 2026
Merged

fix: preserve stream service plugin context#13402
nic-6443 merged 2 commits into
apache:masterfrom
nic-6443:fix-stream-service-plugin-cache-157

Conversation

@nic-6443

@nic-6443 nic-6443 commented May 21, 2026

Copy link
Copy Markdown
Member

When a stream route references a service, APISIX already builds a merged stream route and records a stream_route&service context. That context was then overwritten with route-only values before plugin execution, so plugin-level caches could keep using the old service plugin config until the route changed or the worker restarted.

This keeps the service-aware context for stream routes backed by a service, while preserving the existing route-only context for standalone stream routes.

Copilot AI review requested due to automatic review settings May 21, 2026 01:46
@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label May 21, 2026
@dosubot dosubot Bot added the bug Something isn't working label May 21, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes stream plugin context handling when a stream route references a Service. APISIX already computes a merged stream_route&service context for such routes, but the context used for plugin LRU cache keys was later overwritten with route-only values, causing stale service plugin configs to persist until route change or worker restart.

Changes:

  • Preserve the existing api_ctx.conf_type/conf_version/conf_id for service-backed stream routes by only setting the route-only context when it hasn’t already been set.
  • Add a regression test ensuring service plugin configuration updates take effect for stream routes referencing a service.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
apisix/init.lua Avoids overwriting api_ctx.conf_* so stream plugin cache keys reflect route+service context when applicable.
t/stream-plugin/syslog.t Adds a new test validating syslog plugin config changes on a Service are picked up by a stream route using service_id.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread t/stream-plugin/syslog.t Outdated
Comment thread t/stream-plugin/syslog.t Outdated
Comment thread t/stream-plugin/syslog.t Outdated
Comment thread t/stream-plugin/syslog.t Outdated
@nic-6443
nic-6443 merged commit 81dbc5b into apache:master May 21, 2026
33 of 34 checks passed
@nic-6443
nic-6443 deleted the fix-stream-service-plugin-cache-157 branch May 21, 2026 08:17
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:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants