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

sessionctx, variable: add skip name resolve #25464

Merged
merged 4 commits into from
Jun 22, 2021

Conversation

morgo
Copy link
Contributor

@morgo morgo commented Jun 15, 2021

What problem does this PR solve?

Issue Number: close #9778

Problem Summary:

I was investigating linter issues, when I noticed that the silencing of the error in getHostByIP might not be completely correct. If the reverse lookup fails (net.LookupAddr) - is the original IP returned? I expect this behavior is undefined, so authentication might fail when it doesn't need to.

Then I was wondering why there is no method to skip name resolution like there is in MySQL, since it is a common problem in large scale systems. There has been a feature request @ #9778

In MySQL skip-name-resolve is non-dynamic, but this does not make so much sense for TiDB, so I've changed it to GLOBAL-only scope.

I also don't think it is correct to silently drop errors from name resolution (although the fact that they were previously noisy and this was fixed in #13989 indicates that skip-name resolve as a feature has merit). My resolution was to reintroduce an error message, but switch it to debug level.

What is changed and how it works?

What's Changed:

Support has been added for skip-name-resolve.

Related changes

  • PR to update pingcap/docs/pingcap/docs-cn:
  • Need to cherry-pick to the release branch

Check List

Tests

  • Manual test (add detailed scripts or steps below)

Side effects

  • Increased code complexity

Release note

  • Support has been added for skip-name-resolve.

@morgo morgo requested a review from tiancaiamao June 15, 2021 22:23
@ti-chi-bot ti-chi-bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Jun 15, 2021
@morgo morgo added sig/sql-infra SIG: SQL Infra size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jun 15, 2021
Copy link
Contributor

@xhebox xhebox left a comment

Choose a reason for hiding this comment

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

LGTM

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Jun 17, 2021
if ip == "127.0.0.1" {
return []string{variable.DefHostname}
}
skipNameResolve, err := s.GetSessionVars().GlobalVarsAccessor.GetGlobalSysVar(variable.SkipNameResolve)
if err == nil && variable.TiDBOptOn(skipNameResolve) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Are you intended to continue even when err != nil?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. The option defaults to OFF (and always will). It's only if can be successfully read as ON that we take the short-path and return the IP address. See: https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_skip_name_resolve

@ti-chi-bot
Copy link
Member

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • tiancaiamao
  • xhebox

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Jun 18, 2021
@tiancaiamao
Copy link
Contributor

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: a32bcfe

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Jun 22, 2021
@ti-chi-bot
Copy link
Member

@morgo: Your PR was out of date, I have automatically updated it for you.

At the same time I will also trigger all tests for you:

/run-all-tests

If the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

@ti-chi-bot ti-chi-bot merged commit 851fb3c into pingcap:master Jun 22, 2021
@morgo morgo deleted the add-skip-name-resolve branch June 23, 2021 19:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/sql-infra SIG: SQL Infra size/S Denotes a PR that changes 10-29 lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

support skip-name-resolve
5 participants