mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-12 14:18:32 +00:00
PT-2015 Fix pt-config-diff not sorting flags
Previously, flags would be compared in the exact order they are output by MySQL, which can result in false negatives if the input ordering does not match. Example from the ticket: ``` [root@avvr-dbm51 ~]# pt-config-diff /etc/my.cnf h=localhost,P=3047 1 config difference Variable /etc/my.cnf avvr-dbm51 ========================= ============ ============ myisam_recover_options FORCE,BACKUP BACKUP,FORCE ``` This commit fixes the issue by sorting the flags before comparison to ensure that any ordering differences will not report a diff. Co-authored-by: Jonathan Gnagy <jonathan@therubyist.org>
This commit is contained in:
@@ -3701,6 +3701,10 @@ sub _normalize_value {
|
|||||||
$val = defined $val ? $val : '';
|
$val = defined $val ? $val : '';
|
||||||
$val = $alt_val_for{$val} if exists $alt_val_for{$val};
|
$val = $alt_val_for{$val} if exists $alt_val_for{$val};
|
||||||
|
|
||||||
|
if ( $val =~ m/,/ && !$is_dir && !$base_path) {
|
||||||
|
$val = join(',', sort(split(',', $val)));
|
||||||
|
}
|
||||||
|
|
||||||
if ( $val ) {
|
if ( $val ) {
|
||||||
if ( $is_dir ) {
|
if ( $is_dir ) {
|
||||||
$val .= '/' unless $val =~ m/\/$/;
|
$val .= '/' unless $val =~ m/\/$/;
|
||||||
|
@@ -295,6 +295,10 @@ sub _normalize_value {
|
|||||||
$val = defined $val ? $val : '';
|
$val = defined $val ? $val : '';
|
||||||
$val = $alt_val_for{$val} if exists $alt_val_for{$val};
|
$val = $alt_val_for{$val} if exists $alt_val_for{$val};
|
||||||
|
|
||||||
|
if ( $val =~ m/,/ && !$is_dir && !$base_path) {
|
||||||
|
$val = join(',', sort(split(',', $val)));
|
||||||
|
}
|
||||||
|
|
||||||
if ( $val ) {
|
if ( $val ) {
|
||||||
if ( $is_dir ) {
|
if ( $is_dir ) {
|
||||||
$val .= '/' unless $val =~ m/\/$/;
|
$val .= '/' unless $val =~ m/\/$/;
|
||||||
|
@@ -369,6 +369,30 @@ $c2 = new MySQLConfig(
|
|||||||
) or print Dumper($diff);
|
) or print Dumper($diff);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# ############################################################################
|
||||||
|
# PS-2015 pt-config-diff doesn't diff ordered flags
|
||||||
|
# ############################################################################
|
||||||
|
$c1 = new MySQLConfig(
|
||||||
|
result_set => [['log_slow_verbosity', 'innodb,microtime']],
|
||||||
|
format => 'show_variables',
|
||||||
|
);
|
||||||
|
$c2 = new MySQLConfig(
|
||||||
|
result_set => [['log_slow_verbosity', 'microtime,innodb']],
|
||||||
|
format => 'show_variables',
|
||||||
|
);
|
||||||
|
|
||||||
|
{
|
||||||
|
$diff = $cc->diff(
|
||||||
|
configs => [$c1, $c2],
|
||||||
|
);
|
||||||
|
|
||||||
|
is_deeply(
|
||||||
|
$diff,
|
||||||
|
undef,
|
||||||
|
"Values are same regardless of order"
|
||||||
|
) or diag(Dumper($diff));
|
||||||
|
}
|
||||||
|
|
||||||
# ############################################################################
|
# ############################################################################
|
||||||
# https://bugs.launchpad.net/percona-toolkit/+bug/889739
|
# https://bugs.launchpad.net/percona-toolkit/+bug/889739
|
||||||
# pt-config-diff doesn't diff quoted strings properly
|
# pt-config-diff doesn't diff quoted strings properly
|
||||||
|
Reference in New Issue
Block a user