diff --git a/bin/pt-archiver b/bin/pt-archiver index fda2d5ca..3a285648 100755 --- a/bin/pt-archiver +++ b/bin/pt-archiver @@ -6332,6 +6332,41 @@ in long table scans if you're trying to nibble from the end of the table by an index other than the one it prefers. See L<"--source"> and read the documentation on the C part if this applies to you. +=head1 Percona XtraDB Cluster + +pt-archiver works with Percona XtraDB Cluster (PXC) 5.5.28-23.7 and newer, +but there are three limitations you should consider before archiving on +a cluster: + +=over + +=item Error on commit + +pt-archiver does not check for error when it commits transactions. +Commits on PXC can fail, but the tool does not yet check for or retry the +transaction when this happens. If it happens, the tool will die. + +=item MyISAM tables + +Archiving MyISAM tables works, but MyISAM support in PXC is still +experimental at the time of this release. There are several known bugs with +PXC, MyISAM tables, and C columns. Therefore, you must ensure +that archiving will not directly or indirectly result in the use of default +C values for a MyISAM table. For example, this happens with +L<"--dest"> if L<"--columns"> is used and the C column is not +included. The tool does not check for this! + +=item Non-cluster options + +Certain options may or may not work. For example, if a cluster node +is not also a slave, then L<"--check-slave-lag"> does not work. And since PXC +tables are usually InnoDB, but InnoDB doesn't support C, then +L<"--delayed-insert"> does not work. Other options may also not work, but +the tool does not check them, therefore you should test archiving on a test +cluster before archiving on your real cluster. + +=back + =head1 OUTPUT If you specify L<"--progress">, the output is a header row, plus status output diff --git a/t/pt-archiver/pxc.t b/t/pt-archiver/pxc.t index 15c45921..663d8e75 100644 --- a/t/pt-archiver/pxc.t +++ b/t/pt-archiver/pxc.t @@ -312,6 +312,94 @@ check_rows( expect => $expected_rows, ); +# ############################################################################# +# Repeat some of the above tests with MyISAM. +# ############################################################################# + +$sb->load_file('node1', 't/pt-archiver/samples/table14.sql'); +$expected_rows = $node1_dbh->selectall_arrayref( + "SELECT * FROM test.table_1 ORDER BY a"); +$node1_dbh->do("INSERT INTO test.table_2 SELECT * FROM test.table_1"); + +# Since there's no auto-inc column, all rows should be purged on all nodes. +$output = output( + sub { + pt_archiver::main(@args, '--source', "D=test,t=table_1,F=$node1_cnf", + qw(--purge)) + }, + stderr => 1, +); + +check_rows( + name => "MyISAM: Purged all rows", + sql => "SELECT * FROM test.table_1 ORDER BY a", + expect => [], +); + + +# table_2 has an auto-inc, so all rows less the max auto-inc row +# should be purged on all nodes. This is due to --[no]safe-auto-increment. +$output = output( + sub { + pt_archiver::main(@args, '--source', "D=test,t=table_2,F=$node1_cnf", + qw(--purge)) + }, + stderr => 1, +); + +check_rows( + name => "MyISAM: Purged rows less max auto-inc", + sql => "SELECT * FROM test.table_2 ORDER BY a", + expect => [[qw(4 2 3), "\n"]], +); + +# Archive rows to another MyISAM table. + +# Same node +$sb->load_file('node1', 't/pt-archiver/samples/table14.sql'); +$output = output( + sub { + pt_archiver::main(@args, '--source', "D=test,t=table_1,F=$node1_cnf", + qw(--dest t=table_2)) + }, + stderr => 1, +); + +check_rows( + name => "MyISAM: Rows purged from table_1 (same node)", + sql => "SELECT * FROM test.table_1 ORDER BY a", + expect => [], +); + +check_rows( + name => "MyISAM: Rows archived to table_2 (same node)", + sql => "SELECT * FROM test.table_2 ORDER BY a", + expect => $expected_rows, +); + +# To another node +$sb->load_file('node1', 't/pt-archiver/samples/table14.sql'); + +$output = output( + sub { + pt_archiver::main(@args, '--source', "D=test,t=table_1,F=$node1_cnf", + '--dest', "F=$node2_cnf,D=test,t=table_2") + }, + stderr => 1, +); + +check_rows( + name => "MyISAM: Rows purged from table_1 (cross-node)", + sql => "SELECT * FROM test.table_1 ORDER BY a", + expect => [], +); + +check_rows( + name => "MyISAM: Rows archived to table_2 (cross-node)", + sql => "SELECT * FROM test.table_2 ORDER BY a", + expect => $expected_rows, +); + # ############################################################################# # Done. # ############################################################################# diff --git a/t/pt-archiver/samples/table14.sql b/t/pt-archiver/samples/table14.sql new file mode 100644 index 00000000..83766a7f --- /dev/null +++ b/t/pt-archiver/samples/table14.sql @@ -0,0 +1,25 @@ +use test; + +drop table if exists table_1; +drop table if exists table_2; + +create table table_1( + a int not null primary key, + b int, + c int not null, + d varchar(50), + key(b) +) engine=myisam; + +create table table_2( + a int not null primary key auto_increment, + b int, + c int not null, + d varchar(50) +) engine=myisam; + +insert into table_1 values + (1, 2, 3, 4), + (2, null, 3, 4), + (3, 2, 3, "\t"), + (4, 2, 3, "\n");