PT-1528 [WIP] Proposed solution

This commit is contained in:
Carlos Salguero
2020-11-22 18:58:00 -03:00
parent ff6b05b381
commit 15ffa974eb
2 changed files with 107 additions and 1 deletions

View File

@@ -8387,6 +8387,7 @@ package pt_online_schema_change;
use strict;
use warnings FATAL => 'all';
use utf8;
use English qw(-no_match_vars);
use Percona::Toolkit;
@@ -8474,7 +8475,7 @@ sub main {
@drop_trigger_sqls = ();
@triggers_not_dropped = ();
$dont_interrupt_now = 0;
%ignore_code = (1592 => 1, 1062 => 1);
%ignore_code = (1592 => 1, 1062 => 1, 1300 => 1);
my %stats = (
INSERT => 0,

View File

@@ -0,0 +1,105 @@
#!/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 threads::shared;
use Thread::Semaphore;
use English qw(-no_match_vars);
use Test::More;
use Data::Dumper;
use PerconaTest;
use Sandbox;
use SqlModes;
use File::Temp qw/ tempdir /;
if ($sandbox_version lt '5.7') {
plan skip_all => 'This test needs MySQL 5.7+';
} else {
plan tests => 5;
}
require "$trunk/bin/pt-online-schema-change";
my $dp = new DSNParser(opts=>$dsn_opts);
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
my $dbh = $sb->get_dbh_for('master');
my $dsn = $sb->dsn_for("master");
# 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-1574.sql");
# TODO WRITE A PROPER TEST
# It should:
# 1. import the data from the jira ticket
# 2. run pt-osc with --no-drop-old table
# 3. compare old and new table. they should have the same info
#
die('incomplete test');
# ($output, $exit_status) = full_output(
# sub { pt_online_schema_change::main(@args, "$dsn,D=test,t=t1",
# '--execute', "--chunk-index", "idx_id", "--chunk-size", "1",
# "--nocheck-plan", '--alter', "engine=innodb",
# ),
# },
# stderr => 1,
# );
#
# my $sql_mode = $dbh->selectcol_arrayref('SELECT @@sql_mode');
#
# isnt(
# $exit_status,
# 0,
# "PT-1574, PT-1590 There is no unique index exit status",
# );
#
# like(
# $output,
# qr/at least one UNIQUE and NOT NULLABLE index/s,
# "PT-1574, PT-1590 Message you need an unique index.",
# );
#
# ($output, $exit_status) = full_output(
# sub { pt_online_schema_change::main(@args, "$dsn,D=test,t=t2",
# '--execute', "--chunk-index", "idx_id", "--chunk-size", "1",
# "--nocheck-plan", '--alter', "engine=innodb",
# ),
# },
# stderr => 1,
# );
# diag($output);
#
# is(
# $exit_status,
# 0,
# "PT-1574, PT-1590 Exit status 0 with null fields, got $exit_status",
# );
#
# like(
# $output,
# qr/Successfully altered `test`.`t2`/s,
# "PT-1574, PT-1590 Successfully altered `test`.`t2`",
# );
# #############################################################################
# Done.
# #############################################################################
$sb->wipe_clean($dbh);
ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
done_testing;