From e178fb6ef13d7db7c12d44fb57c1c476766eadc1 Mon Sep 17 00:00:00 2001 From: Frank Cizmich Date: Wed, 18 Mar 2015 13:56:23 -0300 Subject: [PATCH] pt-osc disable interrupts during drop_swap --- bin/pt-online-schema-change | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/bin/pt-online-schema-change b/bin/pt-online-schema-change index 7ddc6a0f..09f6f60a 100755 --- a/bin/pt-online-schema-change +++ b/bin/pt-online-schema-change @@ -7970,6 +7970,7 @@ use sigtrap 'handler', \&sig_int, 'normal-signals'; my $exit_status = 0; my $oktorun = 1; +my $dont_interrupt_now = 0; my @drop_trigger_sqls; my @triggers_not_dropped; @@ -7983,6 +7984,7 @@ sub main { $oktorun = 1; @drop_trigger_sqls = (); @triggers_not_dropped = (); + $dont_interrupt_now = 0; my %stats = ( INSERT => 0, @@ -10251,6 +10253,11 @@ sub drop_swap { "DROP TABLE IF EXISTS $orig_tbl->{name}", "RENAME TABLE $new_tbl->{name} TO $orig_tbl->{name}", ); + + # we don't want to be interrupted during the swap! + # since it might leave original table dropped + # https://bugs.launchpad.net/percona-toolkit/+bug/1368244 + $dont_interrupt_now = 1; foreach my $sql ( @sqls ) { PTDEBUG && _d($sql); @@ -10269,6 +10276,8 @@ sub drop_swap { } } + $dont_interrupt_now = 0; + if ( $o->get('execute') ) { print ts("Dropped and swapped tables OK.\n"); } @@ -10667,6 +10676,11 @@ sub ts { # Catches signals so we can exit gracefully. sub sig_int { my ( $signal ) = @_; + if ( $dont_interrupt_now ) { + # we're in the middle of something that shouldn't be interrupted + PTDEBUG && _d("Received Signal: \"$signal\" in middle of critical operation. Continuing anyway."); + return; + } $oktorun = 0; # flag for cleanup tasks print STDERR "# Exiting on SIG$signal.\n"; # restore terminal to normal state in case CTL+C issued while