Merge lp:~percona-toolkit-dev/percona-toolkit/pt-osc-retry-timeouts into lp:percona-toolkit/2.2

Proposed by Daniel Nichter
Status: Merged
Merged at revision: 547
Proposed branch: lp:~percona-toolkit-dev/percona-toolkit/pt-osc-retry-timeouts
Merge into: lp:percona-toolkit/2.2
Diff against target: 560 lines (+190/-80)
6 files modified
bin/pt-online-schema-change (+166/-78)
lib/Retry.pm (+2/-0)
t/pt-online-schema-change/metadata_locks.t (+4/-2)
t/pt-online-schema-change/samples/stats-dry-run.txt (+6/-0)
t/pt-online-schema-change/samples/stats-execute-5.5.txt (+6/-0)
t/pt-online-schema-change/samples/stats-execute.txt (+6/-0)
To merge this branch: bzr merge lp:~percona-toolkit-dev/percona-toolkit/pt-osc-retry-timeouts
Reviewer Review Type Date Requested Status
Daniel Nichter Approve
Review via email: mp+151854@code.launchpad.net
To post a comment you must log in.
550. By Daniel Nichter

Update sample file with --tries output.

Revision history for this message
Daniel Nichter (daniel-nichter) wrote :

Tool's tests pass in all envs.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'bin/pt-online-schema-change'
--- bin/pt-online-schema-change 2013-03-04 18:08:22 +0000
+++ bin/pt-online-schema-change 2013-03-05 23:44:21 +0000
@@ -3578,6 +3578,8 @@
3578use English qw(-no_match_vars);3578use English qw(-no_match_vars);
3579use constant PTDEBUG => $ENV{PTDEBUG} || 0;3579use constant PTDEBUG => $ENV{PTDEBUG} || 0;
35803580
3581use Time::HiRes qw(sleep);
3582
3581sub new {3583sub new {
3582 my ( $class, %args ) = @_;3584 my ( $class, %args ) = @_;
3583 my $self = {3585 my $self = {
@@ -7617,6 +7619,13 @@
7617 . $n_chunk_index_cols);7619 . $n_chunk_index_cols);
7618 }7620 }
76197621
7622 my $tries = eval {
7623 validate_tries($o);
7624 };
7625 if ( $EVAL_ERROR ) {
7626 $o->save_error($EVAL_ERROR);
7627 }
7628
7620 if ( !$o->get('help') ) {7629 if ( !$o->get('help') ) {
7621 if ( @ARGV ) {7630 if ( @ARGV ) {
7622 $o->save_error('Specify only one DSN on the command line');7631 $o->save_error('Specify only one DSN on the command line');
@@ -7974,6 +7983,17 @@
7974 );7983 );
79757984
7976 # ########################################################################7985 # ########################################################################
7986 # Print --tries.
7987 # ########################################################################
7988 print "Operation, tries, wait:\n";
7989 {
7990 my $fmt = " %s, %s, %s\n";
7991 foreach my $op ( sort keys %$tries ) {
7992 printf $fmt, $op, $tries->{$op}->{tries}, $tries->{$op}->{wait};
7993 }
7994 }
7995
7996 # ########################################################################
7977 # Get child tables of the original table, if necessary.7997 # Get child tables of the original table, if necessary.
7978 # ########################################################################7998 # ########################################################################
7979 my $child_tables;7999 my $child_tables;
@@ -8427,7 +8447,7 @@
8427 Quoter => $q,8447 Quoter => $q,
8428 OptionParser => $o,8448 OptionParser => $o,
8429 Retry => $retry,8449 Retry => $retry,
8430 retries => $o->get('retries'),8450 tries => $tries,
8431 stats => \%stats,8451 stats => \%stats,
8432 );8452 );
8433 }8453 }
@@ -8453,7 +8473,7 @@
8453 Quoter => $q,8473 Quoter => $q,
8454 OptionParser => $o,8474 OptionParser => $o,
8455 Retry => $retry,8475 Retry => $retry,
8456 retries => $o->get('retries'),8476 tries => $tries,
8457 stats => \%stats,8477 stats => \%stats,
8458 );8478 );
8459 };8479 };
@@ -8642,7 +8662,7 @@
8642 # Exec and time the chunk checksum query.8662 # Exec and time the chunk checksum query.
8643 $tbl->{nibble_time} = exec_nibble(8663 $tbl->{nibble_time} = exec_nibble(
8644 %args,8664 %args,
8645 retries => $o->get('retries'),8665 tries => $tries,
8646 Retry => $retry,8666 Retry => $retry,
8647 Quoter => $q,8667 Quoter => $q,
8648 stats => \%stats,8668 stats => \%stats,
@@ -8852,7 +8872,7 @@
8852 Quoter => $q,8872 Quoter => $q,
8853 OptionParser => $o,8873 OptionParser => $o,
8854 Retry => $retry,8874 Retry => $retry,
8855 retries => $o->get('retries'),8875 tries => $tries,
8856 stats => \%stats,8876 stats => \%stats,
8857 );8877 );
8858 };8878 };
@@ -8900,7 +8920,7 @@
8900 TableParser => $tp,8920 TableParser => $tp,
8901 stats => \%stats,8921 stats => \%stats,
8902 Retry => $retry,8922 Retry => $retry,
8903 retries => $o->get('retries'),8923 tries => $tries,
8904 );8924 );
8905 }8925 }
8906 elsif ( $alter_fk_method eq 'drop_swap' ) {8926 elsif ( $alter_fk_method eq 'drop_swap' ) {
@@ -8911,7 +8931,7 @@
8911 OptionParser => $o,8931 OptionParser => $o,
8912 stats => \%stats,8932 stats => \%stats,
8913 Retry => $retry,8933 Retry => $retry,
8914 retries => $o->get('retries'),8934 tries => $tries,
8915 );8935 );
8916 }8936 }
8917 elsif ( !$alter_fk_method8937 elsif ( !$alter_fk_method
@@ -9003,6 +9023,56 @@
9003# Subroutines.9023# Subroutines.
9004# ############################################################################9024# ############################################################################
90059025
9026sub validate_tries {
9027 my ($o) = @_;
9028 my @ops = qw(
9029 create_triggers
9030 drop_triggers
9031 copy_rows
9032 swap_tables
9033 update_foreign_keys
9034 );
9035 my %user_tries;
9036 my $user_tries = $o->get('tries');
9037 if ( $user_tries ) {
9038 foreach my $var_val ( @$user_tries ) {
9039 my ($op, $tries, $wait) = split(':', $var_val);
9040 die "Invalid --tries value: $var_val\n" unless $op && $tries && $wait;
9041 die "Invalid --tries operation: $op\n" unless grep { $op eq $_ } @ops;
9042 die "Invalid --tries tries: $tries\n" unless $tries > 0;
9043 die "Invalid --tries wait: $wait\n" unless $wait > 0;
9044 $user_tries{$op} = {
9045 tries => $tries,
9046 wait => $wait,
9047 };
9048 }
9049 }
9050
9051 my %default_tries;
9052 my $default_tries = $o->read_para_after(__FILE__, qr/MAGIC_tries/);
9053 if ( $default_tries ) {
9054 %default_tries = map {
9055 my $var_val = $_;
9056 my ($op, $tries, $wait) = $var_val =~ m/(\S+)/g;
9057 die "Invalid --tries value: $var_val\n" unless $op && $tries && $wait;
9058 die "Invalid --tries operation: $op\n" unless grep { $op eq $_ } @ops;
9059 die "Invalid --tries tries: $tries\n" unless $tries > 0;
9060 die "Invalid --tries wait: $wait\n" unless $wait > 0;
9061 $op => {
9062 tries => $tries,
9063 wait => $wait,
9064 };
9065 } grep { m/^\s+\w+\s+\d+\s+[\d\.]+/ } split("\n", $default_tries);
9066 }
9067
9068 my %tries = (
9069 %default_tries, # first the tool's defaults
9070 %user_tries, # then the user's which overwrite the defaults
9071 );
9072 PTDEBUG && _d('--tries:', Dumper(\%tries));
9073 return \%tries;
9074}
9075
9006sub check_alter {9076sub check_alter {
9007 my (%args) = @_;9077 my (%args) = @_;
9008 my @required_args = qw(alter tbl dry_run Cxn TableParser);9078 my @required_args = qw(alter tbl dry_run Cxn TableParser);
@@ -9300,15 +9370,15 @@
93009370
9301sub swap_tables {9371sub swap_tables {
9302 my (%args) = @_;9372 my (%args) = @_;
9303 my @required_args = qw(orig_tbl new_tbl Cxn Quoter OptionParser Retry retries stats);9373 my @required_args = qw(orig_tbl new_tbl Cxn Quoter OptionParser Retry tries stats);
9304 foreach my $arg ( @required_args ) {9374 foreach my $arg ( @required_args ) {
9305 die "I need a $arg argument" unless $args{$arg};9375 die "I need a $arg argument" unless $args{$arg};
9306 }9376 }
9307 my ($orig_tbl, $new_tbl, $cxn, $q, $o, $retry, $retries, $stats) = @args{@required_args};9377 my ($orig_tbl, $new_tbl, $cxn, $q, $o, $retry, $tries, $stats) = @args{@required_args};
93089378
9309 my $prefix = '_';9379 my $prefix = '_';
9310 my $table_name = $orig_tbl->{tbl} . ($args{suffix} || '');9380 my $table_name = $orig_tbl->{tbl} . ($args{suffix} || '');
9311 my $tries = 10; # don't try forever9381 my $name_tries = 10; # don't try forever
9312 my $table_exists = qr/table.+?already exists/i;9382 my $table_exists = qr/table.+?already exists/i;
93139383
9314 # This sub only works for --execute. Since the options are9384 # This sub only works for --execute. Since the options are
@@ -9326,7 +9396,7 @@
9326 elsif ( $o->get('execute') ) {9396 elsif ( $o->get('execute') ) {
9327 print "Swapping tables...\n";9397 print "Swapping tables...\n";
93289398
9329 while ( $tries-- ) {9399 while ( $name_tries-- ) {
9330 $table_name = $prefix . $table_name;9400 $table_name = $prefix . $table_name;
93319401
9332 if ( length($table_name) > 64 ) {9402 if ( length($table_name) > 64 ) {
@@ -9344,7 +9414,7 @@
9344 osc_retry(9414 osc_retry(
9345 Cxn => $cxn,9415 Cxn => $cxn,
9346 Retry => $retry,9416 Retry => $retry,
9347 retries => $retries,9417 tries => $tries->{swap_tables},
9348 stats => $stats,9418 stats => $stats,
9349 code => sub {9419 code => sub {
9350 PTDEBUG && _d($sql);9420 PTDEBUG && _d($sql);
@@ -9380,7 +9450,7 @@
93809450
9381 # This shouldn't happen.9451 # This shouldn't happen.
9382 # Here and in the attempt to find a new table name we probably ought to9452 # Here and in the attempt to find a new table name we probably ought to
9383 # use --retries (and maybe a Retry object?)9453 # use --tries (and maybe a Retry object?)
9384 die "Failed to find a unique old table name after serveral attempts.\n";9454 die "Failed to find a unique old table name after serveral attempts.\n";
9385 }9455 }
9386}9456}
@@ -9530,11 +9600,11 @@
9530 my ( %args ) = @_;9600 my ( %args ) = @_;
9531 my @required_args = qw(orig_tbl old_tbl child_tables stats9601 my @required_args = qw(orig_tbl old_tbl child_tables stats
9532 Cxn Quoter OptionParser TableParser9602 Cxn Quoter OptionParser TableParser
9533 Retry retries);9603 Retry tries);
9534 foreach my $arg ( @required_args ) {9604 foreach my $arg ( @required_args ) {
9535 die "I need a $arg argument" unless $args{$arg};9605 die "I need a $arg argument" unless $args{$arg};
9536 }9606 }
9537 my ($orig_tbl, $old_tbl, $child_tables, $stats, $cxn, $q, $o, $tp, $retry, $retries)9607 my ($orig_tbl, $old_tbl, $child_tables, $stats, $cxn, $q, $o, $tp, $retry, $tries)
9538 = @args{@required_args};9608 = @args{@required_args};
95399609
9540 # MySQL has a "feature" where if the parent tbl is in the same db,9610 # MySQL has a "feature" where if the parent tbl is in the same db,
@@ -9612,7 +9682,7 @@
9612 osc_retry(9682 osc_retry(
9613 Cxn => $cxn,9683 Cxn => $cxn,
9614 Retry => $retry,9684 Retry => $retry,
9615 retries => $retries,9685 tries => $tries->{update_foreign_keys},
9616 stats => $stats,9686 stats => $stats,
9617 code => sub {9687 code => sub {
9618 PTDEBUG && _d($sql);9688 PTDEBUG && _d($sql);
@@ -9632,11 +9702,11 @@
96329702
9633sub drop_swap {9703sub drop_swap {
9634 my ( %args ) = @_;9704 my ( %args ) = @_;
9635 my @required_args = qw(orig_tbl new_tbl Cxn OptionParser stats Retry retries);9705 my @required_args = qw(orig_tbl new_tbl Cxn OptionParser stats Retry tries);
9636 foreach my $arg ( @required_args ) {9706 foreach my $arg ( @required_args ) {
9637 die "I need a $arg argument" unless $args{$arg};9707 die "I need a $arg argument" unless $args{$arg};
9638 }9708 }
9639 my ($orig_tbl, $new_tbl, $cxn, $o, $stats, $retry, $retries) = @args{@required_args};9709 my ($orig_tbl, $new_tbl, $cxn, $o, $stats, $retry, $tries) = @args{@required_args};
96409710
9641 if ( $o->get('dry-run') ) {9711 if ( $o->get('dry-run') ) {
9642 print "Not drop-swapping tables because this is a dry run.\n";9712 print "Not drop-swapping tables because this is a dry run.\n";
@@ -9658,7 +9728,7 @@
9658 osc_retry(9728 osc_retry(
9659 Cxn => $cxn,9729 Cxn => $cxn,
9660 Retry => $retry,9730 Retry => $retry,
9661 retries => $retries,9731 tries => $tries->{update_foreign_keys},
9662 stats => $stats,9732 stats => $stats,
9663 code => sub {9733 code => sub {
9664 PTDEBUG && _d($sql);9734 PTDEBUG && _d($sql);
@@ -9677,11 +9747,11 @@
96779747
9678sub create_triggers {9748sub create_triggers {
9679 my ( %args ) = @_;9749 my ( %args ) = @_;
9680 my @required_args = qw(orig_tbl new_tbl del_tbl columns Cxn Quoter OptionParser Retry retries stats);9750 my @required_args = qw(orig_tbl new_tbl del_tbl columns Cxn Quoter OptionParser Retry tries stats);
9681 foreach my $arg ( @required_args ) {9751 foreach my $arg ( @required_args ) {
9682 die "I need a $arg argument" unless $args{$arg};9752 die "I need a $arg argument" unless $args{$arg};
9683 }9753 }
9684 my ($orig_tbl, $new_tbl, $del_tbl, $cols, $cxn, $q, $o, $retry, $retries, $stats) = @args{@required_args};9754 my ($orig_tbl, $new_tbl, $del_tbl, $cols, $cxn, $q, $o, $retry, $tries, $stats) = @args{@required_args};
96859755
9686 # This sub works for --dry-run and --execute. With --dry-run it's9756 # This sub works for --dry-run and --execute. With --dry-run it's
9687 # only interesting if --print is specified, too; then the user can9757 # only interesting if --print is specified, too; then the user can
@@ -9752,7 +9822,7 @@
9752 osc_retry(9822 osc_retry(
9753 Cxn => $cxn,9823 Cxn => $cxn,
9754 Retry => $retry,9824 Retry => $retry,
9755 retries => $retries,9825 tries => $tries->{create_triggers},
9756 stats => $stats,9826 stats => $stats,
9757 code => sub {9827 code => sub {
9758 PTDEBUG && _d($sql);9828 PTDEBUG && _d($sql);
@@ -9778,11 +9848,11 @@
97789848
9779sub drop_triggers {9849sub drop_triggers {
9780 my ( %args ) = @_;9850 my ( %args ) = @_;
9781 my @required_args = qw(tbl Cxn Quoter OptionParser Retry retries stats);9851 my @required_args = qw(tbl Cxn Quoter OptionParser Retry tries stats);
9782 foreach my $arg ( @required_args ) {9852 foreach my $arg ( @required_args ) {
9783 die "I need a $arg argument" unless $args{$arg};9853 die "I need a $arg argument" unless $args{$arg};
9784 }9854 }
9785 my ($tbl, $cxn, $q, $o, $retry, $retries, $stats) = @args{@required_args};9855 my ($tbl, $cxn, $q, $o, $retry, $tries, $stats) = @args{@required_args};
97869856
9787 # This sub works for --dry-run and --execute, although --dry-run is9857 # This sub works for --dry-run and --execute, although --dry-run is
9788 # only interesting with --print so the user can see the drop trigger9858 # only interesting with --print so the user can see the drop trigger
@@ -9802,7 +9872,7 @@
9802 osc_retry(9872 osc_retry(
9803 Cxn => $cxn,9873 Cxn => $cxn,
9804 Retry => $retry,9874 Retry => $retry,
9805 retries => $retries,9875 tries => $tries->{drop_triggers},
9806 stats => $stats,9876 stats => $stats,
9807 code => sub {9877 code => sub {
9808 PTDEBUG && _d($sql);9878 PTDEBUG && _d($sql);
@@ -9846,20 +9916,20 @@
98469916
9847sub osc_retry {9917sub osc_retry {
9848 my (%args) = @_;9918 my (%args) = @_;
9849 my @required_args = qw(Cxn Retry retries code stats);9919 my @required_args = qw(Cxn Retry tries code stats);
9850 foreach my $arg ( @required_args ) {9920 foreach my $arg ( @required_args ) {
9851 die "I need a $arg argument" unless $args{$arg};9921 die "I need a $arg argument" unless $args{$arg};
9852 }9922 }
9853 my $cxn = $args{Cxn};9923 my $cxn = $args{Cxn};
9854 my $retry = $args{Retry};9924 my $retry = $args{Retry};
9855 my $retries = $args{retries};9925 my $tries = $args{tries};
9856 my $code = $args{code};9926 my $code = $args{code};
9857 my $stats = $args{stats};9927 my $stats = $args{stats};
9858 my $ignore_errors = $args{ignore_errors};9928 my $ignore_errors = $args{ignore_errors};
98599929
9860 return $retry->retry(9930 return $retry->retry(
9861 tries => $retries,9931 tries => $tries->{tries},
9862 wait => sub { sleep 0.25; return; },9932 wait => sub { sleep ($tries->{wait} || 0.25) },
9863 try => $code,9933 try => $code,
9864 fail => sub {9934 fail => sub {
9865 my (%args) = @_;9935 my (%args) = @_;
@@ -9911,11 +9981,11 @@
99119981
9912sub exec_nibble {9982sub exec_nibble {
9913 my (%args) = @_;9983 my (%args) = @_;
9914 my @required_args = qw(Cxn tbl stats retries Retry NibbleIterator Quoter);9984 my @required_args = qw(Cxn tbl stats tries Retry NibbleIterator Quoter);
9915 foreach my $arg ( @required_args ) {9985 foreach my $arg ( @required_args ) {
9916 die "I need a $arg argument" unless $args{$arg};9986 die "I need a $arg argument" unless $args{$arg};
9917 }9987 }
9918 my ($cxn, $tbl, $stats, $retries, $retry, $nibble_iter, $q)9988 my ($cxn, $tbl, $stats, $tries, $retry, $nibble_iter, $q)
9919 = @args{@required_args};9989 = @args{@required_args};
99209990
9921 my $sth = $nibble_iter->statements();9991 my $sth = $nibble_iter->statements();
@@ -9952,7 +10022,7 @@
9952 return osc_retry(10022 return osc_retry(
9953 Cxn => $cxn,10023 Cxn => $cxn,
9954 Retry => $retry,10024 Retry => $retry,
9955 retries => $retries,10025 tries => $tries->{copy_rows},
9956 stats => $stats,10026 stats => $stats,
9957 code => sub {10027 code => sub {
9958 # ###################################################################10028 # ###################################################################
@@ -10396,13 +10466,6 @@
10396NAMES UTF8 after connecting to MySQL. Any other value sets binmode on STDOUT10466NAMES UTF8 after connecting to MySQL. Any other value sets binmode on STDOUT
10397without the utf8 layer, and runs SET NAMES after connecting to MySQL.10467without the utf8 layer, and runs SET NAMES after connecting to MySQL.
1039810468
10399=item --check-interval
10400
10401type: time; default: 1
10402
10403Sleep time between checks for L<"--max-lag">.
10404
10405
10406=item --[no]check-alter10469=item --[no]check-alter
1040710470
10408default: yes10471default: yes
@@ -10434,6 +10497,12 @@
1043410497
10435=back10498=back
1043610499
10500=item --check-interval
10501
10502type: time; default: 1
10503
10504Sleep time between checks for L<"--max-lag">.
10505
10437=item --[no]check-plan10506=item --[no]check-plan
1043810507
10439default: yes10508default: yes
@@ -10814,46 +10883,6 @@
10814table. Currently, the DSNs are ordered by id, but id and parent_id are otherwise10883table. Currently, the DSNs are ordered by id, but id and parent_id are otherwise
10815ignored. 10884ignored.
1081610885
10817=item --retries
10818
10819type: int; default: 10
10820
10821Retry critical operations and recover from non-fatal errors. The tool
10822retries these operations:
10823
10824 Creating triggers
10825 Dropping triggers
10826 Copying chunks
10827 Swapping tables
10828 Rebuilding foreign key constraints
10829
10830For creating and dropping triggers, the number of retries applies to each
10831C<CREATE TRIGGER> and C<DROP TRIGGER> statement for each trigger.
10832For copying chunks, the number of retries applies to each chunk, not the
10833entire table. For swapping tables, the number of retries usually applies
10834once because there is usually only one C<RENAME TABLE> statement.
10835For rebuilding foreign key constraints, the number of retries applies to
10836each statement (C<ALTER> statements for the C<rebuild_constraints>
10837L<"--alter-foreign-keys-method">; other statements for the C<drop_swap>
10838method).
10839
10840The tool retries each operation if these errors occur:
10841
10842 Lock wait timeout (innodb_lock_wait_timeout and lock_wait_timeout)
10843 Deadlock found
10844 Query is killed (KILL QUERY <thread_id>)
10845 Connection is killed (KILL CONNECTION <thread_id>)
10846 Lost connection to MySQL
10847
10848In the case of lost and killed connections, the tool will automatically
10849reconnect.
10850
10851To alter extremely busy tables, it may be necessary to increase L<"--retries">,
10852and also C<innodb_lock_wait_timeout> and (for MySQL 5.5 and newer)
10853C<lock_wait_timeout> by specifying higher values with L<"--set-vars">.
10854
10855Failures and retries are recorded in the L<"--statistics">.
10856
10857=item --set-vars10886=item --set-vars
1085810887
10859type: Array10888type: Array
@@ -10895,6 +10924,65 @@
10895place of the original table. The original table becomes the "old table," and10924place of the original table. The original table becomes the "old table," and
10896the tool drops it unless you disable L<"--[no]drop-old-table">.10925the tool drops it unless you disable L<"--[no]drop-old-table">.
1089710926
10927=item --tries
10928
10929type: array
10930
10931How many times to try critical operations. If certain operations fail due
10932to non-fatal, recoverable errors, the tool waits and tries the operation
10933again. These are the operations that are retried, with their default number
10934of tries and wait time between tries (in seconds):
10935
10936=for comment ignore-pt-internal-value
10937MAGIC_tries
10938
10939 OPERATION TRIES WAIT
10940 =================== ===== ====
10941 create_triggers 10 1
10942 drop_triggers 10 1
10943 copy_rows 10 0.25
10944 swap_tables 10 1
10945 update_foreign_keys 10 1
10946
10947To change the defaults, specify the new values like:
10948
10949 --tries create_triggers:5:0.5,drop_triggers:5:0.5
10950
10951That makes the tool try C<create_triggers> and C<drop_triggers> 2 times
10952with a 0.5 second wait between tries. So the format is:
10953
10954 operation:tries:wait[,operation:tries:wait]
10955
10956All three values must be specified.
10957
10958Note that most operations are affected only in MySQL 5.5 and newer by
10959C<lock_wait_timeout> (see L<"--set-vars">) because of metadata locks.
10960The C<copy_rows> operation is affected in any version of MySQL by
10961C<innodb_lock_wait_timeout>.
10962
10963For creating and dropping triggers, the number of tries applies to each
10964C<CREATE TRIGGER> and C<DROP TRIGGER> statement for each trigger.
10965For copying rows, the number of tries applies to each chunk, not the
10966entire table. For swapping tables, the number of tries usually applies
10967once because there is usually only one C<RENAME TABLE> statement.
10968For rebuilding foreign key constraints, the number of tries applies to
10969each statement (C<ALTER> statements for the C<rebuild_constraints>
10970L<"--alter-foreign-keys-method">; other statements for the C<drop_swap>
10971method).
10972
10973The tool retries each operation if these errors occur:
10974
10975 Lock wait timeout (innodb_lock_wait_timeout and lock_wait_timeout)
10976 Deadlock found
10977 Query is killed (KILL QUERY <thread_id>)
10978 Connection is killed (KILL CONNECTION <thread_id>)
10979 Lost connection to MySQL
10980
10981In the case of lost and killed connections, the tool will automatically
10982reconnect.
10983
10984Failures and retries are recorded in the L<"--statistics">.
10985
10898=item --user10986=item --user
1089910987
10900short form: -u; type: string10988short form: -u; type: string
1090110989
=== modified file 'lib/Retry.pm'
--- lib/Retry.pm 2013-01-03 00:19:16 +0000
+++ lib/Retry.pm 2013-03-05 23:44:21 +0000
@@ -27,6 +27,8 @@
27use English qw(-no_match_vars);27use English qw(-no_match_vars);
28use constant PTDEBUG => $ENV{PTDEBUG} || 0;28use constant PTDEBUG => $ENV{PTDEBUG} || 0;
2929
30use Time::HiRes qw(sleep);
31
30sub new {32sub new {
31 my ( $class, %args ) = @_;33 my ( $class, %args ) = @_;
32 my $self = {34 my $self = {
3335
=== modified file 't/pt-online-schema-change/metadata_locks.t'
--- t/pt-online-schema-change/metadata_locks.t 2013-02-28 19:29:17 +0000
+++ t/pt-online-schema-change/metadata_locks.t 2013-03-05 23:44:21 +0000
@@ -51,7 +51,8 @@
51($output) = full_output(51($output) = full_output(
52 sub { pt_online_schema_change::main(52 sub { pt_online_schema_change::main(
53 "$master_dsn,D=pt_osc,t=t",53 "$master_dsn,D=pt_osc,t=t",
54 qw(--statistics --execute --retries 2 --set-vars lock_wait_timeout=1),54 qw(--statistics --execute --tries create_triggers:2:0.1),
55 qw(--set-vars lock_wait_timeout=1),
55 '--plugin', "$plugin/block_create_triggers.pm",56 '--plugin', "$plugin/block_create_triggers.pm",
56 )},57 )},
57 stderr => 1,58 stderr => 1,
@@ -76,7 +77,8 @@
76($output) = full_output(77($output) = full_output(
77 sub { pt_online_schema_change::main(78 sub { pt_online_schema_change::main(
78 "$master_dsn,D=pt_osc,t=t",79 "$master_dsn,D=pt_osc,t=t",
79 qw(--statistics --execute --retries 2 --set-vars lock_wait_timeout=1),80 qw(--statistics --execute --tries swap_tables:2:0.1),
81 qw(--set-vars lock_wait_timeout=1),
80 '--plugin', "$plugin/block_swap_tables.pm",82 '--plugin', "$plugin/block_swap_tables.pm",
81 )},83 )},
82 stderr => 1,84 stderr => 1,
8385
=== modified file 't/pt-online-schema-change/samples/stats-dry-run.txt'
--- t/pt-online-schema-change/samples/stats-dry-run.txt 2013-02-28 19:29:17 +0000
+++ t/pt-online-schema-change/samples/stats-dry-run.txt 2013-03-05 23:44:21 +0000
@@ -1,3 +1,9 @@
1Operation, tries, wait:
2 copy_rows, 10, 0.25
3 create_triggers, 10, 1
4 drop_triggers, 10, 1
5 swap_tables, 10, 1
6 update_foreign_keys, 10, 1
1Starting a dry run. `bug_1045317`.`bits` will not be altered. Specify --execute instead of --dry-run to alter the table.7Starting a dry run. `bug_1045317`.`bits` will not be altered. Specify --execute instead of --dry-run to alter the table.
2Not dropping triggers because this is a dry run.8Not dropping triggers because this is a dry run.
3Dropping new table...9Dropping new table...
410
=== modified file 't/pt-online-schema-change/samples/stats-execute-5.5.txt'
--- t/pt-online-schema-change/samples/stats-execute-5.5.txt 2013-02-28 19:29:17 +0000
+++ t/pt-online-schema-change/samples/stats-execute-5.5.txt 2013-03-05 23:44:21 +0000
@@ -1,3 +1,9 @@
1Operation, tries, wait:
2 copy_rows, 10, 0.25
3 create_triggers, 10, 1
4 drop_triggers, 10, 1
5 swap_tables, 10, 1
6 update_foreign_keys, 10, 1
1Altering `bug_1045317`.`bits`...7Altering `bug_1045317`.`bits`...
2Dropping triggers...8Dropping triggers...
3Dropped triggers OK.9Dropped triggers OK.
410
=== modified file 't/pt-online-schema-change/samples/stats-execute.txt'
--- t/pt-online-schema-change/samples/stats-execute.txt 2013-03-01 02:00:07 +0000
+++ t/pt-online-schema-change/samples/stats-execute.txt 2013-03-05 23:44:21 +0000
@@ -1,3 +1,9 @@
1Operation, tries, wait:
2 copy_rows, 10, 0.25
3 create_triggers, 10, 1
4 drop_triggers, 10, 1
5 swap_tables, 10, 1
6 update_foreign_keys, 10, 1
1Altering `bug_1045317`.`bits`...7Altering `bug_1045317`.`bits`...
2Dropping triggers...8Dropping triggers...
3Dropped triggers OK.9Dropped triggers OK.

Subscribers

People subscribed via source and target branches