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

privilege: fix atomic problem of DROP ROLE #14090

Merged
merged 7 commits into from
Dec 18, 2019
Merged

Conversation

imtbkcat
Copy link

What problem does this PR solve?

TiDB has atomic problem at DROP ROLE, which can reproduce like this:

mysql [email protected]:test> select user, host from mysql.user where user in ('r1', 'r2', 'r3', 'r4');
+------+------+
| user | host |
+------+------+
0 rows in set
Time: 0.016s
mysql [email protected]:test> create role r2;
Query OK, 0 rows affected
Time: 0.004s
mysql [email protected]:test> create role r1, r2, r3
(1396, "Operation CREATE USER failed for 'r2'@'%'")
mysql [email protected]:test> select user, host from mysql.user where user in ('r1', 'r2', 'r3', 'r4');
+------+------+
| user | host |
+------+------+
| r2   | %    |
+------+------+
1 row in set
Time: 0.015s
mysql [email protected]:test> drop role 'r1', 'r2', 'r3';
(1396, 'Operation DROP USER failed for r1@%,r3@%')
mysql [email protected]:test> select user, host from mysql.user where user in ('r1', 'r2', 'r3', 'r4');
+------+------+
| user | host |
+------+------+
0 rows in set
Time: 0.012s
mysql [email protected]:test>

The problem was cause by error logic in DROP ROLE, which doesn't break loop when error occur.

What is changed and how it works?

Break the loop when drop user/role failed.

Check List

Tests

  • Unit test

Code changes

  • None

Side effects

  • Increased code complexity

Related changes

  • Need to cherry-pick to the release branch

Release note

  • fix atomic problem of DROP ROLE

@imtbkcat
Copy link
Author

/run-all-tests

@imtbkcat
Copy link
Author

/run-all-tests tidb-test=pr/966

@codecov
Copy link

codecov bot commented Dec 17, 2019

Codecov Report

❗ No coverage uploaded for pull request base (master@2cb5eb6). Click here to learn what that means.
The diff coverage is 31.0344%.

@@             Coverage Diff             @@
##             master     #14090   +/-   ##
===========================================
  Coverage          ?   80.1725%           
===========================================
  Files             ?        483           
  Lines             ?     121473           
  Branches          ?          0           
===========================================
  Hits              ?      97388           
  Misses            ?      16326           
  Partials          ?       7759

@imtbkcat
Copy link
Author

/run-all-tests tidb-test=pr/966

Copy link
Member

@jackysp jackysp left a comment

Choose a reason for hiding this comment

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

LGTM

@tiancaiamao
Copy link
Contributor

LGTM

@lysu lysu added the status/LGT2 Indicates that a PR has LGTM 2. label Dec 18, 2019
@jackysp
Copy link
Member

jackysp commented Dec 18, 2019

/merge

@sre-bot sre-bot added the status/can-merge Indicates a PR has been approved by a committer. label Dec 18, 2019
@sre-bot
Copy link
Contributor

sre-bot commented Dec 18, 2019

/run-all-tests

@sre-bot
Copy link
Contributor

sre-bot commented Dec 18, 2019

@imtbkcat merge failed.

@jackysp
Copy link
Member

jackysp commented Dec 18, 2019

/merge

@sre-bot
Copy link
Contributor

sre-bot commented Dec 18, 2019

/run-all-tests

@zyxbest
Copy link
Contributor

zyxbest commented Dec 18, 2019

/rebuild

@zyxbest
Copy link
Contributor

zyxbest commented Dec 18, 2019

/build

@zyxbest
Copy link
Contributor

zyxbest commented Dec 18, 2019

/merge

@sre-bot
Copy link
Contributor

sre-bot commented Dec 18, 2019

/run-all-tests

@sre-bot sre-bot merged commit cb37596 into pingcap:master Dec 18, 2019
@sre-bot
Copy link
Contributor

sre-bot commented Dec 18, 2019

cherry pick to release-3.0 failed

imtbkcat pushed a commit to imtbkcat/tidb that referenced this pull request Dec 19, 2019
XiaTianliang pushed a commit to XiaTianliang/tidb that referenced this pull request Dec 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/privilege status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2. type/bugfix This PR fixes a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants