Merge branch '3.0' into PT-1536

This commit is contained in:
Carlos Salguero
2018-05-18 14:30:03 -03:00
48 changed files with 374 additions and 157 deletions

View File

@@ -1,8 +1,10 @@
Changelog for Percona Toolkit Changelog for Percona Toolkit
v3.0.9 released 2018-04-17 v3.0.10
v3.0.9 * Improvement PT-1546 : Improved support of MySQL 8 roles
v3.0.9 released 2018-04-17
* Feature PT-1530 : Add support for encryption status to mysql-summary * Feature PT-1530 : Add support for encryption status to mysql-summary
* Fixed bug PT-1527 : pt-table-checksum ignores --nocheck-binlog-format * Fixed bug PT-1527 : pt-table-checksum ignores --nocheck-binlog-format

View File

@@ -599,9 +599,9 @@ for i in `_seq $NUM`; do
NEXTFILE=$(($i + 1)) NEXTFILE=$(($i + 1))
# Sort each file and eliminate empty lines, so 'join' doesn't complain. # Sort each file and eliminate empty lines, so 'join' doesn't complain.
sort "$FILE$i" | grep . > "$FILE$i.tmp" sort -s "$FILE$i" | grep . > "$FILE$i.tmp"
mv "$FILE$i.tmp" "$FILE$i" mv "$FILE$i.tmp" "$FILE$i"
sort "$FILE${NEXTFILE}" | grep . > "$FILE${NEXTFILE}.tmp" sort -s "$FILE${NEXTFILE}" | grep . > "$FILE${NEXTFILE}.tmp"
mv "$FILE${NEXTFILE}.tmp" "$FILE${NEXTFILE}" mv "$FILE${NEXTFILE}.tmp" "$FILE${NEXTFILE}"
# Join the files together. This gets slow O(n^2) as we add more files, but # Join the files together. This gets slow O(n^2) as we add more files, but
@@ -610,7 +610,7 @@ for i in `_seq $NUM`; do
# Find the max length of the [numeric only] values in the file so we know how # Find the max length of the [numeric only] values in the file so we know how
# wide to make the columns # wide to make the columns
MAXLEN=`awk '{print $2}' "$FILE${NEXTFILE}" | grep -v '[^0-9]' | awk '{print length($1)}' | sort -rn | head -n1` MAXLEN=`awk '{print $2}' "$FILE${NEXTFILE}" | grep -v '[^0-9]' | awk '{print length($1)}' | sort -rns | head -n1`
mv "$FILE" "$FILE${NEXTFILE}" mv "$FILE" "$FILE${NEXTFILE}"
SPEC="$SPEC %${MAXLEN}d"; SPEC="$SPEC %${MAXLEN}d";

View File

@@ -2266,24 +2266,19 @@ report_jemalloc_enabled() {
local JEMALLOC_LOCATION='' local JEMALLOC_LOCATION=''
for PID in $(pidof mysqld); do for PID in $(pidof mysqld); do
grep -qc jemalloc /proc/${PID}/environ || ldd $(which mysqld) 2>/dev/null | grep -qc jemalloc grep -qc jemalloc /proc/${pid}/environ || ldd $(which mysqld) 2>/dev/null | grep -qc jemalloc
JEMALLOC_STATUS=$? jemalloc_status=$?
if [ $JEMALLOC_STATUS = 1 ]; then if [ $jemalloc_status = 1 ]; then
echo "jemalloc is not enabled in MySQL config for process with ID ${PID}" echo "jemalloc is not enabled in mysql config for process with id ${pid}"
else else
echo "jemalloc enabled in MySQL config for process with ID ${PID}" echo "jemalloc enabled in mysql config for process with id ${pid}"
GENERAL_JEMALLOC_STATUS=1 GENERAL_JEMALLOC_STATUS=1
fi fi
done done
if [ $GENERAL_JEMALLOC_STATUS = 1 ]; then if [ $GENERAL_JEMALLOC_STATUS -eq 1 ]; then
for libjemall in "/usr/lib64" "/usr/lib/x86_64-linux-gnu" "/usr/lib"; do JEMALLOC_LOCATION=$(find /usr/lib64/ /usr/lib/x86_64-linux-gnu /usr/lib -name "libjemalloc.*" 2>/dev/null | head -n 1)
if [ -r "$libjemall/libjemalloc.so.1" ]; then if [ -z "$JEMALLOC_LOCATION" ]; then
JEMALLOC_LOCATION="$libjemall/libjemalloc.so.1"
break
fi
done
if [ -z $JEMALLOC_LOCATION ]; then
echo "Jemalloc library not found" echo "Jemalloc library not found"
else else
echo "Using jemalloc from $JEMALLOC_LOCATION" echo "Using jemalloc from $JEMALLOC_LOCATION"

View File

@@ -1909,8 +1909,14 @@ sub main {
. ($o->get('timestamp') ? ", MySQL $version at $ts" : ", MySQL $version"), . ($o->get('timestamp') ? ", MySQL $version at $ts" : ", MySQL $version"),
), "\n" if $o->get('header'); ), "\n" if $o->get('header');
# MySQL 8 roles must be excluded from the regular users list.
# Roles can be identified because the user password is expired, the authentication
# string is empty and the account is locked
my $users = $o->get('only') || $dbh->selectall_arrayref( my $users = $o->get('only') || $dbh->selectall_arrayref(
'SELECT DISTINCT User, Host FROM mysql.user ORDER BY User, Host', 'SELECT DISTINCT User, Host FROM mysql.user WHERE NOT (`account_locked`="Y"
AND `password_expired`="Y"
AND `authentication_string`=""
) ORDER BY User, Host',
{ Slice => {} }); { Slice => {} });
if ( scalar @all_hosts ) { if ( scalar @all_hosts ) {
my $where = join(' OR ', map { "User='$_'" } @all_hosts); my $where = join(' OR ', map { "User='$_'" } @all_hosts);
@@ -1922,6 +1928,24 @@ sub main {
my $ignore_users = $o->get('ignore'); my $ignore_users = $o->get('ignore');
my $exit_status = 0; my $exit_status = 0;
my $roles = get_roles($dbh, $users);
if ($roles && scalar @$roles > 0) {
print "-- Roles\n";
my $count=0;
for my $role (@$roles) {
next if (!$o->get("include-unused-roles") && $role->{active} == 0);
unshift @$users, { Host => $role->{host}, User => $role->{name}, IsRole => 1};
$count++;
printf('CREATE ROLE IF NOT EXISTS `%s`;'."\n", $role->{name});
}
if ($count == 0) {
print "No active roles found\n";
}
print "-- End of roles listing\n";
}
USER: USER:
foreach my $u ( @$users ) { foreach my $u ( @$users ) {
my $user_host = "'$u->{User}'\@'$u->{Host}'"; my $user_host = "'$u->{User}'\@'$u->{Host}'";
@@ -2040,7 +2064,7 @@ sub main {
"\n"; "\n";
} }
if ( $o->get('drop') ) { if ( $o->get('drop') && !defined($u->{IsRole}) ) {
print join("\n", print join("\n",
"DROP USER $user_host;", "DROP USER $user_host;",
"DELETE FROM `mysql`.`user` WHERE `User`='$u->{User}' AND `Host`='$u->{Host}';", "DELETE FROM `mysql`.`user` WHERE `User`='$u->{User}' AND `Host`='$u->{Host}';",
@@ -2084,6 +2108,42 @@ sub parse_user {
return ( $user, $host ); return ( $user, $host );
} }
sub get_roles {
my ($dbh, $users) = @_;
my $query = <<__EOQ;
SELECT DISTINCT user.user AS name, user.host, IF(from_user IS NULL,0, 1) AS active
FROM mysql.user
LEFT JOIN mysql.role_edges ON role_edges.from_user=user.user
WHERE `account_locked`='Y'
AND `password_expired`='Y'
AND `authentication_string`=''
__EOQ
if (scalar $users > 0) {
my $user_names = join (", ", map { "'$_->{User}'" } @$users);
$query .= " AND to_user IN ($user_names)";
}
PTDEBUG && _d("Getting roles");
PTDEBUG && _d($query);
my $roles;
eval { $roles = $dbh->selectall_arrayref($query, { Slice => {} }) };
if ($EVAL_ERROR) {
PTDEBUG && _d("Cannot list roles: $EVAL_ERROR");
}
return $roles;
}
sub is_role {
my ($users, $grant) = @_;
foreach my $u ( @$users ) {
my $user_host = "`$u->{User}`\@`$u->{Host}`";
warn "> user_host: $user_host";
if ($grant eq $user_host) {
return 1;
}
}
return 0;
}
sub split_grants { sub split_grants {
my ($grants) = @_; my ($grants) = @_;
return unless $grants; return unless $grants;
@@ -2346,6 +2406,10 @@ example, specifying C<--set-vars wait_timeout=500> overrides the defaultvalue of
The tool prints a warning and continues if a variable cannot be set. The tool prints a warning and continues if a variable cannot be set.
=item --[no]include-unused-roles
When dumping MySQL 8+ roles, include unused roles.
=item --socket =item --socket
short form: -S; type: string short form: -S; type: string

View File

@@ -9847,6 +9847,7 @@ use sigtrap 'handler', \&sig_int, 'normal-signals';
my $oktorun = 1; my $oktorun = 1;
my $print_header = 1; my $print_header = 1;
my $exit_status = 0; my $exit_status = 0;
my $original_qrt_plugin_master_status = undef;
# "exit codes 1 - 2, 126 - 165, and 255 [1] have special meanings, # "exit codes 1 - 2, 126 - 165, and 255 [1] have special meanings,
# and should therefore be avoided for user-specified exit parameters" # and should therefore be avoided for user-specified exit parameters"
@@ -10052,30 +10053,28 @@ sub main {
# 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.
if ( $o->get('check-binlog-format') ) { if ( VersionParser->new($dbh) >= '5.1.5' ) {
if ( VersionParser->new($dbh) >= '5.1.5' ) { $sql = 'SELECT @@binlog_format';
$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); if ( $original_binlog_format !~ /STATEMENT/i ) {
if ( $original_binlog_format !~ /STATEMENT/i ) { $sql = q{/*!50108 SET @@binlog_format := 'STATEMENT'*/};
$sql = q{/*!50108 SET @@binlog_format := 'STATEMENT'*/}; eval {
eval { PTDEBUG && _d($dbh, $sql);
PTDEBUG && _d($dbh, $sql); $dbh->do($sql);
$dbh->do($sql); };
}; if ( $EVAL_ERROR ) {
if ( $EVAL_ERROR ) { die "Failed to $sql: $EVAL_ERROR\n"
die "Failed to $sql: $EVAL_ERROR\n" . "This tool requires binlog_format=STATEMENT, "
. "This tool requires binlog_format=STATEMENT, " . "but the current binlog_format is set to "
. "but the current binlog_format is set to " ."$original_binlog_format and an error occurred while "
."$original_binlog_format and an error occurred while " . "attempting to change it. If running MySQL 5.1.29 or newer, "
. "attempting to change it. If running MySQL 5.1.29 or newer, " . "setting binlog_format requires the SUPER privilege. "
. "setting binlog_format requires the SUPER privilege. " . "You will need to manually set binlog_format to 'STATEMENT' "
. "You will need to manually set binlog_format to 'STATEMENT' " . "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,
@@ -10103,6 +10102,7 @@ sub main {
. "level to REPEATABLE-READ.\n"; . "level to REPEATABLE-READ.\n";
} }
return; return;
}; };
@@ -10131,6 +10131,20 @@ sub main {
my $master_dbh = $master_cxn->dbh(); # just for brevity my $master_dbh = $master_cxn->dbh(); # just for brevity
my $master_dsn = $master_cxn->dsn(); # just for brevity my $master_dsn = $master_cxn->dsn(); # just for brevity
if ($o->get('disable-qrt-plugin')) {
eval {
$master_dbh->selectrow_arrayref('SELECT @@query_response_time_session_stats' );
};
if ($EVAL_ERROR) {
$original_qrt_plugin_master_status = undef;
PTDEBUG && _d('QRT plugin is not installed: '.$EVAL_ERROR);
} else {
($original_qrt_plugin_master_status) = $master_dbh->selectrow_arrayref('SELECT @@query_response_time_stats' );
PTDEBUG && _d("Disabling qrt plugin on master server");
$master_dbh->do('SET GLOBAL query_response_time_stats = off');
}
}
my @ignored_engines = keys %{$o->get('ignore-engines')}; my @ignored_engines = keys %{$o->get('ignore-engines')};
my @rocksdb_ignored = grep(/^ROCKSDB$/i, @ignored_engines); my @rocksdb_ignored = grep(/^ROCKSDB$/i, @ignored_engines);
if (!@rocksdb_ignored) { if (!@rocksdb_ignored) {
@@ -10451,6 +10465,23 @@ sub main {
} }
} }
for my $slave (@$slaves) {
my $qrt_plugin_status;
eval {
($qrt_plugin_status) = $slave->{dbh}->selectrow_arrayref('SELECT @@QUERY_RESPONSE_TIME_SESSION_STATS' );
};
if ($EVAL_ERROR) {
PTDEBUG && _d('QRT plugin is not installed on slave '.$slave->{dsn_name});
$slave->{qrt_plugin_status} = undef;
next;
}
$slave->{qrt_plugin_status} = $qrt_plugin_status->[0];
if ($slave->{qrt_plugin_status}) {
PTDEBUG && _d("Disabling qrt plugin state on slave ".$slave->{dsn_name});
$slave->{dbh}->do('SET GLOBAL query_response_time_stats = off');
}
}
if ( $o->get('check-slave-lag') ) { if ( $o->get('check-slave-lag') ) {
PTDEBUG && _d('Will use --check-slave-lag to check for slave lag'); PTDEBUG && _d('Will use --check-slave-lag to check for slave lag');
my $cxn = $make_cxn->( my $cxn = $make_cxn->(
@@ -11196,6 +11227,7 @@ sub main {
# Update chunk-size based on rows/s checksum rate. # Update chunk-size based on rows/s checksum rate.
$nibble_iter->set_chunk_size($tbl->{chunk_size}); $nibble_iter->set_chunk_size($tbl->{chunk_size});
PTDEBUG && _d('Updated chunk size: '.$tbl->{chunk_size});
} }
# Every table should have a Progress obj; update it. # Every table should have a Progress obj; update it.
@@ -11269,6 +11301,12 @@ sub main {
map { $diff_chunks{ $_->{chunk} }++ } @$diffs; map { $diff_chunks{ $_->{chunk} }++ } @$diffs;
$exit_status |= $PTC_EXIT_STATUS{TABLE_DIFF}; $exit_status |= $PTC_EXIT_STATUS{TABLE_DIFF};
} }
my $max_cnt_diff=0;
for my $diff (@$diffs) {
if ( $diff->{cnt_diff} > $max_cnt_diff ) {
$tbl->{checksum_results}->{max_rows_cnt_diff} = $diff->{cnt_diff};
}
}
}; };
if ($EVAL_ERROR) { if ($EVAL_ERROR) {
if ( $o->get('quiet') < 2 ) { if ( $o->get('quiet') < 2 ) {
@@ -11453,6 +11491,25 @@ sub main {
} }
} }
# Restore origin QRT pligin state
if ($o->get('disable-qrt-plugin')) {
eval {
if ($original_qrt_plugin_master_status) {
PTDEBUG && _d("Restoring qrt plugin state on master server");
$master_dbh->do("SET GLOBAL query_response_time_stats = $original_qrt_plugin_master_status->[0]");
}
for my $slave (@$slaves) {
if ($slave->{qrt_plugin_status}) {
PTDEBUG && _d("Restoring qrt plugin state on slave ".$slave->{dsn_name});
$slave->{dbh}->do("SET GLOBAL query_response_time_stats = $slave->{qrt_plugin_status}");
}
}
};
if ($EVAL_ERROR) {
warn "Cannot restore qrt_plugin status: $EVAL_ERROR";
}
}
PTDEBUG && _d('Exit status', $exit_status, PTDEBUG && _d('Exit status', $exit_status,
'oktorun', $oktorun, 'oktorun', $oktorun,
'have time', $have_time->()); 'have time', $have_time->());
@@ -11703,8 +11760,8 @@ sub exec_nibble {
} }
{ {
my $line_fmt = "%14s %6s %6s %8s %7s %7s %7s %-s\n"; my $line_fmt = "%14s %6s %6s %8s % 10s %7s %7s %7s %-s\n";
my @headers = qw(TS ERRORS DIFFS ROWS CHUNKS SKIPPED TIME TABLE); my @headers = qw(TS ERRORS DIFFS ROWS DIFF_ROWS CHUNKS SKIPPED TIME TABLE);
sub print_checksum_results { sub print_checksum_results {
my (%args) = @_; my (%args) = @_;
@@ -11724,7 +11781,8 @@ sub print_checksum_results {
ts(), ts(),
$res->{errors} || 0, $res->{errors} || 0,
$res->{diffs} || 0, $res->{diffs} || 0,
$res->{n_rows} || 0, $res->{n_rows} || 0,
$tbl->{checksum_results}->{max_rows_cnt_diff} || 0,
$res->{n_chunks} || 0, $res->{n_chunks} || 0,
$res->{skipped} || 0, $res->{skipped} || 0,
sprintf('%.3f', $res->{start_time} ? time - $res->{start_time} : 0), sprintf('%.3f', $res->{start_time} ? time - $res->{start_time} : 0),
@@ -13138,6 +13196,10 @@ short form: -F; type: string; group: Connection
Only read mysql options from the given file. You must give an absolute Only read mysql options from the given file. You must give an absolute
pathname. pathname.
=item --disable-qrt-plugin
Disable the QRT (Query Response Time) plugin if it is enabled.
=item --[no]empty-replicate-table =item --[no]empty-replicate-table
default: yes default: yes
@@ -13950,6 +14012,6 @@ Place, Suite 330, Boston, MA 02111-1307 USA.
=head1 VERSION =head1 VERSION
pt-table-checksum 3.0.9 pt-table-checksum 3.0.10-dev
=cut =cut

View File

@@ -656,14 +656,15 @@ sub test_bash_tool {
} }
my %checksum_result_col = ( my %checksum_result_col = (
ts => 0, ts => 0,
errors => 1, errors => 1,
diffs => 2, diffs => 2,
rows => 3, rows => 3,
chunks => 4, diff_rows => 4,
skipped => 5, chunks => 5,
time => 6, skipped => 5,
table => 7, time => 6,
table => 7,
); );
sub count_checksum_results { sub count_checksum_results {
my ($output, $column, $table) = @_; my ($output, $column, $table) = @_;
@@ -696,7 +697,7 @@ sub normalize_checksum_results {
open my $fh, ">", $tmp_file or die "Cannot open $tmp_file: $OS_ERROR"; open my $fh, ">", $tmp_file or die "Cannot open $tmp_file: $OS_ERROR";
printf $fh $output; printf $fh $output;
close $fh; close $fh;
my $normal_output = `cat $tmp_file | awk '/^[0-9 ]/ {print \$2 " " \$3 " " \$4 " " \$5 " " \$6 " " \$8} /^[A-Z]/ {print \$0}'`; my $normal_output = `cat $tmp_file | awk '/^[0-9 ]/ {print \$2 " " \$3 " " \$4 " " \$5 " " \$6 " " \$7 " " \$9} /^[A-Z]/ {print \$0}'`;
`rm $tmp_file >/dev/null`; `rm $tmp_file >/dev/null`;
return $normal_output; return $normal_output;
} }

View File

@@ -692,14 +692,15 @@ sub test_bash_tool {
} }
my %checksum_result_col = ( my %checksum_result_col = (
ts => 0, ts => 0,
errors => 1, errors => 1,
diffs => 2, diffs => 2,
rows => 3, rows => 3,
chunks => 4, diff_rows => 4,
skipped => 5, chunks => 5,
time => 6, skipped => 6,
table => 7, time => 7,
table => 7,
); );
sub count_checksum_results { sub count_checksum_results {
my ($output, $column, $table) = @_; my ($output, $column, $table) = @_;
@@ -732,7 +733,7 @@ sub normalize_checksum_results {
open my $fh, ">", $tmp_file or die "Cannot open $tmp_file: $OS_ERROR"; open my $fh, ">", $tmp_file or die "Cannot open $tmp_file: $OS_ERROR";
printf $fh $output; printf $fh $output;
close $fh; close $fh;
my $normal_output = `cat $tmp_file | awk '/^[0-9 ]/ {print \$2 " " \$3 " " \$4 " " \$5 " " \$6 " " \$8} /^[A-Z]/ {print \$0}'`; my $normal_output = `cat $tmp_file | awk '/^[0-9 ]/ {print \$2 " " \$3 " " \$4 " " \$5 " " \$6 " " \$7 " " \$9} /^[A-Z]/ {print \$0}'`;
if ( wantarray ) { if ( wantarray ) {
my $original_output = `cat $tmp_file`; my $original_output = `cat $tmp_file`;
return $normal_output, $original_output; return $normal_output, $original_output;

View File

@@ -211,6 +211,7 @@ sub wipe_clean {
$self->wait_for_slaves(); $self->wait_for_slaves();
$self->clear_genlogs();
return; return;
} }
@@ -391,7 +392,7 @@ sub verify_test_data {
my @diffs; my @diffs;
foreach my $c ( @checksums ) { foreach my $c ( @checksums ) {
next unless $c->{checksum}; next unless $c->{checksum};
if ( $c->{checksum} ne $ref->{$c->{table}}->{checksum} ) { if ( $ref->{$c->{table}} && $c->{checksum} ne $ref->{$c->{table}}->{checksum} ) {
push @diffs, $c->{table}; push @diffs, $c->{table};
} }
} }

View File

@@ -1270,26 +1270,19 @@ report_jemalloc_enabled() {
local JEMALLOC_LOCATION='' local JEMALLOC_LOCATION=''
for PID in $(pidof mysqld); do for PID in $(pidof mysqld); do
grep -qc jemalloc /proc/${PID}/environ || ldd $(which mysqld) 2>/dev/null | grep -qc jemalloc grep -qc jemalloc /proc/${pid}/environ || ldd $(which mysqld) 2>/dev/null | grep -qc jemalloc
JEMALLOC_STATUS=$? jemalloc_status=$?
if [ $JEMALLOC_STATUS = 1 ]; then if [ $jemalloc_status = 1 ]; then
echo "jemalloc is not enabled in MySQL config for process with ID ${PID}" echo "jemalloc is not enabled in mysql config for process with id ${pid}"
else else
echo "jemalloc enabled in MySQL config for process with ID ${PID}" echo "jemalloc enabled in mysql config for process with id ${pid}"
GENERAL_JEMALLOC_STATUS=1 GENERAL_JEMALLOC_STATUS=1
fi fi
done done
if [ $GENERAL_JEMALLOC_STATUS = 1 ]; then if [ $GENERAL_JEMALLOC_STATUS -eq 1 ]; then
# Check location for libjemalloc.so.1 JEMALLOC_LOCATION=$(find /usr/lib64/ /usr/lib/x86_64-linux-gnu /usr/lib -name "libjemalloc.*" 2>/dev/null | head -n 1)
#for libjemall in "${SCRIPT_PWD}/lib/mysql" "/usr/lib64" "/usr/lib/x86_64-linux-gnu" "/usr/lib"; do if [ -z "$JEMALLOC_LOCATION" ]; then
for libjemall in "/usr/lib64" "/usr/lib/x86_64-linux-gnu" "/usr/lib"; do
if [ -r "$libjemall/libjemalloc.so.1" ]; then
JEMALLOC_LOCATION="$libjemall/libjemalloc.so.1"
break
fi
done
if [ -z $JEMALLOC_LOCATION ]; then
echo "Jemalloc library not found" echo "Jemalloc library not found"
else else
echo "Using jemalloc from $JEMALLOC_LOCATION" echo "Using jemalloc from $JEMALLOC_LOCATION"

Binary file not shown.

View File

@@ -24,5 +24,4 @@ report-host = 127.0.0.1
report-port = PORT report-port = PORT
log-error = /tmp/PORT/data/mysqld.log log-error = /tmp/PORT/data/mysqld.log
innodb_lock_wait_timeout = 3 innodb_lock_wait_timeout = 3
general_log secure-file-priv =
general_log_file = genlog

View File

@@ -26,16 +26,16 @@ log-error = /tmp/PORT/data/mysqld.log
innodb_lock_wait_timeout = 3 innodb_lock_wait_timeout = 3
general_log general_log
general_log_file = genlog general_log_file = genlog
lower_case_table_names = 0 #lower_case_table_names = 0
slow-query-log = 0 #slow-query-log = 0
slow-query-log-file = /tmp/PORT/data/slow.log #slow-query-log-file = /tmp/PORT/data/slow.log
log_slow_admin_statements = 1 #log_slow_admin_statements = 1
long_query_time = 0 #long_query_time = 0
#character-set-server = utf8 #character-set-server = utf8
# fkc test # fkc test
binlog_format = STATEMENT binlog_format = STATEMENT
performance_schema = ON #performance_schema = ON
#performance-schema-instrument='wait/lock/metadata/sql/mdl=ON' #performance-schema-instrument='wait/lock/metadata/sql/mdl=ON'
#performance-schema-instrument='transaction=ON' #performance-schema-instrument='transaction=ON'
secure-file-priv = secure-file-priv =

View File

@@ -173,9 +173,9 @@ SKIP: {
d => $DBD::mysql::VERSION ge '4.001' ? undef : '(7)', d => $DBD::mysql::VERSION ge '4.001' ? undef : '(7)',
dt => undef, dt => undef,
ts => undef, ts => undef,
c => '(1)', c => '(3)',
c2 => '(15)', c2 => '(45)',
v => '(32)', v => '(96)',
t => undef, t => undef,
}, },
}, },

View File

@@ -16,6 +16,7 @@ use Quoter;
use PerconaTest; use PerconaTest;
use DSNParser; use DSNParser;
use Sandbox; use Sandbox;
my $dp = new DSNParser(opts=>$dsn_opts); my $dp = new DSNParser(opts=>$dsn_opts);
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp); my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
my $dbh = $sb->get_dbh_for('master'); my $dbh = $sb->get_dbh_for('master');
@@ -173,6 +174,12 @@ SKIP: {
$dbh->do('CREATE DATABASE IF NOT EXISTS serialize_test'); $dbh->do('CREATE DATABASE IF NOT EXISTS serialize_test');
$dbh->do('DROP TABLE IF EXISTS serialize_test.serialize'); $dbh->do('DROP TABLE IF EXISTS serialize_test.serialize');
$dbh->do('CREATE TABLE serialize_test.serialize (id INT, textval TEXT, blobval BLOB)'); $dbh->do('CREATE TABLE serialize_test.serialize (id INT, textval TEXT, blobval BLOB)');
# Ensure we are using lantin1 as the default for the connection
# From the documentation:
# This statement sets the three session system variables character_set_client,
# character_set_connection, and character_set_results to the given character set.
$dbh->do("SET NAMES 'latin1'");
warn Data::Dumper::Dumper($dbh);
my $sth = $dbh->prepare( my $sth = $dbh->prepare(
"INSERT INTO serialize_test.serialize VALUES (?, ?, ?)" "INSERT INTO serialize_test.serialize VALUES (?, ?, ?)"

View File

@@ -626,7 +626,7 @@ is_deeply(
is_deeply( is_deeply(
[$c->get_crc_type($dbh, 'MD5')], [$c->get_crc_type($dbh, 'MD5')],
[qw(varchar 32)], [qw(varchar 96)],
'Type and length of MD5' 'Type and length of MD5'
); );

View File

@@ -10,6 +10,7 @@ use strict;
use warnings FATAL => 'all'; use warnings FATAL => 'all';
use English qw(-no_match_vars); use English qw(-no_match_vars);
use Test::More; use Test::More;
use utf8;
use PerconaTest; use PerconaTest;
use Sandbox; use Sandbox;

View File

@@ -14,6 +14,8 @@ use Data::Dumper;
use PerconaTest; use PerconaTest;
use Sandbox; use Sandbox;
use utf8;
require "$trunk/bin/pt-archiver"; require "$trunk/bin/pt-archiver";
my $dp = new DSNParser(opts=>$dsn_opts); my $dp = new DSNParser(opts=>$dsn_opts);

View File

@@ -191,13 +191,13 @@ SKIP: {
is( is(
$output, $output,
"`sakila`.`actor_info` "`sakila`.`actor_info`
`sakila`.`customer_list` `sakila`.`customer_list`
`sakila`.`film_list` `sakila`.`film_list`
`sakila`.`nicer_but_slower_film_list` `sakila`.`nicer_but_slower_film_list`
`sakila`.`sales_by_film_category` `sakila`.`sales_by_film_category`
`sakila`.`sales_by_store` `sakila`.`sales_by_store`
`sakila`.`staff_list` `sakila`.`staff_list`
", ",
'--datasize NULL', '--datasize NULL',
); );
}; };

View File

@@ -47,6 +47,7 @@ Com_lock_tables 37 0 0 0
Com_optimize 1 0 0 0 Com_optimize 1 0 0 0
Com_preload_keys 0 0 0 0 Com_preload_keys 0 0 0 0
Com_prepare_sql 0 0 0 0 Com_prepare_sql 0 0 0 0
Compression 0 0 0 0
Com_purge 0 0 0 0 Com_purge 0 0 0 0
Com_purge_before_date 0 0 0 0 Com_purge_before_date 0 0 0 0
Com_rename_table 0 0 0 0 Com_rename_table 0 0 0 0
@@ -107,7 +108,6 @@ Com_xa_prepare 0 0 0 0
Com_xa_recover 0 0 0 0 Com_xa_recover 0 0 0 0
Com_xa_rollback 0 0 0 0 Com_xa_rollback 0 0 0 0
Com_xa_start 0 0 0 0 Com_xa_start 0 0 0 0
Compression 0 0 0 0
Connections 1008 0 0 0 Connections 1008 0 0 0
Created_tmp_disk_tables 350 0 0 0 Created_tmp_disk_tables 350 0 0 0
Created_tmp_files 6 0 0 0 Created_tmp_files 6 0 0 0
@@ -160,8 +160,8 @@ Innodb_os_log_fsyncs 2505 0 0 0
Innodb_os_log_pending_fsyncs 0 0 0 0 Innodb_os_log_pending_fsyncs 0 0 0 0
Innodb_os_log_pending_writes 0 0 0 0 Innodb_os_log_pending_writes 0 0 0 0
Innodb_os_log_written 11063296 0 0 0 Innodb_os_log_written 11063296 0 0 0
Innodb_page_size 16384 0 0 0
Innodb_pages_created 542 0 0 0 Innodb_pages_created 542 0 0 0
Innodb_page_size 16384 0 0 0
Innodb_pages_read 0 0 0 0 Innodb_pages_read 0 0 0 0
Innodb_pages_written 1071 0 0 0 Innodb_pages_written 1071 0 0 0
Innodb_row_lock_current_waits 0 0 0 0 Innodb_row_lock_current_waits 0 0 0 0
@@ -187,10 +187,10 @@ Ndb_config_from_host 0 0 0 0
Ndb_config_from_port 0 0 0 0 Ndb_config_from_port 0 0 0 0
Ndb_number_of_data_nodes 0 0 0 0 Ndb_number_of_data_nodes 0 0 0 0
Not_flushed_delayed_rows 0 0 0 0 Not_flushed_delayed_rows 0 0 0 0
Opened_tables 1698 0 0 0
Open_files 5 0 0 0 Open_files 5 0 0 0
Open_streams 0 0 0 0 Open_streams 0 0 0 0
Open_tables 1 0 0 0 Open_tables 1 0 0 0
Opened_tables 1698 0 0 0
Prepared_stmt_count 0 0 0 0 Prepared_stmt_count 0 0 0 0
Qcache_free_blocks 0 0 0 0 Qcache_free_blocks 0 0 0 0
Qcache_free_memory 0 0 0 0 Qcache_free_memory 0 0 0 0

View File

@@ -47,6 +47,7 @@ Com_lock_tables 37 0 0 0
Com_optimize 1 0 0 0 Com_optimize 1 0 0 0
Com_preload_keys 0 0 0 0 Com_preload_keys 0 0 0 0
Com_prepare_sql 0 0 0 0 Com_prepare_sql 0 0 0 0
Compression 0 0 0 0
Com_purge 0 0 0 0 Com_purge 0 0 0 0
Com_purge_before_date 0 0 0 0 Com_purge_before_date 0 0 0 0
Com_rename_table 0 0 0 0 Com_rename_table 0 0 0 0
@@ -107,7 +108,6 @@ Com_xa_prepare 0 0 0 0
Com_xa_recover 0 0 0 0 Com_xa_recover 0 0 0 0
Com_xa_rollback 0 0 0 0 Com_xa_rollback 0 0 0 0
Com_xa_start 0 0 0 0 Com_xa_start 0 0 0 0
Compression 0 0 0 0
Connections 1009 0 0 0 Connections 1009 0 0 0
Created_tmp_disk_tables 350 0 0 0 Created_tmp_disk_tables 350 0 0 0
Created_tmp_files 6 0 0 0 Created_tmp_files 6 0 0 0
@@ -160,8 +160,8 @@ Innodb_os_log_fsyncs 2505 0 0 0
Innodb_os_log_pending_fsyncs 0 0 0 0 Innodb_os_log_pending_fsyncs 0 0 0 0
Innodb_os_log_pending_writes 0 0 0 0 Innodb_os_log_pending_writes 0 0 0 0
Innodb_os_log_written 11063296 0 0 0 Innodb_os_log_written 11063296 0 0 0
Innodb_page_size 16384 0 0 0
Innodb_pages_created 542 0 0 0 Innodb_pages_created 542 0 0 0
Innodb_page_size 16384 0 0 0
Innodb_pages_read 0 0 0 0 Innodb_pages_read 0 0 0 0
Innodb_pages_written 1071 0 0 0 Innodb_pages_written 1071 0 0 0
Innodb_row_lock_current_waits 0 0 0 0 Innodb_row_lock_current_waits 0 0 0 0
@@ -187,10 +187,10 @@ Ndb_config_from_host 0 0 0 0
Ndb_config_from_port 0 0 0 0 Ndb_config_from_port 0 0 0 0
Ndb_number_of_data_nodes 0 0 0 0 Ndb_number_of_data_nodes 0 0 0 0
Not_flushed_delayed_rows 0 0 0 0 Not_flushed_delayed_rows 0 0 0 0
Opened_tables 1698 0 0 0
Open_files 5 0 0 0 Open_files 5 0 0 0
Open_streams 0 0 0 0 Open_streams 0 0 0 0
Open_tables 1 0 0 0 Open_tables 1 0 0 0
Opened_tables 1698 0 0 0
Prepared_stmt_count 0 0 0 0 Prepared_stmt_count 0 0 0 0
Qcache_free_blocks 0 0 0 0 Qcache_free_blocks 0 0 0 0
Qcache_free_memory 0 0 0 0 Qcache_free_memory 0 0 0 0

View File

@@ -277,5 +277,3 @@ report-port = 12345
log-error = mysqld.log log-error = mysqld.log
innodb_lock_wait_timeout = 3 innodb_lock_wait_timeout = 3
# Memory management library ################################## # Memory management library ##################################
Jemalloc library not found
# The End ####################################################

View File

@@ -220,5 +220,3 @@ report-port = 12345
log-error = mysqld.log log-error = mysqld.log
innodb_lock_wait_timeout = 3 innodb_lock_wait_timeout = 3
# Memory management library ################################## # Memory management library ##################################
Jemalloc library not found
# The End ####################################################

View File

@@ -219,5 +219,3 @@ report-port = 12345
log-error = mysqld.log log-error = mysqld.log
innodb_lock_wait_timeout = 3 innodb_lock_wait_timeout = 3
# Memory management library ################################## # Memory management library ##################################
Jemalloc library not found
# The End ####################################################

View File

@@ -292,5 +292,3 @@ report-port = 12345
log-error = mysqld.log log-error = mysqld.log
innodb_lock_wait_timeout = 3 innodb_lock_wait_timeout = 3
# Memory management library ################################## # Memory management library ##################################
Jemalloc library not found
# The End ####################################################

View File

@@ -341,5 +341,3 @@ log_queries_not_using_indexes | OFF
# Configuration File ######################################### # Configuration File #########################################
Config File | Cannot autodetect or find, giving up Config File | Cannot autodetect or find, giving up
# Memory management library ################################## # Memory management library ##################################
Jemalloc library not found
# The End ####################################################

View File

@@ -295,5 +295,3 @@ log_queries_not_using_indexes | OFF
# Configuration File ######################################### # Configuration File #########################################
Config File | Cannot autodetect or find, giving up Config File | Cannot autodetect or find, giving up
# Memory management library ################################## # Memory management library ##################################
Jemalloc library not found
# The End ####################################################

View File

@@ -843,10 +843,8 @@ diag("Reloading sakila");
my $master_port = $sb->port_for('master'); my $master_port = $sb->port_for('master');
system "$trunk/sandbox/load-sakila-db $master_port &"; system "$trunk/sandbox/load-sakila-db $master_port &";
$sb->do_as_root("master", q/GRANT REPLICATION SLAVE ON *.* TO 'slave_user'@'%' IDENTIFIED BY 'slave_password'/); $sb->do_as_root("slave1", q/CREATE USER 'slave_user'@'%' IDENTIFIED BY 'slave_password'/);
$sb->do_as_root("master", q/set sql_log_bin=0/); $sb->do_as_root("slave1", q/GRANT REPLICATION SLAVE ON *.* TO 'slave_user'@'%'/);
$sb->do_as_root("master", q/DROP USER 'slave_user'/);
$sb->do_as_root("master", q/set sql_log_bin=1/);
test_alter_table( test_alter_table(
name => "--slave-user --slave-password", name => "--slave-user --slave-password",
@@ -861,6 +859,8 @@ test_alter_table(
# ############################################################################# # #############################################################################
# Done. # Done.
# ############################################################################# # #############################################################################
$sb->do_as_root("slave1", q/DROP USER 'slave_user'@'%'/);
$sb->wipe_clean($master_dbh); $sb->wipe_clean($master_dbh);
ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox"); ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
# #

View File

@@ -468,6 +468,7 @@ test_alter_table(
# Done. # Done.
# ############################################################################# # #############################################################################
$sb->wipe_clean($master_dbh); $sb->wipe_clean($master_dbh);
$sb->wait_for_slaves();
ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox"); ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
# #
done_testing; done_testing;

View File

@@ -21,7 +21,11 @@ use Sandbox;
use SqlModes; use SqlModes;
use File::Temp qw/ tempdir /; use File::Temp qw/ tempdir /;
plan tests => 3; if (!$ENV{PERCONA_SLOW_BOX}) {
plan skip_all => 'This test needs a fast machine';
} else {
plan tests => 3;
}
require "$trunk/bin/pt-online-schema-change"; require "$trunk/bin/pt-online-schema-change";
@@ -53,7 +57,7 @@ my $num_rows = 1000;
my $master_port = 12345; my $master_port = 12345;
diag("Loading $num_rows into the table. This might take some time."); 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 employees t1 $num_rows`); diag(`util/mysql_random_data_load --host=127.0.0.1 --port=$master_port --user=msandbox --password=msandbox employees t1 $num_rows`);
diag("$num_rows rows loaded. Starting tests."); diag("$num_rows rows loaded. Starting tests.");
$master_dbh->do("FLUSH TABLES"); $master_dbh->do("FLUSH TABLES");

View File

@@ -46,7 +46,7 @@ $sb->load_file('master', "t/pt-online-schema-change/samples/pt-229.sql");
my $num_rows = 40000; my $num_rows = 40000;
diag("Loading $num_rows into the table. This might take some time."); diag("Loading $num_rows into the table. This might take some time.");
diag(`util/mysql_random_data_load --host=127.1 --port=12345 --user=msandbox --password=msandbox test test_a $num_rows`); diag(`util/mysql_random_data_load --host=127.0.0.1 --port=12345 --user=msandbox --password=msandbox test test_a $num_rows`);
diag("$num_rows rows loaded. Starting tests."); diag("$num_rows rows loaded. Starting tests.");
$master_dbh->do("FLUSH TABLES"); $master_dbh->do("FLUSH TABLES");

View File

@@ -53,7 +53,7 @@ $sb->load_file('master3', "t/pt-online-schema-change/samples/pt-244.sql");
my $num_rows = 1000; my $num_rows = 1000;
diag("Loading $num_rows into the table. This might take some time."); diag("Loading $num_rows into the table. This might take some time.");
diag(`util/mysql_random_data_load_linux_amd64 --host=127.1 --port=$master3_port --user=msandbox --password=msandbox test t3 $num_rows`); diag(`util/mysql_random_data_load --host=127.0.0.1 --port=$master3_port --user=msandbox --password=msandbox test t3 $num_rows`);
diag("$num_rows rows loaded. Starting tests."); diag("$num_rows rows loaded. Starting tests.");
$dbh3->do("FLUSH TABLES"); $dbh3->do("FLUSH TABLES");

View File

@@ -19,7 +19,11 @@ use Sandbox;
use SqlModes; use SqlModes;
use File::Temp qw/ tempdir /; use File::Temp qw/ tempdir /;
plan tests => 4; if ($ENV{PERCONA_SLOW_BOX}) {
plan skip_all => 'This test needs a fast machine';
} else {
plan tests => 4;
}
our $delay = 30; our $delay = 30;
my $tmp_file = File::Temp->new(); my $tmp_file = File::Temp->new();
@@ -32,7 +36,7 @@ my $dp = new DSNParser(opts=>$dsn_opts);
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp); my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
my $master_dbh = $sb->get_dbh_for('master'); my $master_dbh = $sb->get_dbh_for('master');
my $slave_dbh = $sb->get_dbh_for('slave1'); my $slave_dbh = $sb->get_dbh_for('slave1');
my $master_dsn = 'h=127.1,P=12345,u=msandbox,p=msandbox'; my $master_dsn = 'h=127.0.0.1,P=12345,u=msandbox,p=msandbox';
if ( !$master_dbh ) { if ( !$master_dbh ) {
plan skip_all => 'Cannot connect to sandbox master'; plan skip_all => 'Cannot connect to sandbox master';
@@ -65,7 +69,7 @@ $sb->load_file('master', "t/pt-online-schema-change/samples/slave_lag.sql");
my $num_rows = 10000; my $num_rows = 10000;
diag("Loading $num_rows into the table. This might take some time."); diag("Loading $num_rows into the table. This might take some time.");
diag(`util/mysql_random_data_load --host=127.1 --port=12345 --user=msandbox --password=msandbox test pt178 $num_rows`); diag(`util/mysql_random_data_load --host=127.0.0.1 --port=12345 --user=msandbox --password=msandbox test pt178 $num_rows`);
# Run a full table scan query to ensure the slave is behind the master # Run a full table scan query to ensure the slave is behind the master
# There is no query cache in MySQL 8.0+ # There is no query cache in MySQL 8.0+
@@ -89,7 +93,7 @@ like(
# Repeat the test now using --check-slave-lag # Repeat the test now using --check-slave-lag
$args = "$master_dsn,D=test,t=pt178 --execute --chunk-size 1 --max-lag 5 --alter 'ENGINE=InnoDB' " $args = "$master_dsn,D=test,t=pt178 --execute --chunk-size 1 --max-lag 5 --alter 'ENGINE=InnoDB' "
. "--check-slave-lag h=127.1,P=12346,u=msandbox,p=msandbox,D=test,t=sbtest"; . "--check-slave-lag h=127.0.0.1,P=12346,u=msandbox,p=msandbox,D=test,t=sbtest";
# Run a full table scan query to ensure the slave is behind the master # Run a full table scan query to ensure the slave is behind the master
reset_query_cache($master_dbh, $master_dbh); reset_query_cache($master_dbh, $master_dbh);

View File

@@ -73,7 +73,7 @@ ok(
no_diff( no_diff(
sub { pt_table_checksum::main(@args) }, sub { pt_table_checksum::main(@args) },
"$sample/default-results-$sandbox_version.txt", "$sample/default-results-$sandbox_version.txt",
post_pipe => 'awk \'{print $2 " " $3 " " $4 " " $6 " " $8}\'', post_pipe => 'awk \'{print $2 " " $3 " " $4 " " $7 " " $9}\'',
), ),
"Default checksum" "Default checksum"
); );
@@ -85,6 +85,7 @@ ok(
# 2 # 2
$row = $master_dbh->selectrow_arrayref("select count(*) from percona.checksums"); $row = $master_dbh->selectrow_arrayref("select count(*) from percona.checksums");
my $max_chunks = $sandbox_version < '5.7' ? 60 : 100; my $max_chunks = $sandbox_version < '5.7' ? 60 : 100;
ok( ok(
$row->[0] > 25 && $row->[0] < $max_chunks, $row->[0] > 25 && $row->[0] < $max_chunks,
'Between 25 and 60 chunks' 'Between 25 and 60 chunks'
@@ -98,7 +99,7 @@ ok(
no_diff( no_diff(
sub { pt_table_checksum::main(@args, qw(--chunk-time 0)) }, sub { pt_table_checksum::main(@args, qw(--chunk-time 0)) },
"$sample/static-chunk-size-results-$sandbox_version.txt", "$sample/static-chunk-size-results-$sandbox_version.txt",
post_pipe => 'awk \'{print $2 " " $3 " " $4 " " $5 " " $6 " " $8}\'', post_pipe => 'awk \'{print $2 " " $3 " " $4 " " $6 " " $7 " " $9}\'',
), ),
"Static chunk size (--chunk-time 0)" "Static chunk size (--chunk-time 0)"
); );

View File

@@ -34,7 +34,7 @@ my @args = ($master_dsn, qw(--set-vars innodb_lock_wait_timeout=3), '--max
$sb->create_dbs($master_dbh, ['test']); $sb->create_dbs($master_dbh, ['test']);
$sb->load_file('master', "t/lib/samples/char-chunking/ascii.sql", 'test'); $sb->load_file('master', "t/lib/samples/char-chunking/ascii.sql", 'test');
#1
ok( ok(
no_diff( no_diff(
sub { pt_table_checksum::main(@args, sub { pt_table_checksum::main(@args,
@@ -44,14 +44,14 @@ ok(
), ),
"Char chunk ascii, explain" "Char chunk ascii, explain"
); );
#2
ok( ok(
no_diff( no_diff(
sub { pt_table_checksum::main(@args, sub { pt_table_checksum::main(@args,
qw(--tables test.ascii --chunk-index c --chunk-size 20), qw(--tables test.ascii --chunk-index c --chunk-size 20),
qw(--chunk-time 0)) }, qw(--chunk-time 0)) },
"t/pt-table-checksum/samples/char-chunk-ascii.txt", "t/pt-table-checksum/samples/char-chunk-ascii.txt",
post_pipe => 'awk \'{print $2 " " $3 " " $4 " " $5 " " $6 " " $8}\'', post_pipe => 'awk \'{print $2 " " $3 " " $4 " " $6 " " $7 " " $9}\'',
), ),
"Char chunk ascii, chunk size 20" "Char chunk ascii, chunk size 20"
); );

View File

@@ -50,6 +50,7 @@ $sb->wipe_clean($master_dbh);
eval { eval {
pt_table_checksum::main(@args, '--no-create-replicate-table'); pt_table_checksum::main(@args, '--no-create-replicate-table');
}; };
#1
like( like(
$EVAL_ERROR, $EVAL_ERROR,
qr/--replicate database percona does not exist/, qr/--replicate database percona does not exist/,
@@ -61,6 +62,7 @@ $master_dbh->do('use percona');
eval { eval {
pt_table_checksum::main(@args, '--no-create-replicate-table'); pt_table_checksum::main(@args, '--no-create-replicate-table');
}; };
#2
like( like(
$EVAL_ERROR, $EVAL_ERROR,
qr/--replicate table `percona`.`checksums` does not exist/, qr/--replicate table `percona`.`checksums` does not exist/,
@@ -90,11 +92,12 @@ $output = output(
sub { pt_table_checksum::main(@args, '--no-create-replicate-table', sub { pt_table_checksum::main(@args, '--no-create-replicate-table',
qw(-t sakila.country)) }, qw(-t sakila.country)) },
); );
#3
like( like(
$output, $output,
qr/^\S+\s+0\s+0\s+109\s+1\s+0\s+\S+\s+sakila.country$/m, qr/^\S+\s+0\s+0\s+109\s+0\s+1\s+0\s+\S+\s+sakila.country$/m,
"Uses pre-created replicate table" "Uses pre-created replicate table"
); ) or diag($output);
# ############################################################################ # ############################################################################
# Issue 1318: mk-tabke-checksum --create-replicate-table doesn't replicate # Issue 1318: mk-tabke-checksum --create-replicate-table doesn't replicate

View File

@@ -61,13 +61,13 @@ $output = output(
qw(--chunk-time 0 --chunk-size 100) ) }, qw(--chunk-time 0 --chunk-size 100) ) },
stderr => 1, stderr => 1,
); );
#1
like( like(
$output, $output,
qr/MySQL error 1265: Data truncated/, qr/MySQL error 1265: Data truncated/,
"MySQL error 1265: Data truncated for column" "MySQL error 1265: Data truncated for column"
); );
#2
my (@errors) = $output =~ m/error/; my (@errors) = $output =~ m/error/;
is( is(
scalar @errors, scalar @errors,
@@ -91,16 +91,16 @@ $output = output(
my $original_output; my $original_output;
($output, $original_output) = PerconaTest::normalize_checksum_results($output); ($output, $original_output) = PerconaTest::normalize_checksum_results($output);
#3
like( like(
$original_output, $original_output,
qr/Lock wait timeout exceeded/, qr/Lock wait timeout exceeded/,
"Warns about lock wait timeout" "Warns about lock wait timeout"
); );
#4
like( like(
$output, $output,
qr/^0 0 0 1 1 sakila.city/m, qr/^0 0 0 0 1 1 sakila.city/m,
"Skips chunk that times out" "Skips chunk that times out"
); );
@@ -129,7 +129,7 @@ unlike(
like( like(
$output, $output,
qr/^0 0 600 1 0 sakila.city/m, qr/^0 0 600 0 1 0 sakila.city/m,
"Checksum retried after lock wait timeout" "Checksum retried after lock wait timeout"
); );

View File

@@ -56,7 +56,7 @@ unlike(
like( like(
$output, $output,
qr/^\S+\s+0\s+0\s+1\s+1\s+/m, qr/^\S+\s+0\s+0\s+1\s+0\s+1\s+/m,
'Checksums the table (issue 388)' 'Checksums the table (issue 388)'
); );

View File

@@ -0,0 +1,68 @@
#!/usr/bin/env perl
BEGIN {
die "The PERCONA_TOOLKIT_BRANCH environment variable is not set.\n"
unless $ENV{PERCONA_TOOLKIT_BRANCH} && -d $ENV{PERCONA_TOOLKIT_BRANCH};
unshift @INC, "$ENV{PERCONA_TOOLKIT_BRANCH}/lib";
};
use strict;
use warnings FATAL => 'all';
use English qw(-no_match_vars);
use Test::More;
use PerconaTest;
use Sandbox;
use SqlModes;
require "$trunk/bin/pt-table-checksum";
my $dp = new DSNParser(opts=>$dsn_opts);
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
my $dbh = $sb->get_dbh_for('master');
my $sb_version = VersionParser->new($dbh);
my $rows = $dbh->selectall_hashref("SHOW VARIABLES LIKE '%version%'", ['variable_name']);
if ( !$dbh ) {
plan skip_all => 'Cannot connect to sandbox master';
} elsif ( $sb_version < '5.7.21' || !($rows->{version_comment}->{value} =~ m/percona server/i) ) {
plan skip_all => 'This test file needs Percona Server 5.7.21.21+';
} else {
plan tests => 3;
}
eval {
$dbh->selectrow_arrayref('SELECT @@query_response_time_session_stats' );
};
if ($EVAL_ERROR) {
$sb->load_file('master', 't/pt-table-checksum/samples/pt-131.sql');
}
# The sandbox servers run with lock_wait_timeout=3 and it is not dynamic
# so we need to specify --set-vars innodb_lock_wait_timeout=3 else the tool will die.
# And --max-load "" prevents waiting for status variables.
my $master_dsn = $sb->dsn_for('master');
my $output;
my $exit_status;
$ENV{PTDEBUG} = 1;
my $cmd ="PTDEBUG=1 $trunk/bin/pt-table-checksum $master_dsn --disable-qrt-plugin 2>&1";
$output = `$cmd`;
like (
$output,
qr/Restoring qrt plugin state/,
"QRT plugin status has been restored",
);
like (
$output,
qr/Disabling qrt plugin on master server/,
"QRT plugin has been disabled",
);
delete $ENV{PTDEBUG};
# #############################################################################
# Done.
# #############################################################################
$sb->wipe_clean($dbh);
ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
exit;

View File

@@ -63,7 +63,7 @@ isnt(
like( like(
$output, $output,
qr/1\s+100\s+1\s+0\s+.*test.joinit/, qr/1\s+100\s+0\s+1\s+0\s+.*test.joinit/,
"PT-226 table joinit has differences", "PT-226 table joinit has differences",
); );

View File

@@ -441,10 +441,10 @@ is(
"Checking if all tables can be checksummed ... "Checking if all tables can be checksummed ...
Starting checksum ... Starting checksum ...
Resuming from sakila.rental chunk 11, timestamp 2011-10-15 13:00:49 Resuming from sakila.rental chunk 11, timestamp 2011-10-15 13:00:49
ERRORS DIFFS ROWS CHUNKS SKIPPED TABLE ERRORS DIFFS ROWS DIFF_ROWS CHUNKS SKIPPED TABLE
0 0 5044 8 0 sakila.rental 0 0 5044 0 8 0 sakila.rental
0 0 2 1 0 sakila.staff 0 0 2 0 1 0 sakila.staff
0 0 2 1 0 sakila.store 0 0 2 0 1 0 sakila.store
", ",
"Resumed from last updated chunk" "Resumed from last updated chunk"
); );
@@ -497,8 +497,8 @@ is(
$output, $output,
"Checking if all tables can be checksummed ... "Checking if all tables can be checksummed ...
Starting checksum ... Starting checksum ...
ERRORS DIFFS ROWS CHUNKS SKIPPED TABLE ERRORS DIFFS ROWS DIFF_ROWS CHUNKS SKIPPED TABLE
0 0 26 8 0 test.t3 0 0 26 0 8 0 test.t3
", ",
"Resumed from t3" "Resumed from t3"
); );

View File

@@ -1,4 +1,4 @@
if all tables can be ... if all tables be checksummed
checksum ... checksum ...
ERRORS DIFFS ROWS CHUNKS SKIPPED TABLE ERRORS DIFFS ROWS CHUNKS SKIPPED TABLE
0 0 142 10 0 test.ascii 0 0 142 10 0 test.ascii

View File

@@ -1,3 +1,5 @@
if all tables checksummed
checksum ...
ERRORS DIFFS ROWS SKIPPED TABLE ERRORS DIFFS ROWS SKIPPED TABLE
0 0 0 0 mysql.columns_priv 0 0 0 0 mysql.columns_priv
0 0 0 0 mysql.db 0 0 0 0 mysql.db

View File

@@ -1,4 +1,4 @@
if all tables be ... if all tables checksummed
checksum ... checksum ...
ERRORS DIFFS ROWS SKIPPED TABLE ERRORS DIFFS ROWS SKIPPED TABLE
0 0 0 0 mysql.columns_priv 0 0 0 0 mysql.columns_priv

View File

@@ -1,4 +1,4 @@
if all tables be ... if all tables checksummed
checksum ... checksum ...
ERRORS DIFFS ROWS SKIPPED TABLE ERRORS DIFFS ROWS SKIPPED TABLE
0 0 0 0 mysql.columns_priv 0 0 0 0 mysql.columns_priv

View File

@@ -0,0 +1,16 @@
-- See https://www.percona.com/doc/percona-server/LATEST/diagnostics/response_time_distribution.html
-- This plugin is used for gathering statistics.
INSTALL PLUGIN QUERY_RESPONSE_TIME_AUDIT SONAME 'query_response_time.so';
-- This plugin provides the interface (QUERY_RESPONSE_TIME) to output gathered statistics.
INSTALL PLUGIN QUERY_RESPONSE_TIME SONAME 'query_response_time.so';
-- This plugin provides the interface (QUERY_RESPONSE_TIME_READ) to output gathered statistics.
INSTALL PLUGIN QUERY_RESPONSE_TIME_READ SONAME 'query_response_time.so';
-- This plugin provides the interface (QUERY_RESPONSE_TIME_WRITE) to output gathered statistics.
INSTALL PLUGIN QUERY_RESPONSE_TIME_WRITE SONAME 'query_response_time.so';
-- Start collecting query time metrics,
SET GLOBAL query_response_time_stats = on;

View File

@@ -1,3 +1,5 @@
if all tables be checksummed
checksum ...
ERRORS DIFFS ROWS CHUNKS SKIPPED TABLE ERRORS DIFFS ROWS CHUNKS SKIPPED TABLE
0 0 0 1 0 mysql.columns_priv 0 0 0 1 0 mysql.columns_priv
0 0 0 1 0 mysql.db 0 0 0 1 0 mysql.db

View File

@@ -1,4 +1,4 @@
if all tables can be ... if all tables be checksummed
checksum ... checksum ...
ERRORS DIFFS ROWS CHUNKS SKIPPED TABLE ERRORS DIFFS ROWS CHUNKS SKIPPED TABLE
0 0 0 1 0 mysql.columns_priv 0 0 0 1 0 mysql.columns_priv

View File

@@ -1,4 +1,4 @@
if all tables can be ... if all tables be checksummed
checksum ... checksum ...
ERRORS DIFFS ROWS CHUNKS SKIPPED TABLE ERRORS DIFFS ROWS CHUNKS SKIPPED TABLE
0 0 0 1 0 mysql.columns_priv 0 0 0 1 0 mysql.columns_priv