Merge pull request #217 from percona/PT-142

PT-142 pt-online-schema-change find_child_tables slow
This commit is contained in:
Carlos Salguero
2017-05-23 16:43:30 -03:00
committed by GitHub
6 changed files with 45 additions and 5 deletions

View File

@@ -2,6 +2,7 @@ Changelog for Percona Toolkit
v3.0.4
* Fixed bug PT-142 : pt-online-schema-change find_child_tables slow
* Fixed bug PT-138 : Added --output-format option to pt-mongodb-summary
* Feature PT-141 : pt-archiver archive records into csv file
@@ -13,15 +14,17 @@ v3.0.3
* Fixed bug PT-128 : pt-stalk ps include memory usage outputs
* Fixed bug PT-126 : Recognize comments in ALTER
* Fixed bug PT-116 : pt-online-schema change eats data on adding a unique index. Added --[no]use-insert-ignore
* Feature PT-115 : Make DSNs params able to be repeatable
* Fixed bug PT-115 : Made OptionParser to accept repeatable DSNs
* Fixed bug PT-111 : Collect MySQL variables
* Fixed bug PT-087 : Add --skip-check-slave-lag to pt-table-checksum
* Fixed bug PT-086 : Added --skip-check-slave-lag to pt-osc
* Fixed bug PT-080 : Added support for slave status in pt-stalk
* Feature PT-115 : Make DSNs params able to be repeatable
v3.0.2 released 2017-03-23
* Fixed bug PT-101 : pt-table-checksum ignores slave-user and slave-password
* Fixed bug PT-105 : pt-table-checksum fails if a database is dropped while the tool is running
* Fixed bug PT-73 : pt-mongodb tools add support for SSL connections
* Fixed bug PT-74 : pt-mongodb-summary Cannot get security settings when connected to a mongod instance
* Fixed bug PT-75 : pt-mongodb-query-digest Change the default sort order to -count (descending)
@@ -32,8 +35,6 @@ v3.0.2 released 2017-03-23
* Fixed bug PT-93 : Fix pt-mongodb-query-digest query ID (Thanks Kamil Dziedzic)
* Fixed bug PT-94 : pt-online-schema-change makes duplicate rows in _t_new for UPDATE t set pk=0 where pk=1
* Fixed bug PT-96 : Fixed PT tests
* Fixed bug PT-101 : pt-table-checksum ignores slave-user and slave-password
* Fixed bug PT-105 : pt-table-checksum fails if a database is dropped while the tool is running
v3.0.1 released 2017-02-16

View File

@@ -8770,6 +8770,7 @@ sub main {
tbl => $orig_tbl,
Cxn => $cxn,
Quoter => $q,
only_same_schema_fks => $o->get('only-same-schema-fks'),
);
if ( !$child_tables ) {
if ( $alter_fk_method ) {
@@ -10453,6 +10454,11 @@ sub find_child_tables {
. "FROM information_schema.key_column_usage "
. "WHERE referenced_table_schema='$tbl->{db}' "
. "AND referenced_table_name='$tbl->{tbl}'";
if ($args{only_same_schema_fks}) {
$sql .= " AND table_schema='$tbl->{db}'";
}
PTDEBUG && _d($sql);
my $rows = $cxn->dbh()->selectall_arrayref($sql);
if ( !$rows || !@$rows ) {
@@ -11874,6 +11880,13 @@ them. The rows which contain NULL values will be converted to the defined
default value. If no explicit DEFAULT value is given MySQL will assign a default
value based on datatype, e.g. 0 for number datatypes, '' for string datatypes.
=item --only-same-schema-fks
Check foreigns keys only on tables on the same schema than the original table.
This option is dangerous since if you have FKs refenrencing tables in other
schemas, they won't be detected.
=item --password
short form: -p; type: string

View File

@@ -26,3 +26,4 @@ log-error = /tmp/PORT/data/mysqld.log
innodb_lock_wait_timeout = 3
general_log
general_log_file = genlog
secure-file-priv =

View File

@@ -52,7 +52,7 @@ my $want = [
key_len => 2,
ref => 'const',
rows => 1,
Extra => $sandbox_version gt '5.6' ? undef : '',
Extra => $sandbox_version eq '5.6' ? undef : '',
},
];
if ( $sandbox_version gt '5.6' ) {

View File

@@ -445,6 +445,31 @@ $output = output(
# clear databases with their foreign keys
$sb->load_file('master', "$sample/bug-1315130_cleanup.sql");
# #############################################################################
# Issue 1315130
# Failed to detect child tables in other schema, and falsely identified
# child tables in own schema
# #############################################################################
$sb->load_file('master', "$sample/bug-1315130_cleanup.sql");
$sb->load_file('master', "$sample/bug-1315130.sql");
$output = output(
sub { pt_online_schema_change::main(@args, "$master_dsn,D=bug_1315130_a,t=parent_table",
'--dry-run',
'--alter', "add column c varchar(16)",
'--alter-foreign-keys-method', 'auto', '--only-same-schema-fks'),
},
);
like(
$output,
qr/Child tables:\s*`bug_1315130_a`\.`child_table_in_same_schema` \(approx\. 1 rows\)[^`]*?Will/s,
"Ignore child tables in other schemas.",
);
# clear databases with their foreign keys
$sb->load_file('master', "$sample/bug-1315130_cleanup.sql");
# #############################################################################
# Issue 1340728

View File

@@ -105,7 +105,7 @@ ok(
$row = $master_dbh->selectrow_arrayref("select count(*) from percona.checksums");
my $max_rows = $sandbox_version < '5.7' ? 75 : 100;
my $max_rows = $sandbox_version < '5.7' ? 90 : 100;
ok(
$row->[0] >= 75 && $row->[0] <= $max_rows,
'Between 75 and 90 chunks on master'