mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-12-19 01:09:21 +08:00
pt-archiver & tests: Deal with LOAD DATA LOCAL INFILE being disabled.
This occasionally shows up in some OSs, like Ubuntu 12.04 LTS.
This commit is contained in:
@@ -3945,6 +3945,22 @@ sub main {
|
|||||||
$dp->get_cxn_params($table), { AutoCommit => $ac });
|
$dp->get_cxn_params($table), { AutoCommit => $ac });
|
||||||
PTDEBUG && _d('Inspecting table on', $dp->as_string($table));
|
PTDEBUG && _d('Inspecting table on', $dp->as_string($table));
|
||||||
|
|
||||||
|
if ( $o->get('bulk-insert') ) {
|
||||||
|
local $@;
|
||||||
|
my $sql = "LOAD DATA LOCAL INFILE '/dev/null' INTO TABLE "
|
||||||
|
. "`test`.`pt_not_there`";
|
||||||
|
eval { $dbh->do($sql); 1 } or do {
|
||||||
|
my $e = $@;
|
||||||
|
my $error_re = qr/\QDBD::mysql::db do failed: The used command is not allowed with this MySQL version [for Statement "LOAD DATA LOCAL INFILE/;
|
||||||
|
if ($e =~ $error_re) {
|
||||||
|
$dbh->disconnect();
|
||||||
|
die("--bulk-insert cannot work as LOAD DATA LOCAL INFILE "
|
||||||
|
. "is disabled. See http://kb.percona.com/troubleshoot-load-data-infile"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
# Set options that can enable removing data on the master and archiving it
|
# Set options that can enable removing data on the master and archiving it
|
||||||
# on the slaves.
|
# on the slaves.
|
||||||
if ( $table->{a} ) {
|
if ( $table->{a} ) {
|
||||||
|
|||||||
@@ -51,6 +51,9 @@ make_sandbox() {
|
|||||||
if [ -n "$MULTIPLE_BUFFER_POOLS" ]; then
|
if [ -n "$MULTIPLE_BUFFER_POOLS" ]; then
|
||||||
echo "innodb_buffer_pool_instances=$MULTIPLE_BUFFER_POOLS" >> /tmp/$port/my.sandbox.cnf
|
echo "innodb_buffer_pool_instances=$MULTIPLE_BUFFER_POOLS" >> /tmp/$port/my.sandbox.cnf
|
||||||
fi
|
fi
|
||||||
|
if [ -n "$LOCAL_INFILE" ]; then
|
||||||
|
echo "local-infile=$LOCAL_INFILE" >> /tmp/$port/my.sandbox.cnf
|
||||||
|
fi
|
||||||
|
|
||||||
# If the sandbox is a slave, set it read_only.
|
# If the sandbox is a slave, set it read_only.
|
||||||
if [ "$type" = "slave" ]; then
|
if [ "$type" = "slave" ]; then
|
||||||
|
|||||||
@@ -22,8 +22,12 @@ my $dbh = $sb->get_dbh_for('master');
|
|||||||
if ( !$dbh ) {
|
if ( !$dbh ) {
|
||||||
plan skip_all => 'Cannot connect to sandbox master';
|
plan skip_all => 'Cannot connect to sandbox master';
|
||||||
}
|
}
|
||||||
|
elsif ( PerconaTest::load_data_is_disabled($dbh) ) {
|
||||||
|
diag("LOAD DATA LOCAL INFILE is disabled, only going to test the error message");
|
||||||
|
plan tests => 2;
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
plan tests => 10;
|
plan tests => 11;
|
||||||
}
|
}
|
||||||
|
|
||||||
my $output;
|
my $output;
|
||||||
@@ -34,6 +38,10 @@ my $cmd = "$trunk/bin/pt-archiver";
|
|||||||
$sb->wipe_clean($dbh);
|
$sb->wipe_clean($dbh);
|
||||||
$sb->create_dbs($dbh, ['test']);
|
$sb->create_dbs($dbh, ['test']);
|
||||||
|
|
||||||
|
if ( PerconaTest::load_data_is_disabled($dbh) ) {
|
||||||
|
test_disabled_load_data($dbh, $sb);
|
||||||
|
}
|
||||||
|
else {
|
||||||
# Test --bulk-insert
|
# Test --bulk-insert
|
||||||
$sb->load_file('master', 't/pt-archiver/samples/table5.sql');
|
$sb->load_file('master', 't/pt-archiver/samples/table5.sql');
|
||||||
$dbh->do('INSERT INTO `test`.`table_5_copy` SELECT * FROM `test`.`table_5`');
|
$dbh->do('INSERT INTO `test`.`table_5_copy` SELECT * FROM `test`.`table_5`');
|
||||||
@@ -84,6 +92,43 @@ is_deeply(
|
|||||||
"--bulk-insert archived 7 rows (issue 1260)"
|
"--bulk-insert archived 7 rows (issue 1260)"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
# Test that the tool bails out early if LOAD DATA LOCAL INFILE is disabled
|
||||||
|
{
|
||||||
|
if ( -d "/tmp/2900" ) {
|
||||||
|
diag(`$trunk/sandbox/stop-sandbox 2900 >/dev/null 2>&1`);
|
||||||
|
}
|
||||||
|
|
||||||
|
local $ENV{LOCAL_INFILE} = 0;
|
||||||
|
diag(`$trunk/sandbox/start-sandbox master 2900 >/dev/null 2>&1`);
|
||||||
|
|
||||||
|
my $master3_dbh = $sb->get_dbh_for('master3');
|
||||||
|
|
||||||
|
test_disabled_load_data($master3_dbh, $sb);
|
||||||
|
|
||||||
|
diag(`$trunk/sandbox/stop-sandbox 2900 >/dev/null 2>&1`);
|
||||||
|
$master3_dbh->disconnect() if $master3_dbh;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
sub test_disabled_load_data {
|
||||||
|
my ($dbh, $sb) = @_;
|
||||||
|
$sb->load_file('master', 't/pt-archiver/samples/table5.sql');
|
||||||
|
$dbh->do('INSERT INTO `test`.`table_5_copy` SELECT * FROM `test`.`table_5`');
|
||||||
|
|
||||||
|
my ($output, undef) = full_output(
|
||||||
|
sub { pt_archiver::main(qw(--no-ascend --limit 50 --bulk-insert),
|
||||||
|
qw(--bulk-delete --where 1=1 --statistics),
|
||||||
|
'--source', "D=test,t=table_5,F=$cnf",
|
||||||
|
'--dest', "t=table_5_dest") },
|
||||||
|
);
|
||||||
|
|
||||||
|
like($output,
|
||||||
|
qr!\Q--bulk-insert cannot work as LOAD DATA LOCAL INFILE is disabled. See http://kb.percona.com/troubleshoot-load-data-infile!,
|
||||||
|
""
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
# Done.
|
# Done.
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
|
|||||||
@@ -22,6 +22,9 @@ my $dbh = $sb->get_dbh_for('master');
|
|||||||
if ( !$dbh ) {
|
if ( !$dbh ) {
|
||||||
plan skip_all => 'Cannot connect to sandbox master';
|
plan skip_all => 'Cannot connect to sandbox master';
|
||||||
}
|
}
|
||||||
|
elsif ( PerconaTest::load_data_is_disabled($dbh) ) {
|
||||||
|
plan skip_all => 'Cannot use --bulk-insert with LOAD DATA LOCAL INFILE disabled';
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
plan tests => 5;
|
plan tests => 5;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -159,7 +159,7 @@ diag('Loading sample dataset...');
|
|||||||
$sb->load_file('master', "$sample/basic_no_fks.sql");
|
$sb->load_file('master', "$sample/basic_no_fks.sql");
|
||||||
$master_dbh->do("USE pt_osc");
|
$master_dbh->do("USE pt_osc");
|
||||||
$master_dbh->do("TRUNCATE TABLE t");
|
$master_dbh->do("TRUNCATE TABLE t");
|
||||||
$master_dbh->do("LOAD DATA LOCAL INFILE '$trunk/t/pt-online-schema-change/samples/basic_no_fks.data' INTO TABLE t");
|
$master_dbh->do("LOAD DATA INFILE '$trunk/t/pt-online-schema-change/samples/basic_no_fks.data' INTO TABLE t");
|
||||||
$master_dbh->do("ANALYZE TABLE t");
|
$master_dbh->do("ANALYZE TABLE t");
|
||||||
$sb->wait_for_slaves();
|
$sb->wait_for_slaves();
|
||||||
|
|
||||||
|
|||||||
@@ -363,7 +363,7 @@ is(
|
|||||||
# Test --where.
|
# Test --where.
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
$sb->load_file('master', 't/pt-table-checksum/samples/600cities.sql');
|
$sb->load_file('master', 't/pt-table-checksum/samples/600cities.sql');
|
||||||
$master_dbh->do("LOAD DATA LOCAL INFILE '$trunk/t/pt-table-checksum/samples/600cities.data' INTO TABLE test.t");
|
$master_dbh->do("LOAD DATA INFILE '$trunk/t/pt-table-checksum/samples/600cities.data' INTO TABLE test.t");
|
||||||
|
|
||||||
$output = output(
|
$output = output(
|
||||||
sub { $exit_status = pt_table_checksum::main(@args,
|
sub { $exit_status = pt_table_checksum::main(@args,
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ unlike(
|
|||||||
# on replicas
|
# on replicas
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
$sb->load_file('master', 't/pt-table-checksum/samples/600cities.sql');
|
$sb->load_file('master', 't/pt-table-checksum/samples/600cities.sql');
|
||||||
$master_dbh->do("LOAD DATA LOCAL INFILE '$trunk/t/pt-table-checksum/samples/600cities.data' INTO TABLE test.t");
|
$master_dbh->do("LOAD DATA INFILE '$trunk/t/pt-table-checksum/samples/600cities.data' INTO TABLE test.t");
|
||||||
$master_dbh->do("SET SQL_LOG_BIN=0");
|
$master_dbh->do("SET SQL_LOG_BIN=0");
|
||||||
$master_dbh->do("DELETE FROM test.t WHERE id > 100");
|
$master_dbh->do("DELETE FROM test.t WHERE id > 100");
|
||||||
$master_dbh->do("SET SQL_LOG_BIN=1");
|
$master_dbh->do("SET SQL_LOG_BIN=1");
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ my $output;
|
|||||||
sub load_data_infile {
|
sub load_data_infile {
|
||||||
my ($file, $where) = @_;
|
my ($file, $where) = @_;
|
||||||
$master_dbh->do('truncate table percona.checksums');
|
$master_dbh->do('truncate table percona.checksums');
|
||||||
$master_dbh->do("LOAD DATA LOCAL INFILE '$trunk/t/pt-table-checksum/samples/checksum_results/$file' INTO TABLE percona.checksums");
|
$master_dbh->do("LOAD DATA INFILE '$trunk/t/pt-table-checksum/samples/checksum_results/$file' INTO TABLE percona.checksums");
|
||||||
if ( $where ) {
|
if ( $where ) {
|
||||||
PerconaTest::wait_for_table($slave1_dbh, 'percona.checksums', $where);
|
PerconaTest::wait_for_table($slave1_dbh, 'percona.checksums', $where);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user