Merge pull request #288 from percona/PT-207

PT-207 All tests passed for 3.0.6
This commit is contained in:
Carlos Salguero
2017-12-18 13:24:35 -03:00
committed by GitHub
27 changed files with 234 additions and 110 deletions

View File

@@ -175,7 +175,7 @@ sub wait {
die "$var=$val exceeds its critical threshold "
. "$self->{critical_val_for}->{$var}\n";
}
if ( $val >= $self->{max_val_for}->{$var} ) {
if ( $val && $val >= $self->{max_val_for}->{$var} ) {
$vals_too_high{$var} = $val;
}
else {

View File

@@ -193,13 +193,13 @@ SKIP: {
# Ignore some dbs and tbls.
test_so(
filters => ['--ignore-databases', 'mysql,sakila,d1,d3,percona_test'],
filters => ['--ignore-databases', 'mysql,sakila,d1,d3,percona_test,sys'],
result => "d2.t1 ",
test_name => '--ignore-databases',
);
test_so(
filters => ['--ignore-databases', 'mysql,sakila,d2,d3,percona_test',
filters => ['--ignore-databases', 'mysql,sakila,d2,d3,percona_test,sys',
'--ignore-tables', 't1,t2'],
result => "d1.t3 ",
test_name => '--ignore-databases and --ignore-tables',
@@ -233,7 +233,7 @@ SKIP: {
);
test_so(
filters => ['--ignore-databases-regex', '(?:^d[23]|mysql|info|sakila|percona_test)',
filters => ['--ignore-databases-regex', '(?:^d[23]|mysql|info|sakila|percona_test|sys)',
'--ignore-tables-regex', 't[^23]'],
result => "d1.t2 d1.t3 ",
test_name => '--ignore-databases-regex',
@@ -266,6 +266,7 @@ SKIP: {
# ########################################################################
# Filter by db-qualified table. There is t1 in both d1 and d2.
# We want only d1.t1.
test_so(
filters => [qw(-t d1.t1)],
result => "d1.t1 ",
@@ -290,10 +291,11 @@ SKIP: {
test_name => '-t d1.t1,d1.t3 (issue 806)',
);
my $want = $sandbox_version le '5.6' ? "d1.t2 d1.t3 d2.t1 " : 'd1.t2 d1.t3 d2.t1 sys.sys_config ';
test_so(
filters => ['--ignore-databases', 'mysql,sakila,percona_test',
'--ignore-tables', 'd1.t1'],
result => "d1.t2 d1.t3 d2.t1 ",
result => $want,
test_name => '--ignore-databases and --ignore-tables d1.t1 (issue 806)',
);
@@ -420,7 +422,7 @@ test_so(
# ############################################################################
test_so(
filters => ['--ignore-databases', 'sakila,mysql'],
filters => ['--ignore-databases', 'sakila,mysql,sys'],
result => "",
lives_ok => 1,
resume => 'sakila.payment',
@@ -430,7 +432,7 @@ test_so(
$dbh->do("CREATE DATABASE zakila");
$dbh->do("CREATE TABLE zakila.bug_911385 (i int)");
test_so(
filters => ['--ignore-databases', 'sakila,mysql'],
filters => ['--ignore-databases', 'sakila,mysql,sys'],
result => "zakila.bug_911385 ",
resume => 'sakila.payment',
test_name => "Bug 911385: ...and continues to the next db"
@@ -438,7 +440,7 @@ test_so(
$dbh->do("DROP DATABASE zakila");
test_so(
filters => [qw(--ignore-tables-regex payment --ignore-databases mysql)],
filters => ['--ignore-tables-regex', 'payment', '--ignore-databases', 'mysql,sys'],
result => "",
lives_ok => 1,
resume => 'sakila.payment',
@@ -446,7 +448,7 @@ test_so(
);
test_so(
filters => [qw(--ignore-tables-regex payment --ignore-databases mysql)],
filters => ['--ignore-tables-regex', 'payment', '--ignore-databases', 'mysql,sys'],
result => "sakila.rental sakila.staff sakila.store ",
resume => 'sakila.payment',
test_name => "Bug 911385: ...and continues to the next table"

View File

@@ -85,14 +85,6 @@ CREATE TABLE `func` (
PRIMARY KEY (`name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='User defined functions'
mysql.gtid_executed
CREATE TABLE `gtid_executed` (
`source_uuid` char(36) NOT NULL COMMENT 'uuid of the source where the transaction was originally executed.',
`interval_start` bigint(20) NOT NULL COMMENT 'First number of interval.',
`interval_end` bigint(20) NOT NULL COMMENT 'Last number of interval.',
PRIMARY KEY (`source_uuid`,`interval_start`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
mysql.help_category
CREATE TABLE `help_category` (
`help_category_id` smallint(5) unsigned NOT NULL,
@@ -147,6 +139,38 @@ CREATE TABLE `ndb_binlog_index` (
PRIMARY KEY (`epoch`,`orig_server_id`,`orig_epoch`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
mysql.plugin
CREATE TABLE `plugin` (
`name` varchar(64) NOT NULL DEFAULT '',
`dl` varchar(128) NOT NULL DEFAULT '',
PRIMARY KEY (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 STATS_PERSISTENT=0 COMMENT='MySQL plugins'
mysql.proc
CREATE TABLE `proc` (
`db` char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '',
`name` char(64) NOT NULL DEFAULT '',
`type` enum('FUNCTION','PROCEDURE') NOT NULL,
`specific_name` char(64) NOT NULL DEFAULT '',
`language` enum('SQL') NOT NULL DEFAULT 'SQL',
`sql_data_access` enum('CONTAINS_SQL','NO_SQL','READS_SQL_DATA','MODIFIES_SQL_DATA') NOT NULL DEFAULT 'CONTAINS_SQL',
`is_deterministic` enum('YES','NO') NOT NULL DEFAULT 'NO',
`security_type` enum('INVOKER','DEFINER') NOT NULL DEFAULT 'DEFINER',
`param_list` blob NOT NULL,
`returns` longblob NOT NULL,
`body` longblob NOT NULL,
`definer` char(93) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '',
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`modified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
`sql_mode` set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','NOT_USED','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE','NO_ENGINE_SUBSTITUTION','PAD_CHAR_TO_FULL_LENGTH') NOT NULL DEFAULT '',
`comment` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`character_set_client` char(32) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
`collation_connection` char(32) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
`db_collation` char(32) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
`body_utf8` longblob,
PRIMARY KEY (`db`,`name`,`type`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Stored Procedures'
mysql.procs_priv
CREATE TABLE `procs_priv` (
`Host` char(60) COLLATE utf8_bin NOT NULL DEFAULT '',
@@ -535,3 +559,12 @@ CREATE TABLE `store` (
CONSTRAINT `fk_store_staff` FOREIGN KEY (`manager_staff_id`) REFERENCES `staff` (`staff_id`) ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8
sys.sys_config
CREATE TABLE `sys_config` (
`variable` varchar(128) NOT NULL,
`value` varchar(128) DEFAULT NULL,
`set_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`set_by` varchar(128) DEFAULT NULL,
PRIMARY KEY (`variable`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8

View File

@@ -43,6 +43,9 @@ $dbh2->commit;
$dbh1->{InactiveDestroy} = 1;
$dbh2->{InactiveDestroy} = 1;
$dbh1->{mysql_auto_reconnect} = 1;
$dbh2->{mysql_auto_reconnect} = 1;
sub make_deadlock {
# Fork off two children to deadlock against each other.
my %children;
@@ -82,12 +85,28 @@ sub make_deadlock {
foreach my $child ( keys %children ) {
my $pid = waitpid($children{$child}, 0);
}
$dbh1->commit;
$dbh2->commit;
eval {
$dbh1->commit;
$dbh1->disconnect();
};
eval {
$dbh2->commit;
$dbh2->disconnect();
};
}
sub reconnect {
my $dbh = shift;
$dbh->disconnect();
$dbh = $sb->get_dbh_for('master', { PrintError => 0, RaiseError => 1, AutoCommit => 0 });
return $dbh;
}
make_deadlock();
$dbh1 = reconnect($dbh1);
$dbh2 = reconnect($dbh2);
# Test that there is a deadlock
$output = $dbh1->selectrow_hashref('show /*!40101 engine*/ innodb status')->{status};
like($output, qr/WE ROLL BACK/, 'There was a deadlock');
@@ -208,6 +227,9 @@ SKIP: {
# #############################################################################
# Done.
# #############################################################################
$dbh1 = reconnect($dbh1);
$dbh2 = reconnect($dbh2);
$dbh1->commit;
$dbh2->commit;
$sb->wipe_clean($dbh1);

View File

@@ -0,0 +1,88 @@
#!/usr/bin/env perl
BEGIN {
die "The PERCONA_TOOLKIT_BRANCH environment variable is not set.\n"
unless $ENV{PERCONA_TOOLKIT_BRANCH} && -d $ENV{PERCONA_TOOLKIT_BRANCH};
unshift @INC, "$ENV{PERCONA_TOOLKIT_BRANCH}/lib";
};
use strict;
use warnings FATAL => 'all';
use threads;
use English qw(-no_match_vars);
use Test::More;
use Data::Dumper;
use PerconaTest;
use Sandbox;
use SqlModes;
use File::Temp qw/ tempdir /;
require "$trunk/bin/pt-online-schema-change";
my $dp = new DSNParser(opts=>$dsn_opts);
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
my $master_dbh = $sb->get_dbh_for('master');
my $master_dsn = 'h=127.1,P=12345,u=msandbox,p=msandbox';
if ( !$master_dbh ) {
plan skip_all => 'Cannot connect to sandbox master';
}
if ($sandbox_version lt '5.7') {
plan skip_all => "RocksDB is only available on Percona Server 5.7.19+";
}
my $rows = $master_dbh->selectall_arrayref('SHOW ENGINES', {Slice=>{}});
my $rocksdb_enabled;
for my $row (@$rows) {
if ($row->{engine} eq 'ROCKSDB') {
$rocksdb_enabled = 1;
last;
}
}
if (!$rocksdb_enabled) {
plan skip_all => "RocksDB engine is not available";
}
plan tests => 3;
# The sandbox servers run with lock_wait_timeout=3 and it's not dynamic
# so we need to specify --set-vars innodb_lock_wait_timeout=3 else the
# tool will die.
my @args = (qw(--set-vars innodb_lock_wait_timeout=3));
my $output;
my $exit_status;
$sb->load_file('master', "t/pt-online-schema-change/samples/pt-207.sql");
($output, $exit_status) = full_output(
sub { pt_online_schema_change::main(@args, "$master_dsn,D=test,t=t1",
'--execute',
'--alter', "ADD INDEX (f3)",
),
},
);
isnt(
$exit_status,
0,
"PT-207 Altering RocksDB table adding index with invalid collation, exit status != 0",
);
like(
$output,
qr/`test`.`t1` was not altered/s,
"PT-207 Message cannot add index with invalid collation to a RocksDB table",
);
$master_dbh->do("DROP DATABASE IF EXISTS test");
# #############################################################################
# Done.
# #############################################################################
$sb->wipe_clean($master_dbh);
ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
done_testing;

View File

@@ -0,0 +1,9 @@
CREATE SCHEMA IF NOT EXISTS test;
USE test;
DROP TABLE IF EXISTS t1;
CREATE TABLE `test`.`t1` (
`id` int(11) NOT NULL,
`f2` int(11) DEFAULT NULL,
`f3` varchar(255) CHARACTER SET latin1 COLLATE latin1_german1_ci,
PRIMARY KEY (`id`)
) ENGINE=RocksDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

File diff suppressed because one or more lines are too long

View File

@@ -22,6 +22,10 @@ use File::Temp qw/ tempdir /;
plan tests => 4;
our $delay = 30;
my $tmp_file = File::Temp->new();
my $tmp_file_name = $tmp_file->filename;
unlink $tmp_file_name;
require "$trunk/bin/pt-online-schema-change";
my $dp = new DSNParser(opts=>$dsn_opts);
@@ -51,6 +55,10 @@ $slave_dbh->do('START SLAVE');
diag('Loading test data');
$sb->load_file('master', "t/pt-online-schema-change/samples/slave_lag.sql");
my $num_rows = 10000;
diag("Loading $num_rows into the table. This might take some time.");
diag(`util/mysql_random_data_load_linux_amd64 --host=127.1 --port=12345 --user=msandbox --password=msandbox test pt178 $num_rows`);
# Run a full table scan query to ensure the slave is behind the master
$master_dbh->do('RESET QUERY CACHE');
$slave_dbh->do('RESET QUERY CACHE');
@@ -60,8 +68,9 @@ $master_dbh->do('UPDATE `test`.`pt178` SET f2 = f2 + 1 WHERE f1 = ""');
# pt-online-schema-change will wait on the slave at port 12346
my $max_lag = $delay / 2;
my $args = "$master_dsn,D=test,t=pt178 --execute --chunk-size 1 --max-lag 5 --alter 'ENGINE=InnoDB' ";
my $args = "$master_dsn,D=test,t=pt178 --execute --chunk-size 1 --max-lag 5 --alter 'ENGINE=InnoDB' --pid $tmp_file_name";
diag("Starting base test. This is going to take some time due to the delay in the slave");
diag("pid: $tmp_file_name");
my $output = `$trunk/bin/pt-online-schema-change $args 2>&1`;
like(

View File

@@ -196,6 +196,7 @@ $exit_status = pt_table_checksum::main(@args,
$slave1_dbh->do("update percona.checksums set this_crc='' where db='sakila' and tbl='city' and (chunk=1 or chunk=6)");
PerconaTest::wait_for_table($slave2_dbh, "percona.checksums", "db='sakila' and tbl='city' and (chunk=1 or chunk=6) and thic_crc=''");
# 9
ok(
no_diff(
sub { pt_table_checksum::main(@args, qw(--replicate-check-only)) },
@@ -214,6 +215,7 @@ $output = output(
stderr => 1,
);
# 10
like(
$output,
qr/infinite loop detected/,
@@ -223,13 +225,14 @@ like(
# ############################################################################
# Oversize chunk.
# ############################################################################
# 11
ok(
no_diff(
sub { pt_table_checksum::main(@args,
qw(-t osc.t2 --chunk-size 8 --explain --explain)) },
"$sample/oversize-chunks.txt",
),
"Upper boundary same as next lower boundary"
"Upper boundary same as next lower boundary",
);
$output = output(

View File

@@ -184,9 +184,9 @@ $output = output(
chomp($output);
is(
like(
$output,
'',
qr/Starting checksum/,
"Bug 1074179: ignore-tables-regex works with --replicate-check-only"
);
# #############################################################################

View File

@@ -22,8 +22,9 @@ my $dbh = $sb->get_dbh_for('master');
if ( !$dbh ) {
plan skip_all => 'Cannot connect to sandbox master';
}
else {
} elsif ($sandbox_version lt '5.7') {
plan skip_all => "Generated columns are only available in MySQL 5.7+";
} else {
plan tests => 3;
}

View File

@@ -98,9 +98,9 @@ $output = output(
sub { pt_table_checksum::main(@args, qw(-d sakila --resume)) },
);
is(
like(
$output,
'',
qr/Starting checksum/,
"Resume with nothing to do"
);
@@ -140,7 +140,7 @@ is_deeply(
"Resume finished sakila"
);
my (undef, $first_tbl) = split /\n/, $output;
my (undef, undef, undef, $first_tbl) = split /\n/, $output;
like(
$first_tbl,
qr/sakila.country$/,
@@ -263,7 +263,7 @@ is_deeply(
"Resume finished sakila"
);
(undef, undef, $first_tbl) = split /\n/, $output;
(undef, undef, undef, undef, $first_tbl) = split /\n/, $output;
like(
$first_tbl,
qr/sakila.payment$/,
@@ -272,7 +272,7 @@ like(
like(
$output,
qr/^Resuming from sakila.payment chunk 7, timestamp 2011-10-15 13:00:28/s,
qr/Resuming from sakila.payment chunk 7, timestamp 2011-10-15 13:00:28/s,
"Resuming from sakila.payment chunk 7"
);
@@ -342,7 +342,7 @@ is_deeply(
"Resume finished sakila"
);
(undef, $first_tbl) = split /\n/, $output;
(undef, undef, undef, $first_tbl) = split /\n/, $output;
like(
$first_tbl,
qr/sakila.rental$/,
@@ -438,7 +438,9 @@ is_deeply(
is(
$output,
"Resuming from sakila.rental chunk 11, timestamp 2011-10-15 13:00:49
"Checking if all tables can be checksummed ...
Starting checksum ...
Resuming from sakila.rental chunk 11, timestamp 2011-10-15 13:00:49
ERRORS DIFFS ROWS CHUNKS SKIPPED TABLE
0 0 5044 8 0 sakila.rental
0 0 2 1 0 sakila.staff
@@ -493,7 +495,9 @@ $output = output(
is(
$output,
"ERRORS DIFFS ROWS CHUNKS SKIPPED TABLE
"Checking if all tables can be checksummed ...
Starting checksum ...
ERRORS DIFFS ROWS CHUNKS SKIPPED TABLE
0 0 26 8 0 test.t3
",
"Resumed from t3"

View File

@@ -1,3 +1,5 @@
Checking if all tables can be checksummed ...
Starting checksum ...
--
-- test.ascii
--

View File

@@ -1,2 +1,4 @@
if all tables can be ...
checksum ...
ERRORS DIFFS ROWS CHUNKS SKIPPED TABLE
0 0 142 10 0 test.ascii

View File

@@ -1,3 +1,5 @@
Checking if all tables can be checksummed ...
Starting checksum ...
--
-- issue_519.t
--

View File

@@ -1,3 +1,5 @@
Checking if all tables can be checksummed ...
Starting checksum ...
--
-- issue_519.t
--

View File

@@ -1,3 +1,5 @@
Checking if all tables can be checksummed ...
Starting checksum ...
--
-- issue_519.t
--

View File

@@ -1,3 +1,5 @@
Checking if all tables can be checksummed ...
Starting checksum ...
--
-- sakila.city
--

View File

@@ -1,3 +1,5 @@
if all tables be ...
checksum ...
ERRORS DIFFS ROWS SKIPPED TABLE
0 0 0 0 mysql.columns_priv
0 0 0 0 mysql.db

View File

@@ -1,3 +1,5 @@
if all tables be ...
checksum ...
ERRORS DIFFS ROWS SKIPPED TABLE
0 0 0 0 mysql.columns_priv
0 0 0 0 mysql.db

View File

@@ -1,3 +1,5 @@
Checking if all tables can be checksummed ...
Starting checksum ...
--
-- test.t
--

View File

@@ -1,3 +1,5 @@
Checking if all tables can be checksummed ...
Starting checksum ...
--
-- sakila.rental
--

View File

@@ -1,3 +1,5 @@
Checking if all tables can be checksummed ...
Starting checksum ...
Differences on h=127.0.0.1,P=12346
TABLE CHUNK CNT_DIFF CRC_DIFF CHUNK_INDEX LOWER_BOUNDARY UPPER_BOUNDARY
sakila.city 1 0 1 PRIMARY 1 100

View File

@@ -1,3 +1,5 @@
Checking if all tables can be checksummed ...
Starting checksum ...
--
-- test.multi_resource_apt
--

View File

@@ -1,3 +1,5 @@
Checking if all tables can be checksummed ...
Starting checksum ...
--
-- osc.t2
--

View File

@@ -1,3 +1,5 @@
if all tables can be ...
checksum ...
ERRORS DIFFS ROWS CHUNKS SKIPPED TABLE
0 0 0 1 0 mysql.columns_priv
0 0 0 1 0 mysql.db

View File

@@ -1,3 +1,5 @@
if all tables can be ...
checksum ...
ERRORS DIFFS ROWS CHUNKS SKIPPED TABLE
0 0 0 1 0 mysql.columns_priv
0 0 0 1 0 mysql.db