Skip to content

Commit

Permalink
fix(sync): do not introduce router rebuild timer for full sync (#14001)
Browse files Browse the repository at this point in the history
* 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)
  • Loading branch information
chobits authored and github-actions[bot] committed Dec 11, 2024
1 parent 1f1eb6f commit 83b704e
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions kong/runloop/handler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 = {
Expand Down

0 comments on commit 83b704e

Please sign in to comment.