mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-07 21:09:14 +00:00
Add --execute and die unless it's given. Enhance docu/risks about replication.
This commit is contained in:
@@ -4110,6 +4110,13 @@ sub main {
|
||||
# #####################################################################
|
||||
# Do the online alter.
|
||||
# #####################################################################
|
||||
if ( !$o->get('execute') ) {
|
||||
msg("Exiting without altering $db.$tbl because you did not "
|
||||
. "specify --execute. Please read the tool's documentation "
|
||||
. "carefully before using this tool.");
|
||||
return $exit_status;
|
||||
}
|
||||
|
||||
msg("Starting online schema change");
|
||||
eval {
|
||||
my $sql = "";
|
||||
@@ -4510,12 +4517,12 @@ whether known or unknown, of using this tool. The two main categories of risks
|
||||
are those created by the nature of the tool (e.g. read-only tools vs. read-write
|
||||
tools) and those created by bugs.
|
||||
|
||||
pt-online-schema-change reads, writes, alters and drops tables. Although
|
||||
it is tested, do not use it in production until you have thoroughly tested it
|
||||
in your environment!
|
||||
pt-online-schema-change alters tables and data, therefore it is a high-risk
|
||||
tool. Although the tool is tested and is known to work, you should not use
|
||||
it in production until you have thoroughly tested it in your environment!
|
||||
|
||||
This tool has not been tested with replication; it may break replication.
|
||||
See L<"REPLICATION">.
|
||||
This tool has not been tested with replication, and it can break replication
|
||||
if not used properly. See L<"REPLICATION">.
|
||||
|
||||
At the time of this release there are no known bugs that pose a serious risk.
|
||||
|
||||
@@ -4604,8 +4611,24 @@ the tool might do before actually doing it.
|
||||
|
||||
=head1 REPLICATION
|
||||
|
||||
In brief: update slaves first if columns are added or removed. Certain
|
||||
ALTER changes like ENGINE may not affect replication.
|
||||
If you use pt-online-schema-change to alter a table on a server with slaves,
|
||||
be aware that:
|
||||
|
||||
=over
|
||||
|
||||
=item * The tool is not tested with replication
|
||||
|
||||
=item * The tool can break replication if not used properly
|
||||
|
||||
=item * Although the tool sets SQL_BIN_LOG=0 by default (unless L<"--bin-log"> is specified), triggers which track changes to the table being altered still write statements to the binary log
|
||||
|
||||
=item * Replicaiton will break if you alter a table on a master that does not exist on a slave
|
||||
|
||||
=item * Update slaves first if columns are being added or removed
|
||||
|
||||
=item * Do not use this tool in production before testing it
|
||||
|
||||
=back
|
||||
|
||||
=head1 OUTPUT
|
||||
|
||||
@@ -4737,6 +4760,13 @@ swapped for the original table), then the old table can be restored.
|
||||
If altering a table with foreign key constraints, you may need to specify
|
||||
this option depending on which L<"--update-foreign-keys-method"> you choose.
|
||||
|
||||
=item --execute
|
||||
|
||||
Alter the table. This option must be specified to alter the table, else
|
||||
the tool will only check the table and exit. This helps ensure that the
|
||||
user has read the documentation and is aware of the inherent risks of using
|
||||
this tool.
|
||||
|
||||
=item --[no]foreign-key-checks
|
||||
|
||||
default: yes
|
||||
|
@@ -33,7 +33,7 @@ else {
|
||||
|
||||
my $output = "";
|
||||
my $cnf = '/tmp/12345/my.sandbox.cnf';
|
||||
my @args = ('-F', $cnf);
|
||||
my @args = ('-F', $cnf, '--execute');
|
||||
my $exit = 0;
|
||||
my $rows;
|
||||
|
||||
|
@@ -29,12 +29,12 @@ elsif ( !$slave_dbh ) {
|
||||
plan skip_all => 'Cannot connect to sandbox slave';
|
||||
}
|
||||
else {
|
||||
plan tests => 24;
|
||||
plan tests => 25;
|
||||
}
|
||||
|
||||
my $output = "";
|
||||
my $cnf = '/tmp/12345/my.sandbox.cnf';
|
||||
my @args = ('-F', $cnf);
|
||||
my @args = ('-F', $cnf, '--execute');
|
||||
my $exit = 0;
|
||||
my $rows;
|
||||
|
||||
@@ -43,6 +43,19 @@ PerconaTest::wait_for_table($slave_dbh, "mkosc.a", "c='r'");
|
||||
$master_dbh->do('use mkosc');
|
||||
$slave_dbh->do('use mkosc');
|
||||
|
||||
# #############################################################################
|
||||
# Tool shouldn't run without --execute (bug 933232).
|
||||
# #############################################################################
|
||||
$output = output(
|
||||
sub { pt_online_schema_change::main('h=127.1,P=12345,u=msandbox,p=msandbox,D=mkosc,t=a') },
|
||||
);
|
||||
|
||||
like(
|
||||
$output,
|
||||
qr/you did not specify --execute/,
|
||||
"Doesn't run without --execute"
|
||||
);
|
||||
|
||||
# #############################################################################
|
||||
# --check-tables-and-exit
|
||||
# #############################################################################
|
||||
|
@@ -9,7 +9,7 @@ BEGIN {
|
||||
use strict;
|
||||
use warnings FATAL => 'all';
|
||||
use English qw(-no_match_vars);
|
||||
use Test::More tests => 4;
|
||||
use Test::More tests => 5;
|
||||
|
||||
use PerconaTest;
|
||||
|
||||
@@ -44,6 +44,13 @@ like(
|
||||
"Either DSN D part or --database required"
|
||||
);
|
||||
|
||||
$output = `$cmd --help`;
|
||||
like(
|
||||
$output,
|
||||
qr/--execute\s+FALSE/,
|
||||
"--execute FALSE by default"
|
||||
);
|
||||
|
||||
# #############################################################################
|
||||
# Done.
|
||||
# #############################################################################
|
||||
|
Reference in New Issue
Block a user