MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Alexander Nozdrin Date:July 20 2006 9:24am
Subject:bk commit into 5.0 tree (anozdrin:1.2237) BUG#20716
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of alik. When alik 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, 2006-07-20 13:24:12+04:00, anozdrin@stripped +12 -0
  Fix for BUG#20716: SHOW INSTANCES statement causes races in IM tests.
    
  Fix for the bug in mysql-test-run.pl which prevents other tests succeed
  after IM-test failure.
    
  The idea of the fix of BUG#20716 is to:
    1. Check each SHOW INSTANCES statement, add necessary "sleep" instruction before;
    2. Move all environment checkings into the one file and include it everywhere.

  mysql-test/include/im_check_env.inc@stripped, 2006-07-20 13:24:11+04:00, anozdrin@stripped +27 -0
    A new file to be included in each IM-test.
    The statements in the file ensure that starting
    conditions (environment) are as expected.

  mysql-test/include/im_check_env.inc@stripped, 2006-07-20 13:24:11+04:00, anozdrin@stripped +0 -0

  mysql-test/mysql-test-run.pl@stripped, 2006-07-20 13:24:10+04:00, anozdrin@stripped +22 -0
    Fix bug in mysql-test-run.pl -- kill leftovers if some
    guarded mysqld-instance is still alive after IM shutdown.

  mysql-test/r/im_daemon_life_cycle.result@stripped, 2006-07-20 13:24:10+04:00, anozdrin@stripped +3 -0
    Updated result file.

  mysql-test/r/im_life_cycle.result@stripped, 2006-07-20 13:24:10+04:00, anozdrin@stripped +3 -8
    Updated result file.

  mysql-test/r/im_options_set.result@stripped, 2006-07-20 13:24:11+04:00, anozdrin@stripped +5 -2
    Updated result file.

  mysql-test/r/im_options_unset.result@stripped, 2006-07-20 13:24:11+04:00, anozdrin@stripped +5 -2
    Updated result file.

  mysql-test/r/im_utils.result@stripped, 2006-07-20 13:24:11+04:00, anozdrin@stripped +3 -0
    Updated result file.

  mysql-test/t/im_daemon_life_cycle.imtest@stripped, 2006-07-20 13:24:11+04:00, anozdrin@stripped +1 -15
    Include im_check_env.inc for the checking of environment.

  mysql-test/t/im_life_cycle.imtest@stripped, 2006-07-20 13:24:11+04:00, anozdrin@stripped +21 -45
    Include im_check_env.inc for the checking of environment.

  mysql-test/t/im_options_set.imtest@stripped, 2006-07-20 13:24:11+04:00, anozdrin@stripped +1 -26
    Include im_check_env.inc for the checking of environment.

  mysql-test/t/im_options_unset.imtest@stripped, 2006-07-20 13:24:11+04:00, anozdrin@stripped +1 -26
    Include im_check_env.inc for the checking of environment.

  mysql-test/t/im_utils.imtest@stripped, 2006-07-20 13:24:11+04:00, anozdrin@stripped +6 -25
    Include im_check_env.inc for the checking of environment.

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	anozdrin
# Host:	booka.site
# Root:	/home/alik/MySQL/devel/5.0-rt-bug20716
--- New file ---
+++ mysql-test/include/im_check_env.inc	06/07/20 13:24:11
# This file is intended to be used in each IM-test. It contains stamements,
# that ensure that starting conditions (environment) for the IM-test are as
# expected.

# Wait for mysqld1 (guarded instance) to start.

--exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD1_PATH_PID 30 started

# Check the running instances.

--connect (mysql1_con,localhost,root,,mysql,$IM_MYSQLD1_PORT,$IM_MYSQLD1_SOCK)

--connection mysql1_con

SHOW VARIABLES LIKE 'server_id';

--connection default

# Let IM detect that mysqld1 is online. This delay should be longer than
# monitoring interval.

--sleep 2

# Check that IM understands that mysqld1 is online, while mysqld2 is
# offline.

SHOW INSTANCES;


--- 1.3/mysql-test/r/im_daemon_life_cycle.result	2006-07-20 13:24:17 +04:00
+++ 1.4/mysql-test/r/im_daemon_life_cycle.result	2006-07-20 13:24:17 +04:00
@@ -1,4 +1,7 @@
 Success: the process has been started.
+SHOW VARIABLES LIKE 'server_id';
+Variable_name	Value
+server_id	1
 SHOW INSTANCES;
 instance_name	status
 mysqld1	online

--- 1.6/mysql-test/r/im_life_cycle.result	2006-07-20 13:24:17 +04:00
+++ 1.7/mysql-test/r/im_life_cycle.result	2006-07-20 13:24:17 +04:00
@@ -1,8 +1,7 @@
-
---------------------------------------------------------------------
--- 1.1.1.
---------------------------------------------------------------------
 Success: the process has been started.
+SHOW VARIABLES LIKE 'server_id';
+Variable_name	Value
+server_id	1
 SHOW INSTANCES;
 instance_name	status
 mysqld1	online
@@ -40,10 +39,6 @@ ERROR HY000: Bad instance name. Check th
 --------------------------------------------------------------------
 -- 1.1.6.
 --------------------------------------------------------------------
-SHOW INSTANCES;
-instance_name	status
-mysqld1	online
-mysqld2	offline
 Killing the process...
 Sleeping...
 Success: the process was restarted.

--- 1.4/mysql-test/r/im_options_set.result	2006-07-20 13:24:17 +04:00
+++ 1.5/mysql-test/r/im_options_set.result	2006-07-20 13:24:17 +04:00
@@ -1,8 +1,11 @@
-server_id           = 1
-server_id           = 2
+Success: the process has been started.
 SHOW VARIABLES LIKE 'server_id';
 Variable_name	Value
 server_id	1
+SHOW INSTANCES;
+instance_name	status
+mysqld1	online
+mysqld2	offline
 SET mysqld1.server_id = 11;
 server_id =11
 server_id           = 2

--- 1.4/mysql-test/r/im_options_unset.result	2006-07-20 13:24:17 +04:00
+++ 1.5/mysql-test/r/im_options_unset.result	2006-07-20 13:24:17 +04:00
@@ -1,8 +1,11 @@
-server_id           = 1
-server_id           = 2
+Success: the process has been started.
 SHOW VARIABLES LIKE 'server_id';
 Variable_name	Value
 server_id	1
+SHOW INSTANCES;
+instance_name	status
+mysqld1	online
+mysqld2	offline
 UNSET mysqld1.server_id;
 server_id           = 2
 SHOW VARIABLES LIKE 'server_id';

--- 1.3/mysql-test/r/im_utils.result	2006-07-20 13:24:17 +04:00
+++ 1.4/mysql-test/r/im_utils.result	2006-07-20 13:24:17 +04:00
@@ -1,4 +1,7 @@
 Success: the process has been started.
+SHOW VARIABLES LIKE 'server_id';
+Variable_name	Value
+server_id	1
 SHOW INSTANCES;
 instance_name	status
 mysqld1	online

--- 1.2/mysql-test/t/im_daemon_life_cycle.imtest	2006-07-20 13:24:17 +04:00
+++ 1.3/mysql-test/t/im_daemon_life_cycle.imtest	2006-07-20 13:24:17 +04:00
@@ -7,21 +7,7 @@
 ###########################################################################
 
 --source include/im_check_os.inc
-
-###########################################################################
-
-# Wait for mysqld1 (guarded instance) to start.
-
---exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD1_PATH_PID 30 started
-
-# Let IM detect that mysqld1 is online. This delay should be longer than
-# monitoring interval.
-
---sleep 3
-
-# Check that start conditions are as expected.
-
-SHOW INSTANCES;
+--source include/im_check_env.inc
 
 ###########################################################################
 

--- 1.5/mysql-test/t/im_life_cycle.imtest	2006-07-20 13:24:17 +04:00
+++ 1.6/mysql-test/t/im_life_cycle.imtest	2006-07-20 13:24:17 +04:00
@@ -7,33 +7,7 @@
 ###########################################################################
 
 --source include/im_check_os.inc
-
-###########################################################################
-#
-# 1.1.1. Check that Instance Manager is able:
-#  - to read definitions of two mysqld-instances;
-#  - to start the first instance;
-#  - to understand 'nonguarded' option and keep the second instance down;
-#
-###########################################################################
-
---echo
---echo --------------------------------------------------------------------
---echo -- 1.1.1.
---echo --------------------------------------------------------------------
-
-# Wait for mysqld1 (guarded instance) to start.
-
---exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD1_PATH_PID 30 started
-
-# Let IM detect that mysqld1 is online. This delay should be longer than
-# monitoring interval.
-
---sleep 3
-
-# Check that start conditions are as expected.
-
-SHOW INSTANCES;
+--source include/im_check_env.inc
 
 ###########################################################################
 #
@@ -54,9 +28,10 @@ START INSTANCE mysqld2;
 # FIXME: START INSTANCE should be synchronous.
 --exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 started
 
-# FIXME: SHOW INSTANCES is not deterministic unless START INSTANCE is
-# synchronous. Even waiting for mysqld to start by looking at its pid file is
-# not enough, because IM may not detect that mysqld has started.
+# FIXME: Result of SHOW INSTANCES here is not deterministic unless START
+# INSTANCE is synchronous. Even waiting for mysqld to start by looking at
+# its pid file is not enough, because it is unknown when IM detects that
+# mysqld has started.
 # SHOW INSTANCES;
 
 --connect (mysql_con,localhost,root,,mysql,$IM_MYSQLD2_PORT,$IM_MYSQLD2_SOCK)
@@ -86,9 +61,10 @@ STOP INSTANCE mysqld2;
 # FIXME: STOP INSTANCE should be synchronous.
 --exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 stopped
 
-# FIXME: SHOW INSTANCES is not deterministic unless START INSTANCE is
-# synchronous. Even waiting for mysqld to start by looking at its pid file is
-# not enough, because IM may not detect that mysqld has started.
+# FIXME: Result of SHOW INSTANCES here is not deterministic unless START
+# INSTANCE is synchronous. Even waiting for mysqld to start by looking at
+# its pid file is not enough, because it is unknown when IM detects that
+# mysqld has started.
 # SHOW INSTANCES;
 
 ###########################################################################
@@ -114,8 +90,8 @@ START INSTANCE mysqld1;
 
 ###########################################################################
 #
-# 1.1.5. Check that Instance Manager reports correct errors for 'STOP INSTANCE'
-# command:
+# 1.1.5. Check that Instance Manager reports correct errors for
+#        'STOP INSTANCE' command:
 #   - if the client tries to start unregistered instance;
 #   - if the client tries to start already stopped instance;
 #   - if the client submits invalid arguments;
@@ -146,12 +122,10 @@ STOP INSTANCE mysqld3;
 --echo -- 1.1.6.
 --echo --------------------------------------------------------------------
 
-SHOW INSTANCES;
-
 --exec $MYSQL_TEST_DIR/t/kill_n_check.sh $IM_MYSQLD1_PATH_PID restarted 30
 
-# Give some time to IM to detect that mysqld was restarted. It should be longer
-# than monitoring interval.
+# Give some time to IM to detect that mysqld was restarted. It should be
+# longer than monitoring interval.
 
 --sleep 3
 
@@ -172,16 +146,18 @@ START INSTANCE mysqld2;
 # FIXME: START INSTANCE should be synchronous.
 --exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 started
 
-# FIXME: SHOW INSTANCES is not deterministic unless START INSTANCE is
-# synchronous. Even waiting for mysqld to start by looking at its pid file is
-# not enough, because IM may not detect that mysqld has started.
+# FIXME: Result of SHOW INSTANCES here is not deterministic unless START
+# INSTANCE is synchronous. Even waiting for mysqld to start by looking at
+# its pid file is not enough, because it is unknown when IM detects that
+# mysqld has started.
 # SHOW INSTANCES;
 
 --exec $MYSQL_TEST_DIR/t/kill_n_check.sh $IM_MYSQLD2_PATH_PID killed 10
 
-# FIXME: SHOW INSTANCES is not deterministic unless START INSTANCE is
-# synchronous. Even waiting for mysqld to start by looking at its pid file is
-# not enough, because IM may not detect that mysqld has started.
+# FIXME: Result of SHOW INSTANCES here is not deterministic unless START
+# INSTANCE is synchronous. Even waiting for mysqld to start by looking at
+# its pid file is not enough, because it is unknown when IM detects that
+# mysqld has started.
 # SHOW INSTANCES;
 
 ###########################################################################

--- 1.2/mysql-test/t/im_options_set.imtest	2006-07-20 13:24:17 +04:00
+++ 1.3/mysql-test/t/im_options_set.imtest	2006-07-20 13:24:17 +04:00
@@ -39,32 +39,7 @@
 ###########################################################################
 
 --source include/im_check_os.inc
-
-###########################################################################
-#
-# 0. Check starting conditions.
-#
-###########################################################################
-
-# - check the configuration file;
-
---exec grep server_id $MYSQLTEST_VARDIR/im.cnf ;
-
-# - check the running instances.
-
---connect (mysql1_con,localhost,root,,mysql,$IM_MYSQLD1_PORT,$IM_MYSQLD1_SOCK)
-
---connection mysql1_con
-
-SHOW VARIABLES LIKE 'server_id';
-
---connection default
-
-# - check the internal cache.
-#   TODO: we should check only server_id option here.
-
-# SHOW INSTANCE OPTIONS mysqld1;
-# SHOW INSTANCE OPTIONS mysqld2;
+--source include/im_check_env.inc
 
 ###########################################################################
 #

--- 1.2/mysql-test/t/im_options_unset.imtest	2006-07-20 13:24:17 +04:00
+++ 1.3/mysql-test/t/im_options_unset.imtest	2006-07-20 13:24:17 +04:00
@@ -46,32 +46,7 @@
 ###########################################################################
 
 --source include/im_check_os.inc
-
-###########################################################################
-#
-# 0. Check starting conditions.
-#
-###########################################################################
-
-# - check the configuration file;
-
---exec grep server_id $MYSQLTEST_VARDIR/im.cnf ;
-
-# - check the running instances.
-
---connect (mysql1_con,localhost,root,,mysql,$IM_MYSQLD1_PORT,$IM_MYSQLD1_SOCK)
-
---connection mysql1_con
-
-SHOW VARIABLES LIKE 'server_id';
-
---connection default
-
-# - check the internal cache.
-#   TODO: we should check only server_id option here.
-
-# SHOW INSTANCE OPTIONS mysqld1;
-# SHOW INSTANCE OPTIONS mysqld2;
+--source include/im_check_env.inc
 
 ###########################################################################
 #

--- 1.2/mysql-test/t/im_utils.imtest	2006-07-20 13:24:17 +04:00
+++ 1.3/mysql-test/t/im_utils.imtest	2006-07-20 13:24:17 +04:00
@@ -7,36 +7,17 @@
 ###########################################################################
 
 --source include/im_check_os.inc
+--source include/im_check_env.inc
 
 ###########################################################################
 
 #
-# Check starting conditions. This test case assumes that:
-#  - two mysqld-instances are registered;
-#  - the first instance is online;
-#  - the second instance is offline;
+# Check 'SHOW INSTANCE OPTIONS' command.
 #
-
-# Wait for mysqld1 (guarded instance) to start.
-
---exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD1_PATH_PID 30 started
-
-# Let IM detect that mysqld1 is online. This delay should be longer than
-# monitoring interval.
-
---sleep 3
-
-# Check that start conditions are as expected.
-
-SHOW INSTANCES;
-
-#
-# Check 'SHOW INSTANCE OPTIONS' command:
-#  - check that options of both offline and online instances are accessible;
-#  - since configuration of an mysqld-instance contains directories, we should
-#    completely ignore the second column (values) in order to make the test
-#    case produce the same results on different installations;
-#    TODO: ignore values of only directory-specific options.
+# Since configuration of an mysqld-instance contains directories, we should
+# completely ignore the second column (values) in order to make the test
+# case produce the same results on different installations;
+# TODO: ignore values of only directory-specific options.
 #
 
 --replace_column 2 VALUE

--- 1.103/mysql-test/mysql-test-run.pl	2006-07-20 13:24:17 +04:00
+++ 1.104/mysql-test/mysql-test-run.pl	2006-07-20 13:24:17 +04:00
@@ -2898,12 +2898,16 @@ sub im_stop($) {
 
   while (1)
   {
+    # Check that IM-main died.
+
     if (kill (0, $instance_manager->{'pid'}))
     {
       mtr_debug("IM-main is still alive.");
       last;
     }
 
+    # Check that IM-angel died.
+
     if (defined $instance_manager->{'angel_pid'} &&
         kill (0, $instance_manager->{'angel_pid'}))
     {
@@ -2911,20 +2915,38 @@ sub im_stop($) {
       last;
     }
 
+    # Check that all guarded mysqld-instances died.
+
+    my $guarded_mysqlds_dead= 1;
+
     foreach my $pid (@mysqld_pids)
     {
       if (kill (0, $pid))
       {
         mtr_debug("Guarded mysqld ($pid) is still alive.");
+        $guarded_mysqlds_dead= 0;
         last;
       }
     }
 
+    last unless $guarded_mysqlds_dead;
+
+    # Ok, all necessary processes are dead.
+
     $clean_shutdown= 1;
     last;
   }
 
   # Kill leftovers (the order is important).
+
+  if ($clean_shutdown)
+  {
+    mtr_debug("IM-shutdown was clean -- all processed died.");
+  }
+  else
+  {
+    mtr_debug("IM failed to shutdown gracefully. We have to clean the mess...");
+  }
 
   unless ($clean_shutdown)
   {
Thread
bk commit into 5.0 tree (anozdrin:1.2237) BUG#20716Alexander Nozdrin20 Jul