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
  • Loading branch information
chobits authored Dec 10, 2024
1 parent b594b1d commit ce668cc
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

1 comment on commit ce668cc

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bazel Build

Docker image available kong/kong:ce668ccb86479bbdda70f1094a92d6b57bc65166
Artifacts available https://github.com/Kong/kong/actions/runs/12258377615

Please sign in to comment.