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

fix(core): initialize route to avoid race (500) #13924

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
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
12 changes: 12 additions & 0 deletions kong/runloop/handler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ local request_id_get = request_id.get
local escape = require("kong.tools.uri").escape
local encode = require("string.buffer").encode
local uuid = require("kong.tools.uuid").uuid
local EMPTY = require("kong.tools.table").EMPTY

local req_dyn_hook_run_hook = req_dyn_hook.run_hook

Expand Down Expand Up @@ -429,6 +430,17 @@ end


local function build_router(version)
-- as new_router may be interrupted, and after init_worker we assume
-- the ROUTE is never nil, we create an empty router which cannot be
-- interrupted and will be replaced by the new_router
if version == "init" then
local err
ROUTER, err = Router.new(EMPTY, ROUTER_CACHE, ROUTER_CACHE_NEG, ROUTER)
if not ROUTER then
log(ERR, "could not create an empty router: ", err)
end
end

local router, err = new_router(version)
if not router then
return nil, err
Expand Down
Loading