yoshinorim / mha4mysql-manager

Development tree of Master High Availability Manager and tools for MySQL (MHA), Manager part
http://code.google.com/p/mysql-master-ha/
GNU General Public License v2.0
1.46k stars 501 forks source link

Perl 5.24.1: Redundant argument in sprintf at /usr/local/share/perl/5.24.1/MHA/NodeUtil.pm line 195 #116

Open Cugar15 opened 5 years ago

Cugar15 commented 5 years ago

With Perl 5.24.1 in NodeUtil.pl the following error occurs:

masterha_check_repl --conf=/etc/mha/app1.cnf

Fri Nov  9 10:28:01 2018 - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping.
Fri Nov  9 10:28:01 2018 - [info] Reading application default configuration from /etc/mha/app1.cnf..
Fri Nov  9 10:28:01 2018 - [info] Reading server configuration from /etc/mha/app1.cnf..
Fri Nov  9 10:28:01 2018 - [info] MHA::MasterMonitor version 0.58.
Fri Nov  9 10:28:03 2018 - [error][/usr/local/share/perl/5.24.1/MHA/MasterMonitor.pm, ln427] Error happened on checking configurations. Redundant argument in sprintf at /usr/local/share/perl/5.24.1/MHA/NodeUtil.pm line 195.
Fri Nov  9 10:28:03 2018 - [error][/usr/local/share/perl/5.24.1/MHA/MasterMonitor.pm, ln525] Error happened on monitoring servers.
Fri Nov  9 10:28:03 2018 - [info] Got exit code 1 (Not master dead).

The problem is the mysql version string which is: 5.7.22-ndb-7.6.6-log and the strict assignment of

sub parse_mysql_version($) {
  my $str = shift;
  my $result = sprintf( '%03d%03d%03d', $str =~ m/(\d+)/g );    <-----
  return $result;
}

A possible solution is to cut everything in the version string past the "-" like:

sub parse_mysql_version($) {
  my $str = shift;
 ($str) =  $str =~ m/^[^-]*/g;
  my $result = sprintf( '%03d%03d%03d', $str =~ m/(\d+)/g );
  return $result;
}

A better regex wizzard than me can probably do this much slicker :)

The overall question is: Are there more of these occurrences and how can they be found?

Cheers

qiukeren commented 3 years ago

need help +1 here

qiukeren commented 3 years ago

what plus here is parse_mysql_major_version still have same issue,so we can change here:

sub parse_mysql_major_version($) {
  my $str = shift;
  $str =~ /(\d+)\.(\d+)/;
  my $strmajor = "$1.$2";
  my $result = sprintf( '%03d%03d', $strmajor =~ m/(\d+)/g );
  return $result;
}
frankgululu commented 3 years ago

I have same issue after changed all mha node and master

vfzh commented 2 years ago

thanks for your answer~

KAispread commented 7 months ago

Thanks for your comment!!😀