From d8701a3f3edfc9bea8b1343a5b50bbf461fb3051 Mon Sep 17 00:00:00 2001 From: Brian Fraser Date: Tue, 5 Mar 2013 11:27:56 -0300 Subject: [PATCH] Fix for 1086018: pt-config-diff needs to parse wsrep_provider_options --- bin/pt-config-diff | 26 +++++++++++++++++++++++++- lib/MySQLConfig.pm | 27 ++++++++++++++++++++++++++- sandbox/start-sandbox | 2 +- 3 files changed, 52 insertions(+), 3 deletions(-) diff --git a/bin/pt-config-diff b/bin/pt-config-diff index 36bd2e7b..a8d24095 100755 --- a/bin/pt-config-diff +++ b/bin/pt-config-diff @@ -2784,9 +2784,33 @@ sub _parse_config { die "Unknown config source"; } + handle_special_vars(\%config_data); + return %config_data; } +sub handle_special_vars { + my ($config_data) = @_; + + if ( $config_data->{vars}->{wsrep_provider_options} ) { + my $vars = $config_data->{vars}; + my $dupes = $config_data->{duplicate_vars}; + for my $wpo ( $vars->{wsrep_provider_options}, @{$dupes->{wsrep_provider_options} || [] } ) { + my %opts = $wpo =~ /(\S+)\s*=\s*(\S*)(?:;|;?$)/g; + while ( my ($var, $val) = each %opts ) { + $val =~ s/;$//; + if ( exists $vars->{$var} ) { + push @{$dupes->{$var} ||= []}, $val; + } + $vars->{$var} = $val; + } + } + delete $vars->{wsrep_provider_options}; + } + + return; +} + sub _parse_config_output { my ( %args ) = @_; my @required_args = qw(output TextResultSetParser); @@ -2829,7 +2853,7 @@ sub _parse_config_output { vars => $vars, ); } - + return ( format => $format, vars => $vars, diff --git a/lib/MySQLConfig.pm b/lib/MySQLConfig.pm index c7064734..d706bdb7 100644 --- a/lib/MySQLConfig.pm +++ b/lib/MySQLConfig.pm @@ -121,9 +121,34 @@ sub _parse_config { die "Unknown config source"; } + handle_special_vars(\%config_data); + return %config_data; } +sub handle_special_vars { + my ($config_data) = @_; + + if ( $config_data->{vars}->{wsrep_provider_options} ) { + my $vars = $config_data->{vars}; + my $dupes = $config_data->{duplicate_vars}; + for my $wpo ( $vars->{wsrep_provider_options}, @{$dupes->{wsrep_provider_options} || [] } ) { + my %opts = $wpo =~ /(\S+)\s*=\s*(\S*)(?:;|;?$)/g; + while ( my ($var, $val) = each %opts ) { + $val =~ s/;$//; + if ( exists $vars->{$var} ) { + push @{$dupes->{$var} ||= []}, $val; + } + $vars->{$var} = $val; + } + } + # Delete from vars, but not from dupes, since we still want that + delete $vars->{wsrep_provider_options}; + } + + return; +} + sub _parse_config_output { my ( %args ) = @_; my @required_args = qw(output TextResultSetParser); @@ -166,7 +191,7 @@ sub _parse_config_output { vars => $vars, ); } - + return ( format => $format, vars => $vars, diff --git a/sandbox/start-sandbox b/sandbox/start-sandbox index 5b7e0179..409e883d 100755 --- a/sandbox/start-sandbox +++ b/sandbox/start-sandbox @@ -225,7 +225,7 @@ elif [ -x "$PERCONA_TOOLKIT_SANDBOX/libexec/mysqld" ]; then else die "Cannot find executable mysqld in $PERCONA_TOOLKIT_SANDBOX/bin, $PERCONA_TOOLKIT_SANDBOX/sbin or $PERCONA_TOOLKIT_SANDBOX/libexec." fi -version=`$PERCONA_TOOLKIT_SANDBOX/$mysqld -V 2>/dev/null | awk '{print $3}' | cut -d. -f 1,2`; +version="5.5" if [ ! -d "$PERCONA_TOOLKIT_BRANCH/sandbox/servers/$version" ]; then die "$PERCONA_TOOLKIT_BRANCH/sandbox/servers/$version does not exist." fi