Skip to content

Commit f808f73

Browse files
authored
Merge branch 'master' into feature/cpu-aware-innodb-instances
2 parents 2ca8f79 + dabb226 commit f808f73

File tree

1 file changed

+74
-63
lines changed

1 file changed

+74
-63
lines changed

mysqltuner.pl

Lines changed: 74 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -2253,10 +2253,6 @@ sub security_recommendations {
22532253
subheaderprint "Security Recommendations";
22542254

22552255
infoprint "$myvar{'version_comment'} - $myvar{'version'}";
2256-
if ( mysql_version_ge(8.0) ) {
2257-
infoprint "Skipped due to unsupported feature for MySQL 8.0+";
2258-
return;
2259-
}
22602256

22612257
#exit 0;
22622258
if ( $opt{skippassword} eq 1 ) {
@@ -2377,15 +2373,17 @@ sub security_recommendations {
23772373
}
23782374

23792375
# Looking for User with user/ uppercase /capitalise user as password
2380-
@mysqlstatlist = select_array
2376+
if ( !mysql_version_ge(8) ) {
2377+
@mysqlstatlist = select_array
23812378
"SELECT CONCAT(QUOTE(user), '\@', QUOTE(host)) FROM mysql.user WHERE user != '' AND (CAST($PASS_COLUMN_NAME as Binary) = PASSWORD(user) OR CAST($PASS_COLUMN_NAME as Binary) = PASSWORD(UPPER(user)) OR CAST($PASS_COLUMN_NAME as Binary) = PASSWORD(CONCAT(UPPER(LEFT(User, 1)), SUBSTRING(User, 2, LENGTH(User)))))";
2382-
if (@mysqlstatlist) {
2383-
foreach my $line ( sort @mysqlstatlist ) {
2384-
chomp($line);
2385-
badprint "User " . $line . " has user name as password.";
2386-
push( @generalrec,
2379+
if (@mysqlstatlist) {
2380+
foreach my $line ( sort @mysqlstatlist ) {
2381+
chomp($line);
2382+
badprint "User " . $line . " has user name as password.";
2383+
push( @generalrec,
23872384
"Set up a Secure Password for $line user: SET PASSWORD FOR $line = PASSWORD('secure_password');"
2388-
);
2385+
);
2386+
}
23892387
}
23902388
}
23912389

@@ -2419,44 +2417,46 @@ sub security_recommendations {
24192417
my $nbins = 0;
24202418
my $passreq;
24212419
if (@passwords) {
2422-
my $nbInterPass = 0;
2423-
foreach my $pass (@passwords) {
2424-
$nbInterPass++;
2425-
2426-
$pass =~ s/\s//g;
2427-
$pass =~ s/\'/\\\'/g;
2428-
chomp($pass);
2429-
2430-
# Looking for User with user/ uppercase /capitalise weak password
2431-
@mysqlstatlist =
2432-
select_array
2420+
if ( !mysql_version_ge(8) ) {
2421+
my $nbInterPass = 0;
2422+
foreach my $pass (@passwords) {
2423+
$nbInterPass++;
2424+
2425+
$pass =~ s/\s//g;
2426+
$pass =~ s/\'/\\\'/g;
2427+
chomp($pass);
2428+
2429+
# Looking for User with user/ uppercase /capitalise weak password
2430+
@mysqlstatlist =
2431+
select_array
24332432
"SELECT CONCAT(user, '\@', host) FROM mysql.user WHERE $PASS_COLUMN_NAME = PASSWORD('"
2434-
. $pass
2435-
. "') OR $PASS_COLUMN_NAME = PASSWORD(UPPER('"
2436-
. $pass
2437-
. "')) OR $PASS_COLUMN_NAME = PASSWORD(CONCAT(UPPER(LEFT('"
2438-
. $pass
2439-
. "', 1)), SUBSTRING('"
2440-
. $pass
2441-
. "', 2, LENGTH('"
2442-
. $pass . "'))))";
2443-
debugprint "There are " . scalar(@mysqlstatlist) . " items.";
2444-
if (@mysqlstatlist) {
2445-
foreach my $line (@mysqlstatlist) {
2446-
chomp($line);
2447-
badprint "User '" . $line
2448-
. "' is using weak password: $pass in a lower, upper or capitalize derivative version.";
2433+
. $pass
2434+
. "') OR $PASS_COLUMN_NAME = PASSWORD(UPPER('"
2435+
. $pass
2436+
. "')) OR $PASS_COLUMN_NAME = PASSWORD(CONCAT(UPPER(LEFT('"
2437+
. $pass
2438+
. "', 1)), SUBSTRING('"
2439+
. $pass
2440+
. "', 2, LENGTH('"
2441+
. $pass . "'))))";
2442+
debugprint "There are " . scalar(@mysqlstatlist) . " items.";
2443+
if (@mysqlstatlist) {
2444+
foreach my $line (@mysqlstatlist) {
2445+
chomp($line);
2446+
badprint "User '" . $line
2447+
. "' is using weak password: $pass in a lower, upper or capitalize derivative version.";
24492448

2450-
push( @generalrec,
2449+
push( @generalrec,
24512450
"Set up a Secure Password for $line user: SET PASSWORD FOR '"
2452-
. ( split /@/, $line )[0] . "'\@'"
2453-
. ( split /@/, $line )[1]
2454-
. "' = PASSWORD('secure_password');" );
2455-
$nbins++;
2451+
. ( split /@/, $line )[0] . "'\@'"
2452+
. ( split /@/, $line )[1]
2453+
. "' = PASSWORD('secure_password');" );
2454+
$nbins++;
2455+
}
24562456
}
2457+
debugprint "$nbInterPass / " . scalar(@passwords)
2458+
if ( $nbInterPass % 1000 == 0 );
24572459
}
2458-
debugprint "$nbInterPass / " . scalar(@passwords)
2459-
if ( $nbInterPass % 1000 == 0 );
24602460
}
24612461
}
24622462
if ( $nbins > 0 ) {
@@ -5996,9 +5996,7 @@ sub trim {
59965996
sub get_wsrep_options {
59975997
return () unless defined $myvar{'wsrep_provider_options'};
59985998

5999-
my @galera_options = split /;/, $myvar{'wsrep_provider_options'};
6000-
my $wsrep_slave_threads = $myvar{'wsrep_slave_threads'};
6001-
push @galera_options, ' wsrep_slave_threads = ' . $wsrep_slave_threads;
5999+
my @galera_options = split /;/, $myvar{'wsrep_provider_options'};
60026000
@galera_options = remove_cr @galera_options;
60036001
@galera_options = remove_empty @galera_options;
60046002

@@ -6176,25 +6174,33 @@ sub mariadb_galera {
61766174
. hr_bytes_rnd( get_wsrep_option('gcache.mem_size') );
61776175

61786176
infoprint "CPU cores detected : " . (cpu_cores);
6179-
infoprint "wsrep_slave_threads: " . get_wsrep_option('wsrep_slave_threads');
6177+
my $wsrep_threads_var_name = 'wsrep_slave_threads';
6178+
if ( defined( $myvar{'wsrep_applier_threads'} ) ) {
6179+
$wsrep_threads_var_name = 'wsrep_applier_threads';
6180+
}
6181+
# Use 1 as a fallback if $myvar{$wsrep_threads_var_name} is undefined or zero,
6182+
# to ensure there is at least one thread for Galera replication.
6183+
my $wsrep_threads_value = $myvar{$wsrep_threads_var_name} || 1;
61806184

6181-
if ( get_wsrep_option('wsrep_slave_threads') > ( (cpu_cores) * 4 )
6182-
or get_wsrep_option('wsrep_slave_threads') < ( (cpu_cores) * 2 ) )
6185+
infoprint "$wsrep_threads_var_name: " . $wsrep_threads_value;
6186+
6187+
if ( $wsrep_threads_value > ( (cpu_cores) * 4 )
6188+
or $wsrep_threads_value < ( (cpu_cores) * 2 ) )
61836189
{
61846190
badprint
6185-
"wsrep_slave_threads is not equal to 2, 3 or 4 times the number of CPU(s)";
6186-
push @adjvars, "wsrep_slave_threads = " . ( (cpu_cores) * 4 );
6191+
"$wsrep_threads_var_name is not equal to 2, 3 or 4 times the number of CPU(s)";
6192+
push @adjvars, "$wsrep_threads_var_name = " . ( (cpu_cores) * 4 );
61876193
}
61886194
else {
61896195
goodprint
6190-
"wsrep_slave_threads is equal to 2, 3 or 4 times the number of CPU(s)";
6196+
"$wsrep_threads_var_name is equal to 2, 3 or 4 times the number of CPU(s)";
61916197
}
61926198

6193-
if ( get_wsrep_option('wsrep_slave_threads') > 1 ) {
6199+
if ( $wsrep_threads_value > 1 ) {
61946200
infoprint
61956201
"wsrep parallel slave can cause frequent inconsistency crash.";
61966202
push @adjvars,
6197-
"Set wsrep_slave_threads to 1 in case of HA_ERR_FOUND_DUPP_KEY crash on slave";
6203+
"Set $wsrep_threads_var_name to 1 in case of HA_ERR_FOUND_DUPP_KEY crash on slave";
61986204

61996205
# check options for parallel slave
62006206
if ( get_wsrep_option('wsrep_slave_FK_checks') eq "OFF" ) {
@@ -6212,15 +6218,15 @@ sub mariadb_galera {
62126218
}
62136219
}
62146220

6215-
if ( get_wsrep_option('gcs.fc_limit') != $myvar{'wsrep_slave_threads'} * 5 )
6216-
{
6217-
badprint "gcs.fc_limit should be equal to 5 * wsrep_slave_threads (="
6218-
. ( $myvar{'wsrep_slave_threads'} * 5 ) . ")";
6219-
push @adjvars, "gcs.fc_limit= wsrep_slave_threads * 5 (="
6220-
. ( $myvar{'wsrep_slave_threads'} * 5 ) . ")";
6221+
if ( get_wsrep_option('gcs.fc_limit') != $wsrep_threads_value * 5 ) {
6222+
badprint
6223+
"gcs.fc_limit should be equal to 5 * $wsrep_threads_var_name (="
6224+
. ( $wsrep_threads_value * 5 ) . ")";
6225+
push @adjvars, "gcs.fc_limit= $wsrep_threads_var_name * 5 (="
6226+
. ( $wsrep_threads_value * 5 ) . ")";
62216227
}
62226228
else {
6223-
goodprint "gcs.fc_limit is equal to 5 * wsrep_slave_threads ( ="
6229+
goodprint "gcs.fc_limit is equal to 5 * $wsrep_threads_var_name ( ="
62246230
. get_wsrep_option('gcs.fc_limit') . ")";
62256231
}
62266232

@@ -6255,7 +6261,12 @@ sub mariadb_galera {
62556261
goodprint "InnoDB flush log at each commit is disabled for Galera.";
62566262
}
62576263

6258-
infoprint "Read consistency mode :" . $myvar{'wsrep_causal_reads'};
6264+
if ( defined $myvar{'wsrep_causal_reads'} and $myvar{'wsrep_causal_reads'} ne '' ) {
6265+
infoprint "Read consistency mode :" . $myvar{'wsrep_causal_reads'};
6266+
}
6267+
elsif ( defined $myvar{'wsrep_sync_wait'} ) {
6268+
infoprint "Sync Wait mode : " . $myvar{'wsrep_sync_wait'};
6269+
}
62596270

62606271
if ( defined( $myvar{'wsrep_cluster_name'} )
62616272
and $myvar{'wsrep_on'} eq "ON" )

0 commit comments

Comments
 (0)