-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
MDEV-37214: CREATE OR REPLACE UESR must not drop user if auth plugin is not loaded #5191
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
base: 10.11
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11206,6 +11206,27 @@ bool mysql_create_user(THD *thd, List <LEX_USER> &list, bool handle_as_role) | |
| { | ||
| if (thd->lex->create_info.or_replace()) | ||
| { | ||
| /* | ||
| MDEV-37214: pre-validate auth plugins before the destructive DROP so | ||
| that a missing plugin does not silently drop the user without a binlog | ||
| event, causing master/replica divergence. | ||
| */ | ||
| bool plugin_error= false; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While this is a valiant effort, I doubt this could be the only reason why a CREATE OR REPLACE USER can fail. As Brandon mentioned this is a complex problem. First of all I'd like to see an explanation on why there's a doubling of the binlog entry in this case. If there still is doubling, that is. Secondly, you need to reach an agreement with the other MariaDB developers on what would the proper fix be in this case. FWIW, in MySQL, a similar issue class was solved (atomic ACL) by:
A different approach could be taken here. This is why it's best to discuss it with the reviewer(s) first, as I've suggested. I would at least make a utility function called "pre-check" and stuff all the checks you're doing here into it. I'd also explore the other ACL statements. Maybe ALTER has a similar issue? |
||
| for (USER_AUTH *auth= user_name->auth; auth; auth= auth->next) | ||
| { | ||
| if (auth->plugin.length && | ||
| !plugin_is_ready(&auth->plugin, MYSQL_AUTHENTICATION_PLUGIN)) | ||
| { | ||
| my_error(ER_PLUGIN_IS_NOT_LOADED, MYF(0), auth->plugin.str); | ||
| append_user(thd, &wrong_users, user_name); | ||
| result= true; | ||
| plugin_error= true; | ||
| break; | ||
| } | ||
| } | ||
| if (plugin_error) | ||
| continue; | ||
|
Comment on lines
+11209
to
+11228
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a potential master/replica divergence issue when The IssueThe current validation is performed inside the main loop that iterates over each user in the list. If a query like the following is executed: CREATE OR REPLACE USER u1 IDENTIFIED VIA valid_plugin, u2 IDENTIFIED VIA invalid_plugin;
As a result, Recommended SolutionTo prevent partial execution and master/replica divergence, we should pre-validate the authentication plugins for all users in the list in a separate loop at the very beginning of |
||
|
|
||
| // Drop the existing user | ||
| if (handle_grant_data(thd, tables, 1, user_name, NULL) <= 0) | ||
| { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To prevent future regressions and verify that multi-user statements do not suffer from partial execution or master/replica divergence, please add a test case covering the scenario where a valid user and an invalid user are specified in the same
CREATE OR REPLACE USERstatement.For example:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please describe what is this testing exactly? I do not see replication related testing done in this file.
Please consider adding a test that either checks the full scenario: