#!/usr/bin/env perl use strict; use warnings; my $usage= <&1"; @cmd_output=`$server_cmd`; die if $?; my $master_port= (grep (/Using MASTER_MYPORT .*= (\d+)$/, @cmd_output))[0]; $master_port =~ s/.*= //; chomp $master_port; die unless $master_port > 0; my $client_cmd= "$client_exe_path/mysql -u root -h 127.0.0.1 -P $master_port test < $sql_name"; open(FILE, ">", $sql_name) or die; # To exhibit BUG#36578 with -d, we don't create an index if -d. This is # because the presence of an index will cause repair-by-sort to be used, # where sort_get_next_record() is only called inside #_ma_create_index_by_sort(), so the latter function fails and in this # case retry_repair is set, so bug does not happen. Whereas without # an index, repair-with-key-cache is called, which calls # sort_get_next_record() whose failure itself does not cause a retry. print FILE "create table t1 (a varchar(1000)". ($corrupt_index ? ", index(a)" : "") .") engine=aria;\n"; print FILE <&1"; for($i= 1; $i <= $force_after; $i= $i + 1) { print "mysqld restart number $i... "; unlink($error_log_name) or die; `$server_cmd`; # mysqld should return 1 when can't read log die unless (($? >> 8) == 1); open(FILE, "<", $error_log_name) or die; @cmd_output= ; close FILE; die unless grep(/\[ERROR\] mysqld(.exe)*: Aria engine: log initialization failed/, @cmd_output); die unless grep(/\[ERROR\] Plugin 'Aria' init function returned error./, @cmd_output); print "failed - ok\n"; } print "mysqld restart number $i... "; unlink($error_log_name) or die; @cmd_output=`$server_cmd`; die if $?; open(FILE, "<", $error_log_name) or die; @cmd_output= ; close FILE; die unless grep(/\[Warning\] mysqld(.exe)*: Aria engine: removed all logs after [\d]+ consecutive failures of recovery from logs/, @cmd_output); die unless grep(/\[ERROR\] mysqld(.exe)*: File '.*tmp.aria_log.00000001' not found \(Errcode: 2\)/, @cmd_output); print "success - ok\n"; open(FILE, ">", $sql_name) or die; print FILE <; close FILE; die if grep(/$corrupt_message/, @cmd_output); print "inserting in table\n"; `$client_cmd`; die if $?; print "table is usable - ok\n"; open(FILE, "<", $error_log_name) or die; @cmd_output= ; close FILE; die unless grep(/$corrupt_message/, @cmd_output); die unless grep(/\[Warning\] Recovering table: '..test.t1'/, @cmd_output); print "was corrupted and automatically repaired - ok\n"; # remove our traces kill_server(15); print "TEST ALL OK\n"; # kills mysqld with signal given in parameter sub kill_server { my ($sig)= @_; my $wait_count= 0; my $kill_cmd; my @kill_output; open(FILE, "<", $server_pid_name) or die; @cmd_output= ; close FILE; $server_pid= $cmd_output[0]; chomp $server_pid; die unless $server_pid > 0; if ($iswindows) { # On Windows, server_pid_name is not the "main" process id # so perl's kill() does not see this process id. # But taskkill works, though only with /F ("-9"-style kill). $kill_cmd= "taskkill /F /PID $server_pid 2>&1"; @kill_output= `$kill_cmd`; die unless grep(/has been terminated/, @kill_output); } else { kill($sig, $server_pid) or die; } while (1) # wait until mysqld process gone { if ($iswindows) { @kill_output= `$kill_cmd`; last if grep(/not found/, @kill_output); } else { kill (0, $server_pid) or last; } print "waiting for mysqld to die\n" if ($wait_count > 30); $wait_count= $wait_count + 1; select(undef, undef, undef, 0.1); } }