mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-10 05:00:45 +00:00
Merge pull request #60 from percona/pt-osc-recursion-method-error-lp1523685
pt-osc fixed recursion method dsn - lp1523685
This commit is contained in:
@@ -4059,17 +4059,8 @@ use constant PTDEBUG => $ENV{PTDEBUG} || 0;
|
|||||||
|
|
||||||
sub check_recursion_method {
|
sub check_recursion_method {
|
||||||
my ($methods) = @_;
|
my ($methods) = @_;
|
||||||
|
if ( @$methods != 1 ) {
|
||||||
foreach my $method ( @$methods ) {
|
if ( grep({ !m/processlist|hosts/i } @$methods)
|
||||||
die "Invalid recursion method: " . ($method || 'undef') . "\n"
|
|
||||||
unless $method && $method =~ m/^(?:processlist$|hosts$|none$|cluster|dsn=)/i;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( @$methods > 1 ) {
|
|
||||||
if ( grep( { m/none/ } @$methods) && grep( {! m/none/ } @$methods) ) {
|
|
||||||
die "--recursion-method=none cannot be combined with other methods\n";
|
|
||||||
}
|
|
||||||
elsif ( grep({ !m/processlist|hosts/i } @$methods)
|
|
||||||
&& $methods->[0] !~ /^dsn=/i )
|
&& $methods->[0] !~ /^dsn=/i )
|
||||||
{
|
{
|
||||||
die "Invalid combination of recursion methods: "
|
die "Invalid combination of recursion methods: "
|
||||||
@@ -4077,8 +4068,11 @@ sub check_recursion_method {
|
|||||||
. "Only hosts and processlist may be combined.\n"
|
. "Only hosts and processlist may be combined.\n"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
return;
|
my ($method) = @$methods;
|
||||||
|
die "Invalid recursion method: " . ( $method || 'undef' )
|
||||||
|
unless $method && $method =~ m/^(?:processlist$|hosts$|none$|cluster$|dsn=)/i;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
|
@@ -10358,17 +10358,8 @@ use constant PTDEBUG => $ENV{PTDEBUG} || 0;
|
|||||||
|
|
||||||
sub check_recursion_method {
|
sub check_recursion_method {
|
||||||
my ($methods) = @_;
|
my ($methods) = @_;
|
||||||
|
if ( @$methods != 1 ) {
|
||||||
foreach my $method ( @$methods ) {
|
if ( grep({ !m/processlist|hosts/i } @$methods)
|
||||||
die "Invalid recursion method: " . ($method || 'undef') . "\n"
|
|
||||||
unless $method && $method =~ m/^(?:processlist$|hosts$|none$|cluster|dsn=)/i;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( @$methods > 1 ) {
|
|
||||||
if ( grep( { m/none/ } @$methods) && grep( {! m/none/ } @$methods) ) {
|
|
||||||
die "--recursion-method=none cannot be combined with other methods\n";
|
|
||||||
}
|
|
||||||
elsif ( grep({ !m/processlist|hosts/i } @$methods)
|
|
||||||
&& $methods->[0] !~ /^dsn=/i )
|
&& $methods->[0] !~ /^dsn=/i )
|
||||||
{
|
{
|
||||||
die "Invalid combination of recursion methods: "
|
die "Invalid combination of recursion methods: "
|
||||||
@@ -10376,8 +10367,11 @@ sub check_recursion_method {
|
|||||||
. "Only hosts and processlist may be combined.\n"
|
. "Only hosts and processlist may be combined.\n"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
return;
|
my ($method) = @$methods;
|
||||||
|
die "Invalid recursion method: " . ( $method || 'undef' )
|
||||||
|
unless $method && $method =~ m/^(?:processlist$|hosts$|none$|cluster$|dsn=)/i;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
|
@@ -31,19 +31,8 @@ use constant PTDEBUG => $ENV{PTDEBUG} || 0;
|
|||||||
# Check that the arrayref of recursion methods passed in is valid
|
# Check that the arrayref of recursion methods passed in is valid
|
||||||
sub check_recursion_method {
|
sub check_recursion_method {
|
||||||
my ($methods) = @_;
|
my ($methods) = @_;
|
||||||
|
if ( @$methods != 1 ) {
|
||||||
# Check that each method is valid.
|
if ( grep({ !m/processlist|hosts/i } @$methods)
|
||||||
foreach my $method ( @$methods ) {
|
|
||||||
die "Invalid recursion method: " . ($method || 'undef') . "\n"
|
|
||||||
unless $method && $method =~ m/^(?:processlist$|hosts$|none$|cluster|dsn=)/i;
|
|
||||||
}
|
|
||||||
|
|
||||||
# Check for invalid combination of methods.
|
|
||||||
if ( @$methods > 1 ) {
|
|
||||||
if ( grep( { m/none/ } @$methods) && grep( {! m/none/ } @$methods) ) {
|
|
||||||
die "--recursion-method=none cannot be combined with other methods\n";
|
|
||||||
}
|
|
||||||
elsif ( grep({ !m/processlist|hosts/i } @$methods)
|
|
||||||
&& $methods->[0] !~ /^dsn=/i )
|
&& $methods->[0] !~ /^dsn=/i )
|
||||||
{
|
{
|
||||||
die "Invalid combination of recursion methods: "
|
die "Invalid combination of recursion methods: "
|
||||||
@@ -51,8 +40,11 @@ sub check_recursion_method {
|
|||||||
. "Only hosts and processlist may be combined.\n"
|
. "Only hosts and processlist may be combined.\n"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
return;
|
my ($method) = @$methods;
|
||||||
|
die "Invalid recursion method: " . ( $method || 'undef' )
|
||||||
|
unless $method && $method =~ m/^(?:processlist$|hosts$|none$|cluster$|dsn=)/i;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
|
@@ -46,6 +46,7 @@ my $exit = 0;
|
|||||||
my $sample = "t/pt-online-schema-change/samples";
|
my $sample = "t/pt-online-schema-change/samples";
|
||||||
my $rows;
|
my $rows;
|
||||||
|
|
||||||
|
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
# Tool shouldn't run without --execute (bug 933232).
|
# Tool shouldn't run without --execute (bug 933232).
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
@@ -798,6 +799,26 @@ test_alter_table(
|
|||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
# #############################################################################
|
||||||
|
# --recursion-method=dns (lp: 1523685)
|
||||||
|
# #############################################################################
|
||||||
|
|
||||||
|
$sb->load_file('master', "$sample/create_dsns.sql");
|
||||||
|
|
||||||
|
($output, $exit) = full_output(
|
||||||
|
sub { pt_online_schema_change::main(@args,
|
||||||
|
"$dsn,D=sakila,t=actor", ('--recursion-method=dsn=D=test_recursion_method,t=dsns,h=127.0.0.1,P=12345,u=msandbox,p=msandbox', '--alter-foreign-keys-method', 'drop_swap', '--execute', '--alter', 'ENGINE=InnoDB')) },
|
||||||
|
stderr => 1,
|
||||||
|
);
|
||||||
|
|
||||||
|
like(
|
||||||
|
$output,
|
||||||
|
qr/Found 2 slaves.*Successfully altered/si,
|
||||||
|
"--recursion-method=dns works"
|
||||||
|
);
|
||||||
|
|
||||||
|
$master_dbh->do("DROP DATABASE test_recursion_method");
|
||||||
|
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
# Done.
|
# Done.
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
|
13
t/pt-online-schema-change/samples/create_dsns.sql
Normal file
13
t/pt-online-schema-change/samples/create_dsns.sql
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
CREATE DATABASE IF NOT EXISTS test_recursion_method;
|
||||||
|
USE test_recursion_method;
|
||||||
|
DROP TABLE IF EXISTS `dsns`;
|
||||||
|
CREATE TABLE `dsns` (
|
||||||
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
`parent_id` int(11) DEFAULT NULL,
|
||||||
|
`dsn` varchar(255) NOT NULL,
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1;
|
||||||
|
|
||||||
|
INSERT INTO `dsns` VALUES (1, 12345, "D=test_recursion_method,t=dsns,P=12346,h=127.0.0.1,u=root,p=msandbox");
|
||||||
|
INSERT INTO `dsns` VALUES (2, 12345, "D=test_recursion_method,t=dsns,P=12347,h=127.0.0.1,u=root,p=msandbox");
|
||||||
|
|
Reference in New Issue
Block a user