Skip to content

fix: batch processor cache not working when configure plugin in service#12474

Merged
nic-6443 merged 1 commit into
apache:masterfrom
nic-6443:nic/fix-batch-processor-cache
Jul 31, 2025
Merged

fix: batch processor cache not working when configure plugin in service#12474
nic-6443 merged 1 commit into
apache:masterfrom
nic-6443:nic/fix-batch-processor-cache

Conversation

@nic-6443

@nic-6443 nic-6443 commented Jul 30, 2025

Copy link
Copy Markdown
Member

Description

When merging the configurations of service and route, APISIX will first perform a deepcopy on the configuration of the service.

apisix/apisix/plugin.lua

Lines 585 to 586 in e3e5a99

local function merge_service_route(service_conf, route_conf)
local new_conf = core.table.deepcopy(service_conf, { shallows = {"self.value.upstream.parent"}})

This results in each route associated with this service getting an independent plugin configuration table, causing the cache in batch-processor-manager.lua that is based on table memory addresses as keys to not work properly.

Note

After this fix, every logger plugin that integrated with batch-processor-manager.lua can share the same batch processor object as long as the plugin configuration is identical. For example, with kafka-logger, even if the exact same kafka-logger plugin is configured on different services, the batch processor object and kafka producer will be the same and will not be created multiple times.

Which issue(s) this PR fixes:

Fixes #

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)

@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Jul 30, 2025
@dosubot dosubot Bot added the bug Something isn't working label Jul 30, 2025
@nic-6443
nic-6443 merged commit a5d06b3 into apache:master Jul 31, 2025
37 of 38 checks passed
@nic-6443
nic-6443 deleted the nic/fix-batch-processor-cache branch July 31, 2025 01:12
jizhuozhi pushed a commit to jizhuozhi/apisix that referenced this pull request Oct 18, 2025
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:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants