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

*: avoid some unnecessary call of ensureActiveUser() #57388

Merged
merged 6 commits into from
Dec 17, 2024

Conversation

tiancaiamao
Copy link
Contributor

@tiancaiamao tiancaiamao commented Nov 14, 2024

What problem does this PR solve?

Issue Number: ref #55563

Problem Summary:

What changed and how does it work?

In #57042, I add too much calls of ensureActiveUser() than necessary. That's introduced to make the CI pass.
That PR had already done a lot to make the CI pass .... So I don't like to introduce extra complexity to it.

After merge that, this commit will be used to reduce some unnecessary ensureActiveUser().

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)

For example

Without optimizing the unnecessary ensureActiveUser(), If I use set password for user%d to change password for 2M users, here is the QPS

image

After the optimization:

image

  • No need to test
    • I checked and no code files have been changed.

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None

@ti-chi-bot ti-chi-bot bot added release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Nov 14, 2024
Copy link

tiprow bot commented Nov 14, 2024

Hi @tiancaiamao. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

I understand the commands that are listed here.

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 kubernetes-sigs/prow repository.

@tiancaiamao tiancaiamao requested a review from bb7133 November 14, 2024 09:40
Copy link

codecov bot commented Nov 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 73.9749%. Comparing base (2a1f646) to head (b4eb956).
Report is 67 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #57388        +/-   ##
================================================
+ Coverage   73.2116%   73.9749%   +0.7633%     
================================================
  Files          1675       1683         +8     
  Lines        461921     466624      +4703     
================================================
+ Hits         338180     345185      +7005     
+ Misses       102981     100655      -2326     
- Partials      20760      20784        +24     
Flag Coverage Δ
integration 43.4518% <75.0000%> (?)
unit 72.6505% <100.0000%> (+0.3056%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 52.6910% <ø> (ø)
parser ∅ <ø> (∅)
br 46.0664% <ø> (+0.0725%) ⬆️

Comment on lines 166 to 171
drop user if exists 'testflush'@'localhost';
CREATE USER 'testflush'@'localhost' IDENTIFIED BY '';
SHOW GRANTS FOR 'testflush'@'localhost';
UPDATE mysql.User SET Select_priv='Y' WHERE User="testflush" and Host="localhost";
connect (conn1, localhost, testflush,,);
--error 1142
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a behavior change.
In the past, all the user data are in-memory, and login will not trigger reload.
Now login will trigger the reload if the user is not loaded, login make the user get the latest privileges.

To test the old behavior, SHOW GRANTS FOR 'testflush'@'localhost'; this line is added.
This cause the user data been loaded
Then login find the user and does not trigger reload.

@tiancaiamao tiancaiamao requested review from lcwangchao and removed request for Defined2014 December 12, 2024 02:18
pkg/executor/simple.go Show resolved Hide resolved
pkg/privilege/privileges/privileges.go Outdated Show resolved Hide resolved
@ti-chi-bot ti-chi-bot bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Dec 13, 2024
@tiancaiamao
Copy link
Contributor Author

/retest

Copy link

tiprow bot commented Dec 13, 2024

@tiancaiamao: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest

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 kubernetes-sigs/prow repository.

@@ -1845,7 +1847,6 @@ func (e *ShowExec) fetchShowCreateUser(ctx context.Context) error {
require = privValue.RequireStr()
}

authData := checker.GetEncodedPassword(ctx, e.User.Username, e.User.Hostname)
Copy link
Member

Choose a reason for hiding this comment

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

I don't quite get why we don't need ensureActiveUser() in fetchShowCreateUser and other functions. Could you please explain it a little bit, and how can we be sure the correctness can be verified?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

show create user is not show grants for user
We just need the command for creating that user, we do not need to assign any privileges to the user. @bb7133

@@ -1795,10 +1795,6 @@ func (e *SimpleExec) executeAlterUser(ctx context.Context, s *ast.AlterUserStmt)
failedUsers = append(failedUsers, user)
continue
}
currentAuthPlugin, err := privilege.GetPrivilegeManager(e.Ctx()).GetAuthPlugin(ctx, spec.User.Username, spec.User.Hostname)
Copy link
Member

Choose a reason for hiding this comment

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

ditto

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The authPlugin and authentication data is obtained by the ExecInternalSQL , read from the mysql.user.

@tiancaiamao tiancaiamao requested a review from bb7133 December 16, 2024 07:26
Copy link
Member

@bb7133 bb7133 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 bot added the lgtm label Dec 16, 2024
Copy link

ti-chi-bot bot commented Dec 16, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: bb7133, lcwangchao

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

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot removed the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Dec 16, 2024
Copy link

ti-chi-bot bot commented Dec 16, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-12-13 02:57:53.281540119 +0000 UTC m=+580063.370342657: ☑️ agreed by lcwangchao.
  • 2024-12-16 14:33:12.666216164 +0000 UTC m=+880982.755018708: ☑️ agreed by bb7133.

Copy link

tiprow bot commented Dec 16, 2024

@tiancaiamao: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
fast_test_tiprow b4eb956 link true /test fast_test_tiprow

Full PR test history. Your PR dashboard.

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 kubernetes-sigs/prow repository. I understand the commands that are listed here.

Copy link

ti-chi-bot bot commented Dec 16, 2024

@tiancaiamao: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-unit-test-ddlv1 8f13e5a link true /test pull-unit-test-ddlv1

Full PR test history. Your PR dashboard.

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 kubernetes-sigs/prow repository. I understand the commands that are listed here.

@tiancaiamao
Copy link
Contributor Author

/retest

Copy link

tiprow bot commented Dec 17, 2024

@tiancaiamao: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest

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 kubernetes-sigs/prow repository.

@ti-chi-bot ti-chi-bot bot merged commit c8ba4e3 into pingcap:master Dec 17, 2024
23 of 24 checks passed
@tiancaiamao tiancaiamao deleted the avoid-ensure branch December 17, 2024 03:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants