Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(clustering/rpc): stop ngx.timer.every if no sync.v2 #14076

Merged
merged 11 commits into from
Jan 3, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
stop v1 loop
chronolaw committed Jan 2, 2025
commit f944567174c7f31dcc82a2875a85353e3ccf8b78
17 changes: 7 additions & 10 deletions kong/clustering/data_plane.lua
Original file line number Diff line number Diff line change
@@ -108,16 +108,11 @@ function _M:init_worker(basic_info)

-- cp supports kong.sync.v2
if has_sync_v2 then
-- notify communicate() to exit
self.config_exit = true
return
end

-- we only check once
if self.inited then
return
end

self.inited = true

ngx_log(ngx_WARN, "sync v1 is enabled due to rpc sync can not work.")

-- only run in process which worker_id() == 0
@@ -256,13 +251,15 @@ function _M:communicate(premature)
-- * write_thread: it is the only thread that receives WS frames from the CP,
-- and is also responsible for handling timeout detection

-- the flag that outside could stop the loop forcely
self.config_exit = false

local ping_immediately
local config_exit
local next_data
local config_err_t

local config_thread = ngx.thread.spawn(function()
while not exiting() and not config_exit do
while not exiting() and not self.config_exit do
local ok, err = config_semaphore:wait(1)

if not ok then
@@ -406,7 +403,7 @@ function _M:communicate(premature)

-- the config thread might be holding a lock if it's in the middle of an
-- update, so we need to give it a chance to terminate gracefully
config_exit = true
self.config_exit = true

ok, err, perr = ngx.thread.wait(config_thread)
if not ok then