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

chore: catch error while new healthcheck instance #3213

Merged
merged 1 commit into from
Jan 11, 2021

Conversation

dabue
Copy link
Contributor

@dabue dabue commented Jan 7, 2021

What this PR does / why we need it:

catch error while new healthcheck instance and return the checker with nil.

the function pick_server will treat the nodes as normal with the 'checker == nil', and get a correct one by rules.

fix #3169

Pre-submission checklist:

  • Did you explain what problem does this PR solve? Or what new features have been added?
  • Have you added corresponding test cases?
  • Have you modified the corresponding document?
  • Is this PR backward compatible? If it is not backward compatible, please discuss on the mailing list first

@@ -87,12 +87,17 @@ local function create_checker(upstream, healthcheck_parent)
if healthcheck == nil then
healthcheck = require("resty.healthcheck")
end
local checker = healthcheck.new({
local checker, err = healthcheck.new({
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 write a test for it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I remember that error happened when more workers tried to create checkers at the same moment. In the PROD, I have encountered such problems. I will consider how to add test cases, but I think it's a bit difficult :(

Copy link
Member

Choose a reason for hiding this comment

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

OK

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can't find a way to reproduce it by using Test::Nginx. In my test case, I've set master_on,workers(10) and added a server on different port, I create many threads to connect that server when got the initial request, and wanted the different workers would handled that connections, but only the same worker which got the initial request dealt with the connection requests.

@membphis @spacewander Do you have a way to get test requests on different workers?

Copy link
Member

Choose a reason for hiding this comment

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

AFAIK, there is no such a way.

@membphis membphis merged commit 1727429 into apache:master Jan 11, 2021
sysulq pushed a commit to sysulq/apisix that referenced this pull request Jan 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

chore: cache the error message when create new healthcheck instance
3 participants