Skip to content

Commit 9b3961e

Browse files
committed
Revert "Bug #21024340: Resolved the congestion on the zeroth mutex in the"
This reverts commit f29a21a6fbd008039d42b13f189a855bad6dba3a. causes problems with replication
1 parent 20f9196 commit 9b3961e

13 files changed

+81
-220
lines changed

sql/auth/auth_internal.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@ ACL_PROXY_USER * acl_find_proxy_user(const char *user,
5858
const char *ip,
5959
char *authenticated_as,
6060
bool *proxy_used);
61-
bool set_user_salt(THD *, ACL_USER *acl_user);
61+
bool set_user_salt(ACL_USER *acl_user);
6262
void acl_insert_proxy_user(ACL_PROXY_USER *new_value);
6363

64-
void acl_update_user(THD* thd, const char *user, const char *host,
64+
void acl_update_user(const char *user, const char *host,
6565
enum SSL_type ssl_type,
6666
const char *ssl_cipher,
6767
const char *x509_issuer,
@@ -73,7 +73,7 @@ void acl_update_user(THD* thd, const char *user, const char *host,
7373
MYSQL_TIME password_change_time,
7474
LEX_ALTER password_life,
7575
ulong what_is_set);
76-
void acl_insert_user(THD *thd, const char *user, const char *host,
76+
void acl_insert_user(const char *user, const char *host,
7777
enum SSL_type ssl_type,
7878
const char *ssl_cipher,
7979
const char *x509_issuer,

sql/auth/password_policy_int.h

Lines changed: 0 additions & 22 deletions
This file was deleted.

sql/auth/password_policy_service.cc

Lines changed: 19 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -22,27 +22,24 @@
2222
#include "strfunc.h"
2323
#include "sql_string.h"
2424
#include "sql_plugin.h"
25-
#include "auth/password_policy_int.h"
2625

2726

2827
LEX_CSTRING validate_password_plugin= {
2928
C_STRING_WITH_LEN("validate_password")
3029
};
3130

32-
3331
/**
34-
Extended version of validate_password_policy()
35-
36-
Takes and extra THD argument to use when locking the plugin.
37-
Please call this as it allows scalability on the plugin mutex
38-
39-
@param thd thread to use
40-
@param password the password to check
41-
@param password_len length of password
42-
@retval 0 good password
43-
@retval 1 weak password
32+
Validate the input password based on defined policies.
33+
34+
@param password password which needs to be validated against the
35+
defined policies
36+
@param password_len length of password
37+
38+
@retval 0 ok
39+
@retval 1 ERROR;
4440
*/
45-
int my_validate_password_policy_int(THD *thd, const char *password, unsigned int password_len)
41+
42+
int my_validate_password_policy(const char *password, unsigned int password_len)
4643
{
4744
plugin_ref plugin;
4845
String password_str;
@@ -52,8 +49,8 @@ int my_validate_password_policy_int(THD *thd, const char *password, unsigned int
5249
String tmp_str(password, password_len, &my_charset_utf8_bin);
5350
password_str= tmp_str;
5451
}
55-
plugin= plugin_lock_by_name_ext(thd, validate_password_plugin,
56-
MYSQL_VALIDATE_PASSWORD_PLUGIN, FALSE);
52+
plugin= my_plugin_lock_by_name(0, validate_password_plugin,
53+
MYSQL_VALIDATE_PASSWORD_PLUGIN);
5754
if (plugin)
5855
{
5956
st_mysql_validate_password *password_validate=
@@ -62,67 +59,33 @@ int my_validate_password_policy_int(THD *thd, const char *password, unsigned int
6259
if (!password_validate->validate_password(&password_str))
6360
{
6461
my_error(ER_NOT_VALID_PASSWORD, MYF(0));
65-
plugin_unlock_ext(thd, plugin, FALSE);
62+
plugin_unlock(0, plugin);
6663
return (1);
6764
}
68-
plugin_unlock_ext(thd, plugin, FALSE);
65+
plugin_unlock(0, plugin);
6966
}
7067
return (0);
7168
}
7269

7370

74-
/**
75-
Validate the input password based on defined policies.
76-
77-
@param password password which needs to be validated against the
78-
defined policies
79-
@param password_len length of password
80-
81-
@retval 0 ok
82-
@retval 1 ERROR;
83-
*/
84-
85-
int my_validate_password_policy(const char *password, unsigned int password_len)
86-
{
87-
return my_validate_password_policy_int(NULL, password, password_len);
88-
}
89-
90-
91-
/**
92-
Extended version of calculate_password_strength()
93-
94-
Takes and extra THD argument to use when locking the plugin.
95-
Please call this as it allows scalability on the plugin mutex
96-
97-
@param thd thread to use
98-
@param password the password to check
99-
@param password_len length of password
100-
@return the password strength as returned by the plugin
101-
*/
102-
int my_calculate_password_strength_int(THD *thd, const char *password, unsigned int password_len)
71+
/* called when new user is created or exsisting password is changed */
72+
int my_calculate_password_strength(const char *password, unsigned int password_len)
10373
{
10474
int res= 0;
10575
DBUG_ASSERT(password != NULL);
10676

10777
String password_str;
10878
if (password)
10979
password_str.set(password, password_len, &my_charset_utf8_bin);
110-
plugin_ref plugin= plugin_lock_by_name_ext(thd, validate_password_plugin,
111-
MYSQL_VALIDATE_PASSWORD_PLUGIN,
112-
FALSE);
80+
plugin_ref plugin= my_plugin_lock_by_name(0, validate_password_plugin,
81+
MYSQL_VALIDATE_PASSWORD_PLUGIN);
11382
if (plugin)
11483
{
11584
st_mysql_validate_password *password_strength=
11685
(st_mysql_validate_password *) plugin_decl(plugin)->info;
11786

11887
res= password_strength->get_password_strength(&password_str);
119-
plugin_unlock_ext(thd, plugin, FALSE);
88+
plugin_unlock(0, plugin);
12089
}
12190
return(res);
12291
}
123-
124-
/* called when new user is created or exsisting password is changed */
125-
int my_calculate_password_strength(const char *password, unsigned int password_len)
126-
{
127-
return my_calculate_password_strength_int(NULL, password, password_len);
128-
}

sql/auth/sql_auth_cache.cc

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,21 +1276,21 @@ class ACL_compare :
12761276
@retval true Hash is of wrong length or format
12771277
*/
12781278

1279-
bool set_user_salt(THD *thd, ACL_USER *acl_user)
1279+
bool set_user_salt(ACL_USER *acl_user)
12801280
{
12811281
bool result= false;
12821282
plugin_ref plugin= NULL;
12831283

1284-
plugin= plugin_lock_by_name_ext(thd, acl_user->plugin,
1285-
MYSQL_AUTHENTICATION_PLUGIN, FALSE);
1284+
plugin= my_plugin_lock_by_name(0, acl_user->plugin,
1285+
MYSQL_AUTHENTICATION_PLUGIN);
12861286
if (plugin)
12871287
{
12881288
st_mysql_auth *auth= (st_mysql_auth *) plugin_decl(plugin)->info;
12891289
result= auth->set_salt(acl_user->auth_string.str,
12901290
acl_user->auth_string.length,
12911291
acl_user->salt,
12921292
&acl_user->salt_len);
1293-
plugin_unlock_ext(thd, plugin, FALSE);
1293+
plugin_unlock(0, plugin);
12941294
}
12951295
return result;
12961296
}
@@ -1643,9 +1643,9 @@ static my_bool acl_load(THD *thd, TABLE_LIST *tables)
16431643

16441644
//We only support native hash, we do not support pre 4.1 hashes
16451645
plugin_ref native_plugin= NULL;
1646-
native_plugin= plugin_lock_by_name_ext(thd,
1646+
native_plugin= my_plugin_lock_by_name(0,
16471647
native_password_plugin_name,
1648-
MYSQL_AUTHENTICATION_PLUGIN, FALSE);
1648+
MYSQL_AUTHENTICATION_PLUGIN);
16491649
if (native_plugin)
16501650
{
16511651
uint password_len= password ? strlen(password) : 0;
@@ -1674,10 +1674,10 @@ static my_bool acl_load(THD *thd, TABLE_LIST *tables)
16741674
"login with this user anymore.",
16751675
user.user ? user.user : "",
16761676
user.host.get_host() ? user.host.get_host() : "");
1677-
plugin_unlock_ext(thd, native_plugin, FALSE);
1677+
plugin_unlock(0, native_plugin);
16781678
continue;
16791679
}
1680-
plugin_unlock_ext(thd, native_plugin, FALSE);
1680+
plugin_unlock(0, native_plugin);
16811681
}
16821682
}
16831683

@@ -1718,8 +1718,8 @@ static my_bool acl_load(THD *thd, TABLE_LIST *tables)
17181718

17191719
/* Validate the hash string. */
17201720
plugin_ref plugin= NULL;
1721-
plugin= plugin_lock_by_name_ext(thd, user.plugin,
1722-
MYSQL_AUTHENTICATION_PLUGIN, FALSE);
1721+
plugin= my_plugin_lock_by_name(0, user.plugin,
1722+
MYSQL_AUTHENTICATION_PLUGIN);
17231723
if (plugin)
17241724
{
17251725
st_mysql_auth *auth= (st_mysql_auth *) plugin_decl(plugin)->info;
@@ -1729,10 +1729,10 @@ static my_bool acl_load(THD *thd, TABLE_LIST *tables)
17291729
sql_print_warning("Found invalid password for user: '%s@%s'; "
17301730
"Ignoring user", user.user ? user.user : "",
17311731
user.host.get_host() ? user.host.get_host() : "");
1732-
plugin_unlock_ext(thd, plugin, FALSE);
1732+
plugin_unlock(0, plugin);
17331733
continue;
17341734
}
1735-
plugin_unlock_ext(thd, plugin, FALSE);
1735+
plugin_unlock(0, plugin);
17361736
}
17371737

17381738
if (table->s->fields > table_schema->password_expired_idx())
@@ -1821,7 +1821,7 @@ static my_bool acl_load(THD *thd, TABLE_LIST *tables)
18211821
user.access|= SUPER_ACL | EXECUTE_ACL;
18221822
}
18231823

1824-
set_user_salt(thd, &user);
1824+
set_user_salt(&user);
18251825
user.password_expired= password_expired;
18261826

18271827
acl_users->push_back(user);
@@ -2629,7 +2629,7 @@ my_bool grant_reload(THD *thd)
26292629
}
26302630

26312631

2632-
void acl_update_user(THD *thd, const char *user, const char *host,
2632+
void acl_update_user(const char *user, const char *host,
26332633
enum SSL_type ssl_type,
26342634
const char *ssl_cipher,
26352635
const char *x509_issuer,
@@ -2671,7 +2671,7 @@ void acl_update_user(THD *thd, const char *user, const char *host,
26712671
acl_user->auth_string.str= strmake_root(&global_acl_memory,
26722672
auth.str, auth.length);
26732673
acl_user->auth_string.length= auth.length;
2674-
set_user_salt(thd, acl_user);
2674+
set_user_salt(acl_user);
26752675
acl_user->password_last_changed= password_change_time;
26762676
}
26772677
}
@@ -2723,7 +2723,7 @@ void acl_update_user(THD *thd, const char *user, const char *host,
27232723
}
27242724

27252725

2726-
void acl_insert_user(THD *thd, const char *user, const char *host,
2726+
void acl_insert_user(const char *user, const char *host,
27272727
enum SSL_type ssl_type,
27282728
const char *ssl_cipher,
27292729
const char *x509_issuer,
@@ -2790,7 +2790,7 @@ void acl_insert_user(THD *thd, const char *user, const char *host,
27902790
acl_user.password_last_changed= password_change_time;
27912791
acl_user.account_locked= password_life.account_locked;
27922792

2793-
set_user_salt(thd, &acl_user);
2793+
set_user_salt(&acl_user);
27942794

27952795
acl_users->push_back(acl_user);
27962796
if (acl_user.host.check_allow_all_hosts())

sql/auth/sql_user.cc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -460,8 +460,8 @@ bool set_and_validate_user_attributes(THD *thd,
460460
Str->plugin= default_auth_plugin_name;
461461
}
462462

463-
plugin= plugin_lock_by_name_ext(thd, Str->plugin,
464-
MYSQL_AUTHENTICATION_PLUGIN, FALSE);
463+
plugin= my_plugin_lock_by_name(0, Str->plugin,
464+
MYSQL_AUTHENTICATION_PLUGIN);
465465

466466
/* check if plugin is loaded */
467467
if (!plugin)
@@ -491,7 +491,7 @@ bool set_and_validate_user_attributes(THD *thd,
491491
thd->security_context()->priv_user().str,
492492
thd->security_context()->priv_host().str,
493493
thd->password ? ER_THD(thd, ER_YES) : ER_THD(thd, ER_NO));
494-
plugin_unlock_ext(thd, plugin, FALSE);
494+
plugin_unlock(0, plugin);
495495
return (1);
496496
}
497497
}
@@ -513,7 +513,7 @@ bool set_and_validate_user_attributes(THD *thd,
513513
push_warning(thd, Sql_condition::SL_NOTE,
514514
ER_SET_PASSWORD_AUTH_PLUGIN,
515515
warning_buffer);
516-
plugin_unlock_ext(thd, plugin, FALSE);
516+
plugin_unlock(0, plugin);
517517
what_to_set= NONE_ATTR;
518518
return (0);
519519
}
@@ -535,7 +535,7 @@ bool set_and_validate_user_attributes(THD *thd,
535535
inbuf,
536536
inbuflen))
537537
{
538-
plugin_unlock_ext(thd, plugin, FALSE);
538+
plugin_unlock(0, plugin);
539539
return(1);
540540
}
541541
if (buflen)
@@ -573,12 +573,12 @@ bool set_and_validate_user_attributes(THD *thd,
573573
Str->auth.length))
574574
{
575575
my_error(ER_PASSWORD_FORMAT, MYF(0));
576-
plugin_unlock_ext(thd, plugin, FALSE);
576+
plugin_unlock(0, plugin);
577577
return(1);
578578
}
579579
}
580580
}
581-
plugin_unlock_ext(thd, plugin, FALSE);
581+
plugin_unlock(0, plugin);
582582
return(0);
583583
}
584584

sql/auth/sql_user_table.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,7 @@ int replace_user_table(THD *thd, TABLE *table, LEX_USER *combo,
806806
password_change_time.time_type= MYSQL_TIMESTAMP_ERROR;
807807
acl_cache->clear(1); // Clear privilege cache
808808
if (old_row_exists)
809-
acl_update_user(thd, combo->user.str, combo->host.str,
809+
acl_update_user(combo->user.str, combo->host.str,
810810
lex->ssl_type,
811811
lex->ssl_cipher,
812812
lex->x509_issuer,
@@ -819,7 +819,7 @@ int replace_user_table(THD *thd, TABLE *table, LEX_USER *combo,
819819
combo->alter_status,
820820
what_to_replace);
821821
else
822-
acl_insert_user(thd, combo->user.str, combo->host.str,
822+
acl_insert_user(combo->user.str, combo->host.str,
823823
lex->ssl_type,
824824
lex->ssl_cipher,
825825
lex->x509_issuer,

sql/item_func.cc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
#include "sql_time.h" // TIME_from_longlong_packed
4444
#include "strfunc.h" // find_type
4545
#include "item_json_func.h" // Item_func_json_quote
46-
#include "auth\password_policy_int.h"
4746

4847
using std::min;
4948
using std::max;
@@ -3989,8 +3988,7 @@ longlong Item_func_validate_password_strength::val_int()
39893988
String *field= args[0]->val_str(&value);
39903989
if ((null_value= args[0]->null_value) || field->length() == 0)
39913990
return 0;
3992-
return (my_calculate_password_strength_int(current_thd,
3993-
field->ptr(), field->length()));
3991+
return (my_calculate_password_strength(field->ptr(), field->length()));
39943992
}
39953993

39963994

0 commit comments

Comments
 (0)