diff --git a/bin/pt-archiver b/bin/pt-archiver index 99182d9f..c6992c41 100755 --- a/bin/pt-archiver +++ b/bin/pt-archiver @@ -6240,6 +6240,14 @@ sub main { return 0; } + # Remove sentinel file. + if ( $o->get('unstop') ) { + unlink $sentinel + or die "Cannot unlink sentinel file ${sentinel}: $OS_ERROR\n"; + print STDOUT "Successfully removed file $sentinel\n" + unless $quiet; + } + # Generate a filename with sprintf-like formatting codes. if ( $archive_file ) { my @time = localtime(); @@ -8347,7 +8355,7 @@ Stop running instances by creating the sentinel file. Causes pt-archiver to create the sentinel file specified by L<"--sentinel"> and exit. This should have the effect of stopping all running instances which are -watching the same sentinel file. +watching the same sentinel file. See also L<"--unstop">. =item --txn-size @@ -8374,6 +8382,13 @@ autocommit, dropped performance to 38 seconds per thousand rows. If you are not archiving from or to a transactional storage engine, you may want to disable transactions so pt-archiver doesn't try to commit. +=item --unstop + +Remove sentinel file + +Causes pt-archiver to remove the sentinel file specified by L<"--sentinel"> and +continue. See also L<"--stop">. + =item --user short form: -u; type: string diff --git a/t/pt-archiver/standard_options.t b/t/pt-archiver/standard_options.t index 38055ca5..0d941414 100644 --- a/t/pt-archiver/standard_options.t +++ b/t/pt-archiver/standard_options.t @@ -84,7 +84,26 @@ like( 'Created the sentinel OK' ); -diag(`rm -f $sentinel`); +# Test --unstop, which removes the sentinel +$output = output( + sub { pt_archiver::main("--source", "D=test,t=table_1,F=$cnf", + qw(--where 1=1 --why-quit --purge), + "--sentinel", $sentinel, "--unstop") + }, +); + +like( + $output, + qr/Successfully removed file $sentinel/, + 'Removed the sentinel OK' +) or diag($output); + +$output = `/tmp/12345/use -N -e "select count(*) from test.table_1"`; +is( + $output + 0, + 0, + 'Rows were deleted' +) or diag($output); # ############################################################################# # Issue 391: Add --pid option to mk-table-sync