List:Commits« Previous MessageNext Message »
From:msvensson Date:September 18 2007 5:56am
Subject:bk commit into 5.0 tree (msvensson:1.2533)
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of msvensson. When msvensson does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2007-09-18 07:55:56+02:00, msvensson@shellback.(none) +2 -0
  Use only one installed MySQL System database as reference

  mysql-test/mysql-test-run.pl@stripped, 2007-09-18 07:55:53+02:00, msvensson@shellback.(none) +63 -181
    Use only one installed MySQL System database as reference

  mysql-test/t/bootstrap.test@stripped, 2007-09-18 07:55:53+02:00, msvensson@shellback.(none) +6 -0
    Use only one installed MySQL System database as reference

diff -Nrup a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl
--- a/mysql-test/mysql-test-run.pl	2007-09-17 10:51:49 +02:00
+++ b/mysql-test/mysql-test-run.pl	2007-09-18 07:55:53 +02:00
@@ -112,7 +112,6 @@ our $path_charsetsdir;
 our $path_client_bindir;
 our $path_language;
 our $path_timefile;
-our $path_snapshot;
 our $path_current_test_log;
 our $path_my_basedir;
 
@@ -278,8 +277,6 @@ our $path_ndb_testrun_log;
 
 our $path_sql_dir;
 
-our @data_dir_lst;
-
 our $used_binlog_format;
 our $used_default_engine;
 our $debug_compiled_binaries;
@@ -303,7 +300,6 @@ sub main ();
 sub initial_setup ();
 sub command_line_setup ();
 sub set_mtr_build_thread_ports($);
-sub datadir_list_setup ();
 sub executable_setup ();
 sub environment_setup ();
 sub kill_running_servers ();
@@ -313,15 +309,15 @@ sub check_ssl_support ($);
 sub check_running_as_root();
 sub check_ndbcluster_support ($);
 sub rm_ndbcluster_tables ($);
-sub ndbcluster_start_install ($);
+sub ndbcluster_install ($);
 sub ndbcluster_start ($$);
 sub ndbcluster_wait_started ($$);
 sub mysqld_wait_started($);
 sub run_benchmarks ($);
 sub initialize_servers ();
 sub mysql_install_db ();
-sub install_db ($$);
-sub copy_install_db ($$);
+sub install_db();
+sub copy_install_db ($);
 sub run_testcase ($);
 sub run_testcase_stop_servers ($$$);
 sub run_testcase_start_servers ($);
@@ -1176,7 +1172,7 @@ sub command_line_setup () {
    data_dir        => "$data_dir",
    connect_string  => "$opt_ndbconnectstring",
    path_pid        => "$data_dir/ndb_3.pid", # Nodes + 1
-   installed_ok    => 0,
+   failed_start    => 0,
   };
 
   $data_dir= "$opt_vardir/ndbcluster-$opt_ndbcluster_port_slave";
@@ -1188,7 +1184,7 @@ sub command_line_setup () {
    data_dir        => "$data_dir",
    connect_string  => "$opt_ndbconnectstring_slave",
    path_pid        => "$data_dir/ndb_2.pid", # Nodes + 1
-   installed_ok    => 0,
+   failed_start    => 0,
   };
 
   # Init pids of ndbd's
@@ -1226,8 +1222,6 @@ sub command_line_setup () {
   $path_current_test_log= "$opt_vardir/log/current_test";
   $path_ndb_testrun_log= "$opt_vardir/log/ndb_testrun.log";
 
-  $path_snapshot= "$opt_tmpdir/snapshot_$opt_master_myport/";
-
   if ( $opt_valgrind and $opt_debug )
   {
     # When both --valgrind and --debug is selected, send
@@ -1285,29 +1279,6 @@ sub set_mtr_build_thread_ports($) {
 }
 
 
-sub datadir_list_setup () {
-
-  # Make a list of all data_dirs
-  for (my $idx= 0; $idx < $max_master_num; $idx++)
-  {
-    push(@data_dir_lst, $master->[$idx]->{'path_myddir'});
-  }
-
-  for (my $idx= 0; $idx < $max_slave_num; $idx++)
-  {
-    push(@data_dir_lst, $slave->[$idx]->{'path_myddir'});
-  }
-
-  unless ($opt_skip_im)
-  {
-    foreach my $instance (@{$instance_manager->{'instances'}})
-    {
-      push(@data_dir_lst, $instance->{'path_datadir'});
-    }
-  }
-}
-
-
 ##############################################################################
 #
 #  Set paths to various executable programs
@@ -2118,13 +2089,6 @@ sub setup_vardir() {
   mkpath("$opt_vardir/tmp");
   mkpath($opt_tmpdir) if $opt_tmpdir ne "$opt_vardir/tmp";
 
-  # Create new data dirs
-  foreach my $data_dir (@data_dir_lst)
-  {
-    mkpath("$data_dir/mysql");
-    mkpath("$data_dir/test");
-  }
-
   # Make a link std_data_ln in var/ that points to std_data
   if ( ! $glob_win32 )
   {
@@ -2300,7 +2264,7 @@ sub check_ndbcluster_support ($) {
 }
 
 
-sub ndbcluster_start_install ($) {
+sub ndbcluster_install ($) {
   my $cluster= shift;
 
   mtr_report("Installing $cluster->{'name'} Cluster");
@@ -2371,11 +2335,6 @@ sub ndbcluster_start_install ($) {
   close OUT;
   close IN;
 
-
-  # Start cluster with "--initial"
-
-  ndbcluster_start($cluster, "--initial");
-
   return 0;
 }
 
@@ -2717,8 +2676,6 @@ EOF
 
 sub initialize_servers () {
 
-  datadir_list_setup();
-
   if ( $opt_extern )
   {
     # Running against an already started server, if the specified
@@ -2746,12 +2703,6 @@ sub initialize_servers () {
       setup_vardir();
 
       mysql_install_db();
-      if ( $opt_force )
-      {
-	# Save a snapshot of the freshly installed db
-	# to make it possible to restore to a known point in time
-	save_installed_db();
-      }
     }
   }
   check_running_as_root();
@@ -2767,18 +2718,7 @@ sub initialize_servers () {
 
 sub mysql_install_db () {
 
-  install_db('master', $master->[0]->{'path_myddir'});
-
-  if ($max_master_num > 1)
-  {
-    copy_install_db('master', $master->[1]->{'path_myddir'});
-  }
-
-  # Install the number of slave databses needed
-  for (my $idx= 0; $idx < $max_slave_num; $idx++)
-  {
-    copy_install_db("slave".($idx+1), $slave->[$idx]->{'path_myddir'});
-  }
+  install_db();
 
   if ( ! $opt_skip_im )
   {
@@ -2792,9 +2732,9 @@ sub mysql_install_db () {
   {
     # Don't install master cluster
   }
-  elsif (ndbcluster_start_install($clusters->[0]))
+  elsif (ndbcluster_install($clusters->[0]))
   {
-    mtr_warning("Failed to start install of $clusters->[0]->{name}");
+    mtr_warning("Failed to install $clusters->[0]->{name} cluster");
     $cluster_started_ok= 0;
   }
 
@@ -2804,29 +2744,12 @@ sub mysql_install_db () {
   {
     # Don't install slave cluster
   }
-  elsif (ndbcluster_start_install($clusters->[1]))
+  elsif (ndbcluster_install($clusters->[1]))
   {
-    mtr_warning("Failed to start install of $clusters->[1]->{name}");
+    mtr_warning("Failed to install $clusters->[1]->{name} cluster");
     $cluster_started_ok= 0;
   }
 
-  foreach my $cluster (@{$clusters})
-  {
-
-    next if !$cluster->{'proc'};
-
-    $cluster->{'installed_ok'}= 1; # Assume install suceeds
-
-    if (ndbcluster_wait_started($cluster, ""))
-    {
-      # failed to install, disable usage and flag that its no ok
-      mtr_report("ndbcluster_install of $cluster->{'name'} failed");
-      $cluster->{"installed_ok"}= 0;
-
-      $cluster_started_ok= 0;
-    }
-  }
-
   if ( ! $cluster_started_ok )
   {
     if ( $opt_force)
@@ -2843,24 +2766,26 @@ sub mysql_install_db () {
 }
 
 
-sub copy_install_db ($$) {
-  my $type=      shift;
-  my $data_dir=  shift;
+#
+# Copy the reference database into selected datadir
+#
+sub copy_install_db ($) {
+  my $path_data_dir=  shift;
 
-  mtr_report("Installing \u$type Database");
+  # Don't install over another db
+  mtr_error("There is already an installed db in '$path_data_dir'")
+    if -d $path_data_dir;
 
-  # Just copy the installed db from first master
-  mtr_copy_dir($master->[0]->{'path_myddir'}, $data_dir);
+  # copy the installed db into place
+  mtr_copy_dir("$opt_vardir/install.db", $path_data_dir);
 
 }
 
 
-sub install_db ($$) {
-  my $type=      shift;
-  my $data_dir=  shift;
-
-  mtr_report("Installing \u$type Database");
+sub install_db () {
+  my $data_dir= "$opt_vardir/install.db";
 
+  mtr_report("Installing System Database");
 
   my $args;
   mtr_init_args(\$args);
@@ -2875,15 +2800,12 @@ sub install_db ($$) {
 
   if ( $opt_debug )
   {
-    mtr_add_arg($args, "--debug=d:t:i:A,%s/log/bootstrap_%s.trace",
-		$path_vardir_trace, $type);
+    mtr_add_arg($args, "--debug=d:t:i:A,%s/log/bootstrap.trace",
+		$path_vardir_trace);
   }
 
-  if ( ! $glob_netware )
-  {
-    mtr_add_arg($args, "--language=%s", $path_language);
-    mtr_add_arg($args, "--character-sets-dir=%s", $path_charsetsdir);
-  }
+  mtr_add_arg($args, "--language=%s", $path_language);
+  mtr_add_arg($args, "--character-sets-dir=%s", $path_charsetsdir);
 
   # If DISABLE_GRANT_OPTIONS is defined when the server is compiled (e.g.,
   # configure --disable-grant-options), mysqld will not recognize the
@@ -2935,6 +2857,9 @@ sub install_db ($$) {
   mtr_tofile($path_bootstrap_log,
 	     "$exe_mysqld_bootstrap " . join(" ", @$args) . "\n");
 
+  # Create directories mysql and test
+  mkpath("$data_dir/mysql");
+  mkpath("$data_dir/test");
 
   if ( mtr_run($exe_mysqld_bootstrap, $args, $bootstrap_sql_file,
                $path_bootstrap_log, $path_bootstrap_log,
@@ -3039,30 +2964,7 @@ sub im_prepare_data_dir($) {
 
   foreach my $instance (@{$instance_manager->{'instances'}})
   {
-    copy_install_db(
-      'im_mysqld_' . $instance->{'server_id'},
-      $instance->{'path_datadir'});
-  }
-}
-
-
-
-#
-# Restore snapshot of the installed slave databases
-# if the snapshot exists
-#
-sub restore_slave_databases ($) {
-  my ($num_slaves)= @_;
-
-  if ( -d $path_snapshot)
-  {
-    for (my $idx= 0; $idx < $num_slaves; $idx++)
-    {
-      my $data_dir= $slave->[$idx]->{'path_myddir'};
-      my $name= basename($data_dir);
-      rmtree($data_dir);
-      mtr_copy_dir("$path_snapshot/$name", $data_dir);
-    }
+    copy_install_db($instance->{'path_datadir'});
   }
 }
 
@@ -3103,11 +3005,11 @@ sub run_testcase_check_skip_test($)
       }
 
       # If test needs this cluster, check it was installed ok
-      if ( !$cluster->{'installed_ok'} )
+      if ( $cluster->{'failed_start'} >= 3 )
       {
 	mtr_report_test_name($tinfo);
 	$tinfo->{comment}=
-	  "Cluster $cluster->{'name'} was not installed ok";
+	  "Cluster $cluster->{'name'} failed to start too many times";
 	mtr_report_test_failed($tinfo);
 	return 1;
       }
@@ -3420,27 +3322,10 @@ sub run_testcase ($) {
 
 
 #
-# Save a snapshot of the installed test db(s)
-# I.e take a snapshot of the var/ dir
-#
-sub save_installed_db () {
-
-  mtr_report("Saving snapshot of installed databases");
-  rmtree($path_snapshot);
-
-  foreach my $data_dir (@data_dir_lst)
-  {
-    my $name= basename($data_dir);
-    mtr_copy_dir("$data_dir", "$path_snapshot/$name");
-  }
-}
-
-
-#
 # Save any interesting files in the data_dir
 # before the data dir is removed.
 #
-sub save_files_before_restore($$) {
+sub save_files_after_test_failure($$) {
   my $test_name= shift;
   my $data_dir= shift;
   my $save_name= "$opt_vardir/log/$test_name";
@@ -3458,42 +3343,31 @@ sub save_files_before_restore($$) {
 }
 
 
-#
-# Restore snapshot of the installed test db(s)
-# if the snapshot exists
-#
-sub restore_installed_db ($) {
+sub after_test_failure ($) {
   my $test_name= shift;
 
-  if ( -d $path_snapshot)
-  {
-    mtr_report("Restoring snapshot of databases");
+  mtr_report("Cleaning datadirs");
 
-    foreach my $data_dir (@data_dir_lst)
-    {
-      my $name= basename($data_dir);
-      save_files_before_restore($test_name, $data_dir);
-      rmtree("$data_dir");
-      mtr_copy_dir("$path_snapshot/$name", "$data_dir");
-    }
+  foreach my $server (@{$master}, @{$slave} )
+  {
+    my $data_dir= $server->{path_myddir};
+    my $name= basename($data_dir);
+    save_files_after_test_failure($test_name, $data_dir);
+    rmtree("$data_dir");
+  }
 
-    # Remove the ndb_*_fs dirs for all ndbd nodes
-    # forcing a clean start of ndb
-    foreach my $cluster (@{$clusters})
+  # Remove the ndb_*_fs dirs for all ndbd nodes
+  # forcing a clean start of ndb
+  foreach my $cluster (@{$clusters})
+  {
+    foreach my $ndbd (@{$cluster->{'ndbds'}})
     {
-      foreach my $ndbd (@{$cluster->{'ndbds'}})
-      {
-	rmtree("$ndbd->{'path_fs'}" );
-      }
+      rmtree("$ndbd->{'path_fs'}" );
     }
   }
-  else
-  {
-    # No snapshot existed
-    mtr_error("No snapshot existed");
-  }
 }
 
+
 sub report_failure_and_restart ($) {
   my $tinfo= shift;
 
@@ -3504,8 +3378,7 @@ sub report_failure_and_restart ($) {
     # Stop all servers that are known to be running
     stop_all_servers();
 
-    # Restore the snapshot of the installed test db
-    restore_installed_db($tinfo->{'name'});
+    after_test_failure($tinfo->{'name'});
     mtr_report("Resuming Tests\n");
     return;
   }
@@ -3938,6 +3811,10 @@ sub mysqld_start ($$$) {
   # Remove the pidfile
   unlink($mysqld->{'path_pid'});
 
+  # Copy data dir from installed db if it does not exist
+  copy_install_db($mysqld->{path_myddir})
+    unless -d $mysqld->{path_myddir};
+
   if ( defined $exe )
   {
     $mysqld->{'proc'}= My::SafeProcess->new
@@ -4195,6 +4072,12 @@ sub run_testcase_stop_servers($$$) {
     my $cluster= $clusters->[1];
     start_shutdown_servers( $cluster, @{$cluster->{'ndbds'}} );
     wait_for_servers( $cluster, @{$cluster->{'ndbds'}} );
+
+    foreach my $mysqld ( @{$slave} )
+    {
+      # Remove slaves datadir
+      rmtree($mysqld->{'path_myddir'});
+    }
   }
 
   foreach my $mysqld (@{$master}, @{$slave})
@@ -4289,8 +4172,6 @@ sub run_testcase_start_servers($) {
   # ----------------------------------------------------------------------
   if ( $tinfo->{'slave_num'} )
   {
-    restore_slave_databases($tinfo->{'slave_num'});
-
     do_before_start_slave($tinfo);
 
     if ( ! $opt_skip_ndbcluster_slave and
@@ -4325,6 +4206,7 @@ sub run_testcase_start_servers($) {
     {
       # failed to start
       $tinfo->{'comment'}= "Start of $cluster->{'name'} cluster failed";
+      $cluster->{failed_start}++;
       return 1;
     }
   }
diff -Nrup a/mysql-test/t/bootstrap.test b/mysql-test/t/bootstrap.test
--- a/mysql-test/t/bootstrap.test	2007-08-07 11:40:02 +02:00
+++ b/mysql-test/t/bootstrap.test	2007-09-18 07:55:53 +02:00
@@ -6,6 +6,12 @@ drop table if exists t1;
 --enable_warnings
 
 
+# Get datadir of the running server
+let $datadir= query_get_value(SHOW VARIABLES LIKE "datadir", Value, 1);
+
+# Add the datadir to the bootstrap command
+let $MYSQLD_BOOTSTRAP_CMD= $MYSQLD_BOOTSTRAP_CMD --datadir=$datadir;
+
 #
 # Check that --bootstrap reads from stdin
 #
Thread
bk commit into 5.0 tree (msvensson:1.2533)msvensson18 Sep