Aria/MyISAM cleanup

Include calculation of Aria index size based of *.MAI files.

Use find -0 | xargs -0 to allow for space containing names.
Quote datadir in find in case it had spaces.

Use xargs -r (GNU extension) (supported Linux, FreeBSD, OpenBSD,
NetBSD, not Solaris, not OSX) to not run if there's no files that match.
This prevents it running the total of the current directory if
there are no M[YA]I files.

A total size of 0 for Aria or MyISAM indexes isn't a problem
because:
* MySQL-5.[567] used MyISAM system tables which have indexes, so 0
wasn't possible (except for remote user without mysql.* access).
* 0 size of index is equally likely to be 0 tables of this type
  (e.g. MySQL-8.0, or MariaDB-10.4+ (Aria default, not MyISAM)).

Setting total_aria_indexes=1 when it was previously 0 is misleading.

Aria was never called AriaDB despite the apparent convention in
other storage engines so use just Aria, or Aria Storage Engine
in messages.

Differentiate between Aria not available and disabled in report.
This commit is contained in:
Daniel Black 2021-01-27 15:09:41 +11:00
parent 9a9ff555ee
commit 99e5c83779

View file

@ -403,7 +403,7 @@ sub pretty_uptime {
}
# Retrieves the memory installed on this machine
my ( $physical_memory, $swap_memory, $duflags );
my ( $physical_memory, $swap_memory, $duflags, $xargsflags );
sub memerror {
badprint
@ -414,6 +414,7 @@ sub memerror {
sub os_setup {
my $os = `uname`;
$duflags = ( $os =~ /Linux/ ) ? '-b' : '';
$xargsflags = ( $os =~ /Darwin|SunOS/ ) ? '' : '-r';
if ( $opt{'forcemem'} > 0 ) {
$physical_memory = $opt{'forcemem'} * 1048576;
infoprint "Assuming $opt{'forcemem'} MB of physical memory";
@ -2562,9 +2563,12 @@ sub calculations {
my $size = 0;
$size += (split)[0]
for
`find $myvar{'datadir'} -name "*.MYI" 2>&1 | xargs du -L $duflags 2>&1`;
`find "$myvar{'datadir'}" -name "*.MYI" -print0 2>&1 | xargs $xargsflags -0 du -L $duflags 2>&1`;
$mycalc{'total_myisam_indexes'} = $size;
$mycalc{'total_aria_indexes'} = 0;
$size = 0 + (split)[0]
for
`find "$myvar{'datadir'}" -name "*.MAI" -print0 2>&1 | xargs $xargsflags -0 du -L $duflags 2>&1`;
$mycalc{'total_aria_indexes'} = $size;
}
elsif ( mysql_version_ge(5) ) {
$mycalc{'total_myisam_indexes'} = select_one
@ -2572,20 +2576,10 @@ sub calculations {
$mycalc{'total_aria_indexes'} = select_one
"SELECT IFNULL(SUM(INDEX_LENGTH),0) FROM information_schema.TABLES WHERE TABLE_SCHEMA NOT IN ('information_schema') AND ENGINE = 'Aria';";
}
if ( defined $mycalc{'total_myisam_indexes'}
and $mycalc{'total_myisam_indexes'} == 0 )
{
$mycalc{'total_myisam_indexes'} = "fail";
}
elsif ( defined $mycalc{'total_myisam_indexes'} ) {
if ( defined $mycalc{'total_myisam_indexes'} ) {
chomp( $mycalc{'total_myisam_indexes'} );
}
if ( defined $mycalc{'total_aria_indexes'}
and $mycalc{'total_aria_indexes'} == 0 )
{
$mycalc{'total_aria_indexes'} = 1;
}
elsif ( defined $mycalc{'total_aria_indexes'} ) {
if ( defined $mycalc{'total_aria_indexes'} ) {
chomp( $mycalc{'total_aria_indexes'} );
}
@ -3390,19 +3384,11 @@ sub mysql_myisam {
}
# Key buffer
if ( !defined( $mycalc{'total_myisam_indexes'} ) and $doremote == 1 ) {
if ( !defined( $mycalc{'total_myisam_indexes'} ) ) {
push( @generalrec,
"Unable to calculate MyISAM indexes on remote MySQL server < 5.0.0"
"Unable to calculate MyISAM index size on MySQL server < 5.0.0"
);
}
elsif ( $mycalc{'total_myisam_indexes'} =~ /^fail$/ ) {
badprint
"Cannot calculate MyISAM index size - re-run script as root user";
}
elsif ( $mycalc{'total_myisam_indexes'} == "0" ) {
badprint
"None of your MyISAM tables are indexed - add indexes immediately";
}
else {
if ( $myvar{'key_buffer_size'} < $mycalc{'total_myisam_indexes'}
&& $mycalc{'pct_keys_from_mem'} < 95 )
@ -5032,31 +5018,27 @@ sub mysqsl_pfs {
}
# Recommendations for Ariadb
sub mariadb_ariadb {
subheaderprint "AriaDB Metrics";
# Recommendations for Aria Engine
sub mariadb_aria {
subheaderprint "Aria Metrics";
# AriaDB
unless ( defined $myvar{'have_aria'}
and $myvar{'have_aria'} eq "YES" )
# Aria
if ( ! defined $myvar{'have_aria'} )
{
infoprint "AriaDB is disabled.";
infoprint "Aria Storage Engine not available.";
return;
}
infoprint "AriaDB is enabled.";
if ( $myvar{'have_aria'} ne "YES" )
{
infoprint "Aria Storage Engine is disabled.";
return;
}
infoprint "Aria Storage Engine is enabled.";
# Aria pagecache
if ( !defined( $mycalc{'total_aria_indexes'} ) and $doremote == 1 ) {
if ( !defined( $mycalc{'total_aria_indexes'} ) ) {
push( @generalrec,
"Unable to calculate Aria indexes on remote MySQL server < 5.0.0" );
}
elsif ( $mycalc{'total_aria_indexes'} =~ /^fail$/ ) {
badprint
"Cannot calculate Aria index size - re-run script as root user";
}
elsif ( $mycalc{'total_aria_indexes'} == "0" ) {
badprint
"None of your Aria tables are indexed - add indexes immediately";
"Unable to calculate Aria index size on MySQL server" );
}
else {
if (
@ -6389,7 +6371,7 @@ mysqsl_pfs; # Print Performance schema info
mariadb_threadpool; # Print MariaDB ThreadPool stats
mysql_myisam; # Print MyISAM stats
mysql_innodb; # Print InnoDB stats
mariadb_ariadb; # Print MariaDB AriaDB stats
mariadb_aria; # Print MariaDB Aria stats
mariadb_tokudb; # Print MariaDB Tokudb stats
mariadb_xtradb; # Print MariaDB XtraDB stats