Skip to content

Commit

Permalink
fix(runloop): skip router rebuilding if reconfigure is running (#14056)
Browse files Browse the repository at this point in the history
In rare cases, the rebuild timer will interrupt the reconfigure handler because of `router was changed while rebuilding it`, which results in an outdated plugin iterator and balancer.

It is hard to test this rare race condition.

KAG-6015
  • Loading branch information
ADD-SP authored Jan 14, 2025
1 parent 4d56a90 commit 65f43be
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion kong/runloop/handler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -992,8 +992,30 @@ return {
if strategy ~= "off" or kong.sync then
local worker_state_update_frequency = kong.configuration.worker_state_update_frequency or 1

--[[
+-----------+
| Start | <-------------------------------------+
+-----------+ |
| |
| |
v |
*************************** +-------+ |
* Is reconfigure running? * ---Yes--->| Sleep | ----+
*************************** +-------+
| ^
No |
| |
v |
+---------------+ |
| rebuild router|-------------------------+
+---------------+
Since reconfigure will also rebuild the router, we skip this round
of rebuilding the router.
--]]
local router_async_opts = {
name = "router",
name = RECONFIGURE_OPTS and RECONFIGURE_OPTS.name or "router", -- please check the above diagram for the
-- reason of using the same name as reconfigure
timeout = 0,
on_timeout = "return_true",
}
Expand Down

1 comment on commit 65f43be

@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:65f43bec13dec28c742e23344d2c43b494412859
Artifacts available https://github.com/Kong/kong/actions/runs/12760825167

Please sign in to comment.