From d7910d934646f5eeefbd651fd4e4460ed2d394c2 Mon Sep 17 00:00:00 2001 From: Baoyuan Date: Fri, 17 Apr 2026 11:02:09 +0800 Subject: [PATCH] fix(nacos): restrict registry fetch to privileged agent only All other discovery modules (tars, kubernetes, consul) only fetch service data in the privileged agent process. The nacos module was missing this restriction, causing every worker process to independently fetch from nacos servers, resulting in N-times redundant API requests and JSON parsing overhead. Add the same process.type() check used by other discovery modules so only the privileged agent fetches from nacos, while workers read from the shared dict populated by the agent. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- apisix/discovery/nacos/init.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/apisix/discovery/nacos/init.lua b/apisix/discovery/nacos/init.lua index 1c50870613d4..9d386401ae6b 100644 --- a/apisix/discovery/nacos/init.lua +++ b/apisix/discovery/nacos/init.lua @@ -26,6 +26,7 @@ local error = error local math_random = math.random local ngx = ngx local ngx_timer_at = ngx.timer.at +local process = require("ngx.process") local log = core.log local _M = {} @@ -291,6 +292,10 @@ function _M.init_worker() return end + if process.type() ~= "privileged agent" then + return + end + -- shallow copy to avoid mutating cached config local conf = {} for k, v in pairs(nacos_conf) do