mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-09 18:30:16 +00:00
PMM-1455 pt-osc is stuck when the table that is being altered is filtered out in the slave
This commit is contained in:
@@ -5002,7 +5002,7 @@ sub wait {
|
||||
my $lag = $get_lag->($lagged_slaves[$i]->{cxn});
|
||||
PTDEBUG && _d($lagged_slaves[$i]->{cxn}->name(),
|
||||
'slave lag:', $lag);
|
||||
if ( !defined $lag || $lag > $max_lag ) {
|
||||
if ( defined $lag && $lag > $max_lag ) {
|
||||
$lagged_slaves[$i]->{lag} = $lag;
|
||||
}
|
||||
else {
|
||||
|
@@ -165,7 +165,7 @@ else {
|
||||
}
|
||||
$master_dbh->do("USE pt_osc");
|
||||
$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");
|
||||
$sb->wait_for_slaves();
|
||||
|
||||
@@ -215,7 +215,7 @@ is(
|
||||
|
||||
$master_dbh->do("USE pt_osc");
|
||||
$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");
|
||||
$sb->wait_for_slaves();
|
||||
|
||||
|
@@ -46,6 +46,11 @@ my $exit_status;
|
||||
my $sample = "t/pt-online-schema-change/samples/";
|
||||
|
||||
$sb->load_file('master', "$sample/issue-1646713.sql");
|
||||
my $num_rows = 1000;
|
||||
my $master_port = 12345;
|
||||
|
||||
$master_dbh->do("FLUSH TABLES");
|
||||
$sb->wait_for_slaves();
|
||||
|
||||
sub start_thread {
|
||||
my ($dsn_opts, $sleep_time) = @_;
|
||||
@@ -53,14 +58,18 @@ sub start_thread {
|
||||
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
|
||||
my $dbh = $sb->get_dbh_for('master');
|
||||
diag("Thread started: Sleeping $sleep_time seconds before updating the PK field for row with id=1 in test.sbtest");
|
||||
sleep($sleep_time);
|
||||
# We need to lock the tables to prevent osc to really start before we are able to write the row to the table
|
||||
$dbh->do("LOCK TABLES `test`.`o1` WRITE");
|
||||
select(undef, undef, undef, $sleep_time);
|
||||
$dbh->do("UPDATE `test`.`o1` SET id=0 WHERE id=1");
|
||||
$dbh->do("UNLOCK TABLES");
|
||||
diag("Row updated");
|
||||
}
|
||||
my $thr = threads->create('start_thread', $dsn_opts, 1);
|
||||
my $thr = threads->create('start_thread', $dsn_opts, 0.50);
|
||||
$thr->detach();
|
||||
threads->yield();
|
||||
|
||||
|
||||
diag("Starting osc. A row will be updated in a different thread.");
|
||||
my $dir = tempdir( CLEANUP => 1 );
|
||||
$output = output(
|
||||
@@ -71,6 +80,7 @@ $output = output(
|
||||
),
|
||||
},
|
||||
);
|
||||
diag($output);
|
||||
|
||||
like(
|
||||
$output,
|
||||
|
@@ -21,7 +21,7 @@ use Sandbox;
|
||||
use SqlModes;
|
||||
use File::Temp qw/ tempdir /;
|
||||
|
||||
plan tests => 4;
|
||||
plan tests => 3;
|
||||
|
||||
require "$trunk/bin/pt-online-schema-change";
|
||||
|
||||
@@ -41,26 +41,26 @@ my @args = (qw(--set-vars innodb_lock_wait_timeout=3));
|
||||
my $output;
|
||||
my $exit_status;
|
||||
|
||||
$sb->load_file('slave1', "t/pt-online-schema-change/samples/pt-1455_slave.sql");
|
||||
diag("Setting replication filters on slave 2");
|
||||
$sb->load_file('slave2', "t/pt-online-schema-change/samples/pt-1455_slave.sql");
|
||||
$sb->load_file('master', "t/pt-online-schema-change/samples/pt-1455_master.sql");
|
||||
diag("Setting replication filters on slave 1");
|
||||
$sb->load_file('slave1', "t/pt-online-schema-change/samples/pt-1455_slave.sql");
|
||||
diag("Setting replication filters on master");
|
||||
$sb->load_file('master', "t/pt-online-schema-change/samples/pt-1455_master.sql",undef, no_wait => 1);
|
||||
diag("replication filters set");
|
||||
|
||||
my $num_rows = 1000;
|
||||
my $master_port = $Sandbox::port_for{master};
|
||||
my $master_port = 12345;
|
||||
|
||||
diag("Loading $num_rows into the table. This might take some time.");
|
||||
diag(`util/mysql_random_data_load_linux_amd64 --host=127.1 --port=$master_port --user=msandbox --password=msandbox ignored_db t1 $num_rows`);
|
||||
diag(`util/mysql_random_data_load_linux_amd64 --host=127.1 --port=$master_port --user=msandbox --password=msandbox employees t1 $num_rows`);
|
||||
diag("$num_rows rows loaded. Starting tests.");
|
||||
|
||||
$master_dbh->do("FLUSH TABLES");
|
||||
|
||||
my $new_dir='/tmp/tdir';
|
||||
diag(`rm -rf $new_dir`);
|
||||
diag(`mkdir $new_dir`);
|
||||
|
||||
($output, $exit_status) = full_output(
|
||||
sub { pt_online_schema_change::main(@args, "$master_dsn,D=ignored_db,t=t1",
|
||||
'--execute',
|
||||
sub { pt_online_schema_change::main(@args, "$master_dsn,D=employees,t=t1",
|
||||
'--execute', '--no-check-replication-filters',
|
||||
'--alter', "engine=innodb",
|
||||
),
|
||||
},
|
||||
@@ -79,19 +79,12 @@ like(
|
||||
"PT-1455 Got successfully altered message.",
|
||||
);
|
||||
|
||||
$master_dbh->do("DROP DATABASE IF EXISTS employees");
|
||||
|
||||
my $db_dir="$new_dir/test/";
|
||||
opendir(my $dh, $db_dir) || die "Can't opendir $db_dir: $!";
|
||||
my @files = grep { /^t3#P#p/ } readdir($dh);
|
||||
closedir $dh;
|
||||
|
||||
is(
|
||||
scalar @files,
|
||||
4,
|
||||
"PT-1455 Number of files is correct",
|
||||
);
|
||||
|
||||
$master_dbh->do("DROP DATABASE IF EXISTS ignored_db");
|
||||
diag("Resetting replication filters on slave 2");
|
||||
$sb->load_file('slave2', "t/pt-online-schema-change/samples/pt-1455_reset_slave.sql");
|
||||
diag("Resetting replication filters on slave 1");
|
||||
$sb->load_file('slave1', "t/pt-online-schema-change/samples/pt-1455_reset_slave.sql");
|
||||
|
||||
# #############################################################################
|
||||
# Done.
|
||||
|
@@ -2,40 +2,12 @@ DROP DATABASE IF EXISTS `test`;
|
||||
CREATE DATABASE IF NOT EXISTS `test`;
|
||||
USE test;
|
||||
|
||||
-- MySQL dump 10.13 Distrib 5.7.14-8, for debian-linux-gnu (x86_64)
|
||||
--
|
||||
-- Host: localhost Database: test
|
||||
-- ------------------------------------------------------
|
||||
-- Server version 5.7.14-8-log
|
||||
|
||||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
|
||||
/*!40101 SET NAMES utf8 */;
|
||||
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
|
||||
/*!40103 SET TIME_ZONE='+00:00' */;
|
||||
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
|
||||
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
|
||||
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
|
||||
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
|
||||
|
||||
--
|
||||
-- Table structure for table `sbtest`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `o1`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
CREATE TABLE `o1` (
|
||||
`id` int
|
||||
(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`id` int (10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1100001 DEFAULT CHARSET=latin1;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
|
||||
|
||||
--
|
||||
-- Dumping data for table `sbtest`
|
||||
--
|
||||
|
||||
LOCK TABLES `o1` WRITE;
|
||||
/*!40000 ALTER TABLE `o1` DISABLE KEYS */;
|
||||
@@ -140,16 +112,4 @@ INSERT INTO `o1` VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),
|
||||
(980),(981),(982),(983),(984),(985),(986),(987),(988),(989),
|
||||
(990),(991),(992),(993),(994),(995),(996),(997),(998),(999),
|
||||
(10000);
|
||||
/*!40000 ALTER TABLE `o1` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
|
||||
|
||||
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
|
||||
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
|
||||
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
|
||||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
||||
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
||||
|
||||
-- Dump completed on 2017-03-14 15:19:26
|
||||
|
@@ -1,6 +1,8 @@
|
||||
DROP DATABASE IF EXISTS employees;
|
||||
CREATE DATABASE employees;
|
||||
-- This table should be replicated
|
||||
CREATE TABLE employees.t1 (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
f2 INT
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
|
@@ -0,0 +1,6 @@
|
||||
STOP SLAVE;
|
||||
CHANGE REPLICATION FILTER REPLICATE_IGNORE_DB = ();
|
||||
CHANGE REPLICATION FILTER REPLICATE_IGNORE_TABLE = ();
|
||||
CHANGE REPLICATION FILTER REPLICATE_WILD_IGNORE_TABLE = ();
|
||||
RESET SLAVE;
|
||||
START SLAVE;
|
@@ -1,4 +1,6 @@
|
||||
STOP SLAVE;
|
||||
CHANGE REPLICATION FILTER REPLICATE_WILD_IGNORE_TABLE = ('employees.%');
|
||||
CHANGE REPLICATION FILTER REPLICATE_IGNORE_DB = (`ignored_db`);
|
||||
CHANGE REPLICATION FILTER REPLICATE_IGNORE_TABLE = (`idb1`.`it1`, `idb1`.`it2`);
|
||||
CHANGE REPLICATION FILTER REPLICATE_WILD_IGNORE_TABLE = ('employees.eit%');
|
||||
RESET SLAVE;
|
||||
START SLAVE;
|
||||
|
Reference in New Issue
Block a user