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: etcd data sync exception #8493

Merged
merged 2 commits into from
Mar 21, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions apisix/core/config_util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ end

-- fire all clean handlers added by add_clean_handler.
function _M.fire_all_clean_handlers(item)
-- When the key is deleted, the item will be set to false.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

When the key is deleted, the item will be set to false.

if not item then
return
end
if not item.clean_handlers then
return
end
Expand Down
8 changes: 8 additions & 0 deletions t/core/config_util.t
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ __DATA__
return item, idx1, idx2
end

local function setup_to_false()
local item = false
return item
end

local item, idx1, idx2 = setup()
util.cancel_clean_handler(item, idx1, true)
util.cancel_clean_handler(item, idx2, true)
Expand All @@ -103,6 +108,9 @@ __DATA__
local item, idx1, idx2 = setup()
util.cancel_clean_handler(item, idx1)
util.fire_all_clean_handlers(item)

local item = setup_to_false()
util.fire_all_clean_handlers(item)
Copy link
Member

Choose a reason for hiding this comment

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

Is it possible to test this bug by deleting a key as you described in the issue? It would be great if we could cover it via an integration test which is more readable.

}
}
--- grep_error_log eval
Expand Down