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: keep healthcheck target state when upstream changes #10312

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion apisix/core/config_util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ function _M.fire_all_clean_handlers(item)
clean_handler.f(item)
end

item.clean_handlers = nil
item.clean_handlers = {}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

if the clean_handler is put into the parents (routers), it will cause error like this:

2023/10/10 20:53:16 [error] 1057074#1057074: *2020 lua entry thread aborted: runtime error: /home/liuwei/api7/apisix/apisix/core/config_util.lua:61: attempt to index field 'clean_handlers' (a nil value)
stack traceback:
coroutine 0:
	/home/liuwei/api7/apisix/apisix/core/config_util.lua: in function 'add_clean_handler'
	/home/liuwei/api7/apisix/apisix/upstream.lua:152: in function 'fetch_healthchecker'
	/home/liuwei/api7/apisix/apisix/upstream.lua:342: in function 'set_upstream'
	/home/liuwei/api7/apisix/apisix/init.lua:549: in function 'handle_upstream'
	/home/liuwei/api7/apisix/apisix/init.lua:730: in function 'http_access_phase'

end


Expand Down
2 changes: 1 addition & 1 deletion apisix/upstream.lua
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ _M.set = set_directly
local function release_checker(healthcheck_parent)
local checker = healthcheck_parent.checker
core.log.info("try to release checker: ", tostring(checker))
checker:clear()
checker:delayed_clear(3)
checker:stop()
end

Expand Down
4 changes: 2 additions & 2 deletions t/node/healthcheck-leak-bugfix.t
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ __DATA__
local new = healthcheck.new
healthcheck.new = function(...)
local obj = new(...)
local clear = obj.clear
obj.clear = function(...)
local clear = obj.delayed_clear
obj.delayed_clear = function(...)
ngx.log(ngx.WARN, "clear checker")
return clear(...)
end
Expand Down