diff --git a/bin/pt-online-schema-change b/bin/pt-online-schema-change index 8b71631e..57fd8b59 100755 --- a/bin/pt-online-schema-change +++ b/bin/pt-online-schema-change @@ -8415,14 +8415,19 @@ sub main { my $cleanup = new CleanupTask( sub { # XXX We shouldn't copy $EVAL_ERROR here, but I found that - # errors are not re-thrown in tests. If you comment out this + # errors are not re-thrown in tests. If you comment (*) out this # line and the die below, an error fails: # not ok 5 - Doesn't try forever to find a new table name # Failed test 'Doesn't try forever to find a new table name' # at /Users/daniel/p/pt-osc-2.1.1/lib/PerconaTest.pm line 559. # '' # doesn't match '(?-xism:Failed to find a unique new table name)' - my $original_error = $EVAL_ERROR; + + # (*) Frank: commented them out because it caused infinite loop + # and the mentioned test error doesn't arise + + #my $original_error = $EVAL_ERROR; + foreach my $task ( reverse @cleanup_tasks ) { eval { $task->(); @@ -8431,7 +8436,7 @@ sub main { warn "Error cleaning up: $EVAL_ERROR\n"; } } - die $original_error if $original_error; # rethrow original error + #die $original_error if $original_error; # rethrow original error return; } ); diff --git a/t/pt-online-schema-change/bugs.t b/t/pt-online-schema-change/bugs.t index 7ddb9b6b..72250d9c 100644 --- a/t/pt-online-schema-change/bugs.t +++ b/t/pt-online-schema-change/bugs.t @@ -433,6 +433,31 @@ $output = output( # clear databases $sb->load_file('master', "$sample/bug-1340728_cleanup.sql"); + +# ############################################################################# +# Issue LP 1446928 +# Avoids an error trapping loop when --alter option contains an invalid +# statement. +# If this test fails it might lead to "segmentation fault" or "out of memory" +# ############################################################################# + +$output = output( + sub { pt_online_schema_change::main(@args, "$master_dsn,D=sakila,t=actor", + '--execute', + '--alter-foreign-keys-method=drop_swap', + '--alter', "GIBBERISH", + '--nocheck-plan', + ), + }, + stderr => 1, +); + +like( + $output, + qr/Error altering new table/s, + "Bug 1446928: Avoid error trapping loop when --alter is invalid", +); + # ############################################################################# # Done. # #############################################################################