diff --git a/lib/resty/healthcheck.lua b/lib/resty/healthcheck.lua index 3922d582..9560deef 100644 --- a/lib/resty/healthcheck.lua +++ b/lib/resty/healthcheck.lua @@ -1650,9 +1650,11 @@ function _M.new(opts) end local cur_time = ngx_now() + local is_checked = false for _, checker_obj in pairs(hcs) do if (last_cleanup_check + CLEANUP_INTERVAL) < cur_time then + is_checked = true -- clear targets marked for delayed removal locking_target_list(checker_obj, function(target_list) local removed_targets = {} @@ -1681,8 +1683,6 @@ function _M.new(opts) end end end) - - last_cleanup_check = cur_time end if checker_obj.checks.active.healthy.active and @@ -1701,6 +1701,9 @@ function _M.new(opts) checker_callback(checker_obj, "unhealthy") end end + if is_checked then + last_cleanup_check = cur_time + end end, }) if not active_check_timer then