From 83b704e1983267809fbe95e650678d0d999bcb67 Mon Sep 17 00:00:00 2001 From: Xiaochen Wang Date: Tue, 10 Dec 2024 22:36:14 +0800 Subject: [PATCH] fix(sync): do not introduce router rebuild timer for full sync (#14001) * fix(sync): do not introduce router rebuild timer for full sync * improve code style * fix comment: remove CP related info (cherry picked from commit ce668ccb86479bbdda70f1094a92d6b57bc65166) --- kong/runloop/handler.lua | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/kong/runloop/handler.lua b/kong/runloop/handler.lua index 4308689770b4..37efc7f8bb78 100644 --- a/kong/runloop/handler.lua +++ b/kong/runloop/handler.lua @@ -359,12 +359,17 @@ local function new_router(version) end end - local detect_changes = kong.core_cache and true - - -- for dbless we will not check changes when initing - if db.strategy == "off" and get_phase() == "init_worker" then - detect_changes = false - end + -- We need to detect router changes if there is some one modifying the routers, + -- like rebuild_router_timer. And it relies on core_cache to detect changes. + -- + -- 1. stratey off (dbless) + -- incremental_sync on: + -- non init worker: true(kong.core_cache) + -- init worker: false + -- incremental_sync off: false + -- 2. strategy on (non dbless): true(kong.core_cache) + local detect_changes = kong.core_cache and + (db.strategy ~= "off" or (kong.sync and get_phase() ~= "init_worker")) local counter = 0 local page_size = db.routes.pagination.max_page_size @@ -979,7 +984,10 @@ return { end end - do -- start some rebuild timers + -- start some rebuild timers for + -- 1. traditional mode + -- 2. DP with incremental sync on (dbless mode) + if strategy ~= "off" or kong.sync then local worker_state_update_frequency = kong.configuration.worker_state_update_frequency or 1 local router_async_opts = {