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: don't release healthchecker during etcd sync due to compaction #10837

Closed
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion apisix/core/config_etcd.lua
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ local function sync_data(self)

if self.values then
for i, val in ipairs(self.values) do
config_util.fire_all_clean_handlers(val)
config_util.fire_all_clean_handlers(val, self.compacted)
end

self.values = nil
Expand All @@ -629,6 +629,7 @@ local function sync_data(self)
if not dir_res then
if err == "compacted" then
self.need_reload = true
self.compacted = true
log.warn("waitdir [", self.key, "] err: ", err,
", will read the configuration again via readdir")
return false
Expand Down
4 changes: 2 additions & 2 deletions apisix/core/config_util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ end


-- fire all clean handlers added by add_clean_handler.
function _M.fire_all_clean_handlers(item)
function _M.fire_all_clean_handlers(item, is_compacted)
-- When the key is deleted, the item will be set to false.
if not item then
return
Expand All @@ -111,7 +111,7 @@ function _M.fire_all_clean_handlers(item)
end

for _, clean_handler in ipairs(item.clean_handlers) do
clean_handler.f(item)
clean_handler.f(item, is_compacted)
end

item.clean_handlers = {}
Expand Down
6 changes: 5 additions & 1 deletion apisix/upstream.lua
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@ end
_M.set = set_directly


local function release_checker(healthcheck_parent)
local function release_checker(healthcheck_parent, is_compacted)
if is_compacted then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a wrong solution and will cause the checker to never be released

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you clarify more? My changes will not release the checker only when the reason is compaction. There is still another case that can release the checkers properly:

https://github.com/shreemaan-abhishek/apisix/blob/105993f40f34768cd0a86035d01393346fff3a94/apisix/core/config_etcd.lua#L686

core.log.info("need not release checker if reload is due to etcd compaction")
return
end
local checker = healthcheck_parent.checker
core.log.info("try to release checker: ", tostring(checker))
checker:delayed_clear(3)
Expand Down
Loading