← Back to team overview

maria-developers team mailing list archive

bzr commit into MariaDB 5.1, with Maria 1.5:maria branch (knielsen:2685)

 

#At lp:maria

 2685 knielsen@xxxxxxxxxxxxxxx	2009-03-17
      When we remove the server data dir before server restart, preserve the
      error log (don't delete it between restarts), as it may contain
      valuable information even for test cases which don't show direct
      failures.
modified:
  mysql-test/mysql-test-run.pl

=== modified file 'mysql-test/mysql-test-run.pl'
--- a/mysql-test/mysql-test-run.pl	2009-03-17 08:23:05 +0000
+++ b/mysql-test/mysql-test-run.pl	2009-03-17 11:58:05 +0000
@@ -3511,6 +3511,29 @@ sub run_testcase ($$) {
 }
 
 
+# We want to preserve the error log between server restarts, as it may contain
+# valuable debugging information even if there is no test failure recorded.
+sub _preserve_error_log_names {
+  my ($mysqld)= @_;
+  my $error_log_file= $mysqld->value('log-error');
+  my $error_log_dir= dirname($error_log_file);
+  my $save_name= $error_log_dir ."/../". $mysqld->name() .".error.log";
+  return ($error_log_file, $save_name);
+}
+
+sub preserve_error_log {
+  my ($mysqld)= @_;
+  my ($error_log_file, $save_name)= _preserve_error_log_names($mysqld);
+  my $res= rename($error_log_file, $save_name);
+  # Ignore any errors, as it's just a best-effort to keep the log if possible.
+}
+
+sub restore_error_log {
+  my ($mysqld)= @_;
+  my ($error_log_file, $save_name)= _preserve_error_log_names($mysqld);
+  my $res= rename($save_name, $error_log_file);
+}
+
 # Keep track of last position in mysqld error log where we scanned for
 # warnings, so we can attribute any warnings found to the correct test
 # suite or server restart.
@@ -3929,6 +3952,7 @@ sub clean_datadir {
   foreach my $mysqld ( mysqlds() )
   {
     my $mysqld_dir= dirname($mysqld->value('datadir'));
+    preserve_error_log($mysqld);
     if (-d $mysqld_dir ) {
       mtr_verbose(" - removing '$mysqld_dir'");
       rmtree($mysqld_dir);
@@ -4579,6 +4603,7 @@ sub start_servers($) {
       }
 
       if (-d $datadir ) {
+        preserve_error_log($mysqld);
 	mtr_verbose(" - removing '$datadir'");
 	rmtree($datadir);
       }
@@ -4604,6 +4629,7 @@ sub start_servers($) {
 	unless -d $datadir;
 
     }
+    restore_error_log($mysqld);
 
     # Create the servers tmpdir
     my $tmpdir= $mysqld->value('tmpdir');




Follow ups