mirror of
https://github.com/percona/percona-toolkit.git
synced 2026-04-26 01:02:25 +08:00
merge upstream
This commit is contained in:
+12
-7
@@ -3778,7 +3778,7 @@ sub set_nibble_number {
|
|||||||
|
|
||||||
sub nibble_index {
|
sub nibble_index {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
return lc($self->{index});
|
return $self->{index};
|
||||||
}
|
}
|
||||||
|
|
||||||
sub statements {
|
sub statements {
|
||||||
@@ -5877,17 +5877,20 @@ sub main {
|
|||||||
# ########################################################################
|
# ########################################################################
|
||||||
# Connect to the master.
|
# Connect to the master.
|
||||||
# ########################################################################
|
# ########################################################################
|
||||||
|
my $vp = new VersionParser();
|
||||||
|
|
||||||
my $set_on_connect = sub {
|
my $set_on_connect = sub {
|
||||||
my ($dbh) = @_;
|
my ($dbh) = @_;
|
||||||
|
|
||||||
return if $o->get('explain');
|
return if $o->get('explain');
|
||||||
|
my $sql;
|
||||||
|
|
||||||
# https://bugs.launchpad.net/percona-toolkit/+bug/919352
|
# https://bugs.launchpad.net/percona-toolkit/+bug/919352
|
||||||
# The tool shouldn't blindly attempt to change binlog_format;
|
# The tool shouldn't blindly attempt to change binlog_format;
|
||||||
# instead, it should check if it's already set to STATEMENT.
|
# instead, it should check if it's already set to STATEMENT.
|
||||||
# This is becase starting with MySQL 5.1.29, changing the format
|
# This is becase starting with MySQL 5.1.29, changing the format
|
||||||
# requires a SUPER user.
|
# requires a SUPER user.
|
||||||
my $sql = 'SELECT @@binlog_format';
|
if ( $vp->version_ge($dbh, '5.1.5') ) {
|
||||||
|
$sql = 'SELECT @@binlog_format';
|
||||||
PTDEBUG && _d($dbh, $sql);
|
PTDEBUG && _d($dbh, $sql);
|
||||||
my ($original_binlog_format) = $dbh->selectrow_array($sql);
|
my ($original_binlog_format) = $dbh->selectrow_array($sql);
|
||||||
PTDEBUG && _d('Original binlog_format:', $original_binlog_format);
|
PTDEBUG && _d('Original binlog_format:', $original_binlog_format);
|
||||||
@@ -5908,6 +5911,7 @@ sub main {
|
|||||||
. "before running this tool.\n";
|
. "before running this tool.\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# Set transaction isolation level. We set binlog_format to STATEMENT,
|
# Set transaction isolation level. We set binlog_format to STATEMENT,
|
||||||
# but if the transaction isolation level is set to READ COMMITTED and the
|
# but if the transaction isolation level is set to READ COMMITTED and the
|
||||||
@@ -5995,7 +5999,6 @@ sub main {
|
|||||||
my $q = new Quoter();
|
my $q = new Quoter();
|
||||||
my $tp = new TableParser(Quoter => $q);
|
my $tp = new TableParser(Quoter => $q);
|
||||||
my $rc = new RowChecksum(Quoter=> $q, OptionParser => $o);
|
my $rc = new RowChecksum(Quoter=> $q, OptionParser => $o);
|
||||||
my $vp = new VersionParser();
|
|
||||||
my $ms = new MasterSlave(VersionParser => $vp);
|
my $ms = new MasterSlave(VersionParser => $vp);
|
||||||
|
|
||||||
my $slaves; # all slaves (that we can find)
|
my $slaves; # all slaves (that we can find)
|
||||||
@@ -6399,7 +6402,8 @@ sub main {
|
|||||||
sth => $sth->{explain_upper_boundary},
|
sth => $sth->{explain_upper_boundary},
|
||||||
vals => [ @{$boundary->{lower}}, $nibble_iter->chunk_size() ],
|
vals => [ @{$boundary->{lower}}, $nibble_iter->chunk_size() ],
|
||||||
);
|
);
|
||||||
if ( lc($expl->{key} || '') ne $nibble_iter->nibble_index() ) {
|
if ( lc($expl->{key} || '')
|
||||||
|
ne lc($nibble_iter->nibble_index() || '') ) {
|
||||||
PTDEBUG && _d('Cannot nibble next chunk, aborting table');
|
PTDEBUG && _d('Cannot nibble next chunk, aborting table');
|
||||||
if ( $o->get('quiet') < 2 ) {
|
if ( $o->get('quiet') < 2 ) {
|
||||||
my $msg
|
my $msg
|
||||||
@@ -6467,7 +6471,8 @@ sub main {
|
|||||||
: 0;
|
: 0;
|
||||||
|
|
||||||
# Ensure that MySQL is using the chunk index.
|
# Ensure that MySQL is using the chunk index.
|
||||||
if ( lc($expl->{key} || '') ne $nibble_iter->nibble_index() ) {
|
if ( lc($expl->{key} || '')
|
||||||
|
ne lc($nibble_iter->nibble_index() || '') ) {
|
||||||
PTDEBUG && _d('Chunk', $args{nibbleno}, 'of table',
|
PTDEBUG && _d('Chunk', $args{nibbleno}, 'of table',
|
||||||
"$tbl->{db}.$tbl->{tbl} not using chunk index, skipping");
|
"$tbl->{db}.$tbl->{tbl} not using chunk index, skipping");
|
||||||
return 0; # next boundary
|
return 0; # next boundary
|
||||||
@@ -7266,7 +7271,7 @@ sub have_more_chunks {
|
|||||||
|
|
||||||
# The previous chunk index must match the current chunk index,
|
# The previous chunk index must match the current chunk index,
|
||||||
# else we don't know what to do.
|
# else we don't know what to do.
|
||||||
my $chunk_index = $nibble_iter->nibble_index() || '';
|
my $chunk_index = lc($nibble_iter->nibble_index() || '');
|
||||||
if (lc($last_chunk->{chunk_index} || '') ne $chunk_index) {
|
if (lc($last_chunk->{chunk_index} || '') ne $chunk_index) {
|
||||||
warn ts("Cannot resume from table $tbl->{db}.$tbl->{tbl} chunk "
|
warn ts("Cannot resume from table $tbl->{db}.$tbl->{tbl} chunk "
|
||||||
. "$last_chunk->{chunk} because the chunk indexes are different: "
|
. "$last_chunk->{chunk} because the chunk indexes are different: "
|
||||||
|
|||||||
@@ -347,7 +347,7 @@ sub set_nibble_number {
|
|||||||
|
|
||||||
sub nibble_index {
|
sub nibble_index {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
return lc($self->{index});
|
return $self->{index};
|
||||||
}
|
}
|
||||||
|
|
||||||
sub statements {
|
sub statements {
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
Differences on h=127.0.0.1,P=12346
|
Differences on h=127.0.0.1,P=12346
|
||||||
TABLE CHUNK CNT_DIFF CRC_DIFF CHUNK_INDEX LOWER_BOUNDARY UPPER_BOUNDARY
|
TABLE CHUNK CNT_DIFF CRC_DIFF CHUNK_INDEX LOWER_BOUNDARY UPPER_BOUNDARY
|
||||||
sakila.city 1 0 1 primary 1 100
|
sakila.city 1 0 1 PRIMARY 1 100
|
||||||
sakila.city 6 0 1 primary 501 600
|
sakila.city 6 0 1 PRIMARY 501 600
|
||||||
|
|
||||||
Differences on h=127.0.0.1,P=12347
|
Differences on h=127.0.0.1,P=12347
|
||||||
TABLE CHUNK CNT_DIFF CRC_DIFF CHUNK_INDEX LOWER_BOUNDARY UPPER_BOUNDARY
|
TABLE CHUNK CNT_DIFF CRC_DIFF CHUNK_INDEX LOWER_BOUNDARY UPPER_BOUNDARY
|
||||||
sakila.city 1 0 1 primary 1 100
|
sakila.city 1 0 1 PRIMARY 1 100
|
||||||
sakila.city 6 0 1 primary 501 600
|
sakila.city 6 0 1 PRIMARY 501 600
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ elsif ( !$slave_dbh ) {
|
|||||||
plan skip_all => 'Cannot connect to sandbox slave';
|
plan skip_all => 'Cannot connect to sandbox slave';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
plan tests => 19;
|
plan tests => 21;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sb->wipe_clean($master_dbh);
|
$sb->wipe_clean($master_dbh);
|
||||||
@@ -198,6 +198,41 @@ is(
|
|||||||
"Synced diff (bug 911996)"
|
"Synced diff (bug 911996)"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
# Fix bug 927771.
|
||||||
|
$sb->load_file('master', 't/pt-table-sync/samples/bug_927771.sql');
|
||||||
|
PerconaTest::wait_for_table($slave_dbh, "test.t", "c='j'");
|
||||||
|
|
||||||
|
$slave_dbh->do("update test.t set c='z' where id>8");
|
||||||
|
|
||||||
|
`$trunk/bin/pt-table-checksum h=127.1,P=12345,u=msandbox,p=msandbox --max-load '' --lock-wait 3 --chunk-size 2 -t test.t --quiet`;
|
||||||
|
|
||||||
|
PerconaTest::wait_for_table($slave_dbh, "percona.checksums", "db='test' and tbl='t' and chunk=4");
|
||||||
|
|
||||||
|
$output = output(
|
||||||
|
sub {
|
||||||
|
pt_table_sync::main('h=127.1,P=12345,u=msandbox,p=msandbox',
|
||||||
|
qw(--print --execute --replicate percona.checksums),
|
||||||
|
qw(--no-foreign-key-checks))
|
||||||
|
},
|
||||||
|
stderr => 1,
|
||||||
|
);
|
||||||
|
|
||||||
|
like(
|
||||||
|
$output,
|
||||||
|
qr/REPLACE INTO `test`.`t`\(`id`, `c`\) VALUES \('9', 'i'\)/,
|
||||||
|
"--replicate with uc index (bug 927771)"
|
||||||
|
);
|
||||||
|
|
||||||
|
my $rows = $slave_dbh->selectall_arrayref("select id, c from test.t where id>8 order by id");
|
||||||
|
is_deeply(
|
||||||
|
$rows,
|
||||||
|
[
|
||||||
|
[9, 'i'],
|
||||||
|
[10, 'j'],
|
||||||
|
],
|
||||||
|
"Synced slaved (bug 927771)"
|
||||||
|
);
|
||||||
|
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
# Done.
|
# Done.
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
drop database if exists test;
|
||||||
|
create database test;
|
||||||
|
use test;
|
||||||
|
create table t (
|
||||||
|
id int auto_increment not null primary key,
|
||||||
|
c varchar(8) not null
|
||||||
|
) engine=innodb;
|
||||||
|
insert into test.t values
|
||||||
|
(null, 'a'),
|
||||||
|
(null, 'b'),
|
||||||
|
(null, 'c'),
|
||||||
|
(null, 'd'),
|
||||||
|
(null, 'e'),
|
||||||
|
(null, 'f'),
|
||||||
|
(null, 'g'),
|
||||||
|
(null, 'h'),
|
||||||
|
(null, 'i'),
|
||||||
|
(null, 'j');
|
||||||
Reference in New Issue
Block a user