Skip to content

Commit

Permalink
fix(clustering/rpc): warning log level for sync retry failing (#14192)
Browse files Browse the repository at this point in the history
KAG-6224

---------

Co-authored-by: Xumin <100666470+StarlightIbuki@users.noreply.github.com>
  • Loading branch information
chronolaw and StarlightIbuki authored Jan 22, 2025
1 parent f657890 commit cb31e28
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
7 changes: 4 additions & 3 deletions kong/clustering/services/sync/rpc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ local ipairs = ipairs
local ngx_null = ngx.null
local ngx_log = ngx.log
local ngx_ERR = ngx.ERR
local ngx_WARN = ngx.WARN
local ngx_INFO = ngx.INFO
local ngx_DEBUG = ngx.DEBUG

Expand Down Expand Up @@ -422,8 +423,8 @@ local function sync_once_impl(premature, retry_count)
-- retry if the version is not updated
retry_count = retry_count or 0

if retry_count > MAX_RETRY then
ngx_log(ngx_ERR, "sync_once retry count exceeded. retry_count: ", retry_count)
if retry_count >= MAX_RETRY then
ngx_log(ngx_WARN, "sync_once retry count exceeded. retry_count: ", retry_count)
return
end

Expand All @@ -435,7 +436,7 @@ local function sync_once_impl(premature, retry_count)
-- in some cases, the new spawned timer will be switched to immediately,
-- preventing the coroutine who possesses the mutex to run
-- to let other coroutines has a chance to run
local ok, err = kong.timer:at(0.1, sync_once_impl, retry_count or 0)
local ok, err = kong.timer:at(0.1, sync_once_impl, retry_count)
-- this is a workaround for a timerng bug, where tail recursion causes failure
-- ok could be a string so let's convert it to boolean
if not ok then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,16 @@ for _, strategy in helpers.each_strategy() do
"no sync runs, version is " .. rep("0", 32), true, 10)

assert.logfile(name).has.line(
"sync_once retry count exceeded. retry_count: 6", true, 10)
"sync_once retry count exceeded. retry_count: 5", true, 10)
assert.logfile(name).has.no.line(
"assertion failed", true, 0)
assert.logfile(name).has.no.line(
"[error]", true, 0)

local name = nil

-- cp logs
for i = 0, 6 do
for i = 0, 5 do
assert.logfile(name).has.line(
"kong.sync.v2.get_delta ok: " .. i, true, 10)
end
Expand Down

1 comment on commit cb31e28

@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-dev:cb31e2892bf2f0fe30817d80e5a036541e7c22e6
Artifacts available https://github.com/Kong/kong/actions/runs/12899207985

Please sign in to comment.