Skip to content

Commit a9ebbcb

Browse files
fix(sync): do not introduce router rebuild timer for full sync (#14001) (#14006)
* fix(sync): do not introduce router rebuild timer for full sync * improve code style * fix comment: remove CP related info (cherry picked from commit ce668cc) Co-authored-by: Xiaochen Wang <[email protected]>
1 parent 1f1eb6f commit a9ebbcb

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

kong/runloop/handler.lua

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -359,12 +359,17 @@ local function new_router(version)
359359
end
360360
end
361361

362-
local detect_changes = kong.core_cache and true
363-
364-
-- for dbless we will not check changes when initing
365-
if db.strategy == "off" and get_phase() == "init_worker" then
366-
detect_changes = false
367-
end
362+
-- We need to detect router changes if there is some one modifying the routers,
363+
-- like rebuild_router_timer. And it relies on core_cache to detect changes.
364+
--
365+
-- 1. stratey off (dbless)
366+
-- incremental_sync on:
367+
-- non init worker: true(kong.core_cache)
368+
-- init worker: false
369+
-- incremental_sync off: false
370+
-- 2. strategy on (non dbless): true(kong.core_cache)
371+
local detect_changes = kong.core_cache and
372+
(db.strategy ~= "off" or (kong.sync and get_phase() ~= "init_worker"))
368373

369374
local counter = 0
370375
local page_size = db.routes.pagination.max_page_size
@@ -979,7 +984,10 @@ return {
979984
end
980985
end
981986

982-
do -- start some rebuild timers
987+
-- start some rebuild timers for
988+
-- 1. traditional mode
989+
-- 2. DP with incremental sync on (dbless mode)
990+
if strategy ~= "off" or kong.sync then
983991
local worker_state_update_frequency = kong.configuration.worker_state_update_frequency or 1
984992

985993
local router_async_opts = {

0 commit comments

Comments
 (0)