Fix updating master_crc and master_cnt. Implement print_checksum_results().

This commit is contained in:
Daniel Nichter
2011-09-12 11:05:28 -06:00
parent 5e7cb7597d
commit 155cd48259

View File

@@ -4972,10 +4972,12 @@ sub main {
exec_nibble => sub { exec_nibble => sub {
my (%args) = @_; my (%args) = @_;
my $tbl = $args{tbl}; my $tbl = $args{tbl};
$tbl->{checksum_results}->{n_chunks}++;
# First, check if the chunk is too large. # First, check if the chunk is too large.
if ( $o->get('chunk-size-limit') if ( $o->get('chunk-size-limit')
&& is_oversize_chunk(%args, %common_modules) ) { && is_oversize_chunk(%args, %common_modules) ) {
warn "Chunk $args{nibbleno} of table $tbl->{db}.$tbl->{tbl} is too large\n"; MKDEBUG && _d('Chunk', $args{nibbleno}, 'of table',
"$tbl->{db}.$tbl->{tbl}", 'is too large');
$tbl->{checksum_results}->{oversize_chunks}++; $tbl->{checksum_results}->{oversize_chunks}++;
$tbl->{checksum_results}->{exit_status} |= 1; $tbl->{checksum_results}->{exit_status} |= 1;
return 0; # next boundary return 0; # next boundary
@@ -4988,7 +4990,11 @@ sub main {
}, },
after_nibble => sub { after_nibble => sub {
my (%args) = @_; my (%args) = @_;
return after_nibble(%args); my $tbl = $args{tbl};
$fetch_sth->execute(@{$tbl}{qw(db tbl)}, $args{nibbleno});
my ($crc, $cnt) = $fetch_sth->fetchrow_array();
$update_sth->execute($crc, $cnt, @{$tbl}{qw(db tbl)}, $args{nibbleno});
return;
}, },
done => sub { done => sub {
my (%args) = @_; my (%args) = @_;
@@ -5032,13 +5038,7 @@ sub main {
%common_modules, %common_modules,
); );
eval { eval {
NIBBLE: 1 while $nibble_iter->next();
while ( my $checksum = $nibble_iter->next() ) {
my $chunkno = $nibble_iter->nibble_number();
$fetch_sth->execute(@{$tbl}{qw(db tbl)}, $chunkno);
my ($crc, $cnt) = $fetch_sth->fetchrow_array();
$update_sth->execute($crc, $cnt, @{$tbl}{qw(db tbl)}, $chunkno);
}
}; };
if ($EVAL_ERROR) { if ($EVAL_ERROR) {
warn "Error checksumming $tbl->{db}.$tbl->{tbl}: $EVAL_ERROR\n"; warn "Error checksumming $tbl->{db}.$tbl->{tbl}: $EVAL_ERROR\n";
@@ -5148,7 +5148,9 @@ sub exec_nibble {
sub after_nibble { sub after_nibble {
my (%args) = @_; my (%args) = @_;
my ($tbl) = @args{qw(tbl)};
MKDEBUG && _d('After nibble'); MKDEBUG && _d('After nibble');
# my $o = $args{OptionParser}; # my $o = $args{OptionParser};
# #
# if ( $throttle_method eq 'slavelag' ) { # if ( $throttle_method eq 'slavelag' ) {
@@ -5173,6 +5175,10 @@ sub after_nibble {
return; return;
}; };
{
my $print_header = 1;
my $line_fmt = "%6s %9s %6s %7s %6s %6s %-s\n";
sub print_checksum_results { sub print_checksum_results {
my (%args) = @_; my (%args) = @_;
my @required_args = qw(tbl); my @required_args = qw(tbl);
@@ -5181,10 +5187,22 @@ sub print_checksum_results {
} }
my ($tbl) = @args{@required_args}; my ($tbl) = @args{@required_args};
print "$tbl->{db}.$tbl->{tbl} $tbl->{checksum_results}->{exit_status}\n"; if ($print_header) {
printf $line_fmt, qw(STATUS ROWS CHUNKS SKIPPED ERRORS TIME TABLE);
$print_header = 0;
}
printf $line_fmt,
$tbl->{checksum_results}->{exit_status} || 0,
$tbl->{checksum_results}->{n_rows} || 0,
$tbl->{checksum_results}->{n_chunks} || 0,
$tbl->{checksum_results}->{oversize_chunks} || 0,
0,
$tbl->{checksum_results}->{total_time} || 0,
"$tbl->{db}.$tbl->{tbl}";
return; return;
} }
}
# Check for existence and privileges on the replication table before # Check for existence and privileges on the replication table before
# starting, and prepare the statements that will be used to update it. # starting, and prepare the statements that will be used to update it.