From db8207b1ed2a4521f65b734eb365e0cbe3407612 Mon Sep 17 00:00:00 2001 From: Francois Lallart Date: Thu, 14 Nov 2019 14:35:01 +0100 Subject: [PATCH 1/3] Add --unstop option to remove sentinel file. --- bin/pt-archiver | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/bin/pt-archiver b/bin/pt-archiver index 6a618e42..c6756bee 100755 --- a/bin/pt-archiver +++ b/bin/pt-archiver @@ -6240,6 +6240,12 @@ sub main { return 0; } + # Remove sentinel file. + if ( $o->get('unstop') ) { + unlink $sentinel + or die "Cannot unlink sentinel file: $OS_ERROR\n"; + } + # Generate a filename with sprintf-like formatting codes. if ( $archive_file ) { my @time = localtime(); @@ -8372,6 +8378,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. + =item --user short form: -u; type: string From c1b751927cab4daec8f2b6e2353e4703042ffde9 Mon Sep 17 00:00:00 2001 From: Sveta Smirnova Date: Tue, 7 Nov 2023 16:24:08 +0300 Subject: [PATCH 2/3] Follow_PR-429_unstop_option_with_testcase - Added information message about removing sentinel file - Added cross-links for options --stop and --unstop in docs - Added test case --- bin/pt-archiver | 6 ++++-- t/pt-archiver/standard_options.t | 21 ++++++++++++++++++++- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/bin/pt-archiver b/bin/pt-archiver index c6756bee..302f93da 100755 --- a/bin/pt-archiver +++ b/bin/pt-archiver @@ -6244,6 +6244,8 @@ sub main { if ( $o->get('unstop') ) { unlink $sentinel or die "Cannot unlink sentinel file: $OS_ERROR\n"; + print STDOUT "Successfully removed file $sentinel\n" + unless $quiet; } # Generate a filename with sprintf-like formatting codes. @@ -8351,7 +8353,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 @@ -8383,7 +8385,7 @@ want to disable transactions so pt-archiver doesn't try to commit. Remove sentinel file Causes pt-archiver to remove the sentinel file specified by L<"--sentinel"> and -continue. +continue. See also L<"--stop">. =item --user 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 From 52cc6c11dea340019f113e2525794224dba37507 Mon Sep 17 00:00:00 2001 From: Sveta Smirnova Date: Sun, 12 Nov 2023 23:26:14 +0300 Subject: [PATCH 3/3] Follow PR-429 unstop option with testcase - Review by Evgeniy - print path to the sentinel file in case of error --- bin/pt-archiver | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/pt-archiver b/bin/pt-archiver index 302f93da..3b89dba1 100755 --- a/bin/pt-archiver +++ b/bin/pt-archiver @@ -6243,7 +6243,7 @@ sub main { # Remove sentinel file. if ( $o->get('unstop') ) { unlink $sentinel - or die "Cannot unlink sentinel file: $OS_ERROR\n"; + or die "Cannot unlink sentinel file ${sentinel}: $OS_ERROR\n"; print STDOUT "Successfully removed file $sentinel\n" unless $quiet; }