List:Commits« Previous MessageNext Message »
From:cbell Date:March 5 2008 10:08pm
Subject:bk commit into 6.0 tree (cbell:1.2575) BUG#33414
View as plain text  
Below is the list of changes that have just been committed into a local
6.0 repository of cbell.  When cbell 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, 2008-03-05 17:07:24-05:00, cbell@mysql_cab_desk. +9 -0
  BUG#33414 : Backup: DDL hangs indefinitely if ongoing backup
  
  Added ability to set a timeout for blocked DDL operations. The
  timeout is the number of seconds a blocked DDL operation will 
  wait before aborting with an error message. The variable can be
  set at the session- or global-level.
  
  Note: timeout must be set before DDL is executed.

  include/mysql_com.h@stripped, 2008-03-05 17:05:59-05:00, cbell@mysql_cab_desk. +2 -0
    BUG#33414 : Backup: DDL hangs indefinitely if ongoing backup
    
    Added default timeout value = 0.

  mysql-test/r/backup_ddl_blocker.result@stripped, 2008-03-05 17:06:00-05:00, cbell@mysql_cab_desk. +126 -0
    BUG#33414 : Backup: DDL hangs indefinitely if ongoing backup
    
    New result file.

  mysql-test/t/backup_ddl_blocker.test@stripped, 2008-03-05 17:06:00-05:00, cbell@mysql_cab_desk. +227 -0
    BUG#33414 : Backup: DDL hangs indefinitely if ongoing backup
    
    Added tests to test the timeout.
    
    Note: This test is currently disabled waiting for improvements 
    to debug insertion techniques.

  sql/ddl_blocker.cc@stripped, 2008-03-05 17:06:01-05:00, cbell@mysql_cab_desk. +40 -8
    BUG#33414 : Backup: DDL hangs indefinitely if ongoing backup
    
    Added ability to timeout based on the variable ddl_wait_timeout.

  sql/mysqld.cc@stripped, 2008-03-05 17:06:02-05:00, cbell@mysql_cab_desk. +10 -2
    BUG#33414 : Backup: DDL hangs indefinitely if ongoing backup
    
    Added the ddl_wait_timeout as a startup option to mysqld.

  sql/set_var.cc@stripped, 2008-03-05 17:06:03-05:00, cbell@mysql_cab_desk. +2 -0
    BUG#33414 : Backup: DDL hangs indefinitely if ongoing backup
    
    Added system variable ddl_wait_timeout.

  sql/share/errmsg.txt@stripped, 2008-03-05 17:07:11-05:00, cbell@mysql_cab_desk. +4 -0
    BUG#33414 : Backup: DDL hangs indefinitely if ongoing backup
    
    Added new error message for DDL timeout. 

  sql/sql_class.h@stripped, 2008-03-05 17:06:04-05:00, cbell@mysql_cab_desk. +2 -0
    BUG#33414 : Backup: DDL hangs indefinitely if ongoing backup
    
    Added ddl_wait_timeout variable to session variables and a 
    variable in the THD to store the calculated timeout for
    the ddl blocker.

  sql/sql_parse.cc@stripped, 2008-03-05 17:06:04-05:00, cbell@mysql_cab_desk. +27 -12
    BUG#33414 : Backup: DDL hangs indefinitely if ongoing backup
    
    Modified code to check for a failed return which indicates the
    ddl blocker has timed out.

diff -Nrup a/include/mysql_com.h b/include/mysql_com.h
--- a/include/mysql_com.h	2008-02-12 05:26:07 -05:00
+++ b/include/mysql_com.h	2008-03-05 17:05:59 -05:00
@@ -188,6 +188,8 @@ enum enum_server_command
 #define NET_WRITE_TIMEOUT	60		/* Timeout on write */
 #define NET_WAIT_TIMEOUT	8*60*60		/* Wait for new query */
 
+#define DDL_WAIT_TIMEOUT	0		  /* Wait for ddl blocker */
+
 #define ONLY_KILL_QUERY         1
 
 struct st_vio;					/* Only C */
diff -Nrup a/mysql-test/r/backup_ddl_blocker.result b/mysql-test/r/backup_ddl_blocker.result
--- a/mysql-test/r/backup_ddl_blocker.result	2007-12-20 15:32:15 -05:00
+++ b/mysql-test/r/backup_ddl_blocker.result	2008-03-05 17:06:00 -05:00
@@ -1459,4 +1459,130 @@ WHERE TABLE_NAME = 't3' AND TABLE_SCHEMA
 count(*)
 2
 DROP TABLE test.t2;
+
+Starting Test 8
+
+DROP TABLE IF EXISTS bup_ddl_blocker.t1, bup_ddl_blocker.t2,
+bup_ddl_blocker.t3, bup_ddl_blocker.t4;
+con1: Creating tables
+CREATE TABLE bup_ddl_blocker.t1 (col_a CHAR(40)) ENGINE=INNODB;
+con1: Loading data
+INSERT INTO bup_ddl_blocker.t1 VALUES ("01 Some data to test");
+INSERT INTO bup_ddl_blocker.t1 VALUES ("02 Some data to test");
+INSERT INTO bup_ddl_blocker.t1 VALUES ("03 Some data to test");
+Part A
+con5: Getting lock on DDL in progress.
+SELECT get_lock("DDL_blocked", 0);
+get_lock("DDL_blocked", 0)
+1
+con2: Get a backup going and stop after the DDL blocker is fired.
+BACKUP DATABASE bup_ddl_blocker TO "bup_ddl_blocker.bak";
+con6: Checking locks
+SELECT state, info FROM INFORMATION_SCHEMA.PROCESSLIST
+WHERE info LIKE "BACKUP DATABASE%";
+state	info
+debug_sync_point: DDL_blocked	BACKUP DATABASE bup_ddl_blocker TO "bup_ddl_blocker.bak"
+Set ddl timeout to 1 second
+SET ddl_wait_timeout = 1;
+SHOW VARIABLES LIKE 'ddl%';
+Variable_name	Value
+ddl_wait_timeout	1
+con2: Try a ddl operation and watch it expire
+CREATE TABLE bup_ddl_blocker.t2 (col_a CHAR(40)) ENGINE=MEMORY;
+ERROR HY000: The DDL operation has timed out for query CREATE TABLE bup_ddl_blocker.t2 (col_a CHAR(40)) ENGINE=MEMORY.
+release the lock.
+con5: Releasing lock
+SELECT release_lock("DDL_blocked");
+release_lock("DDL_blocked")
+1
+backup_id
+#
+Part B
+con5: Getting lock on DDL in progress.
+SELECT get_lock("DDL_blocked", 0);
+get_lock("DDL_blocked", 0)
+1
+con2: Get a backup going and stop after the DDL blocker is fired.
+BACKUP DATABASE bup_ddl_blocker TO "bup_ddl_blocker.bak";
+con6: Checking locks
+SELECT state, info FROM INFORMATION_SCHEMA.PROCESSLIST
+WHERE info LIKE "BACKUP DATABASE%";
+state	info
+debug_sync_point: DDL_blocked	BACKUP DATABASE bup_ddl_blocker TO "bup_ddl_blocker.bak"
+Set ddl timeout to 1,000,000 seconds
+SET ddl_wait_timeout = 0;
+SHOW VARIABLES LIKE 'ddl%';
+Variable_name	Value
+ddl_wait_timeout	0
+SET GLOBAL ddl_wait_timeout = 1000000;
+SHOW GLOBAL VARIABLES LIKE 'ddl%';
+Variable_name	Value
+ddl_wait_timeout	1000000
+con2: Try a ddl operation and it should not expire
+CREATE TABLE bup_ddl_blocker.t2 (col_a CHAR(40)) ENGINE=MEMORY;
+con6: Checking locks
+SELECT state, info FROM INFORMATION_SCHEMA.PROCESSLIST
+WHERE info LIKE "CREATE TABLE bup_ddl_blocker.t2%";
+state	info
+DDL blocker: DDL is blocked	CREATE TABLE bup_ddl_blocker.t2 (col_a CHAR(40)) ENGINE=MEMORY
+release the lock.
+con5: Releasing lock
+SELECT release_lock("DDL_blocked");
+release_lock("DDL_blocked")
+1
+backup_id
+#
+Part C
+con5: Getting lock on DDL in progress.
+SELECT get_lock("DDL_blocked", 0);
+get_lock("DDL_blocked", 0)
+1
+con2: Get a backup going and stop after the DDL blocker is fired.
+BACKUP DATABASE bup_ddl_blocker TO "bup_ddl_blocker.bak";
+con6: Checking locks
+SELECT state, info FROM INFORMATION_SCHEMA.PROCESSLIST
+WHERE info LIKE "BACKUP DATABASE%";
+state	info
+debug_sync_point: DDL_blocked	BACKUP DATABASE bup_ddl_blocker TO "bup_ddl_blocker.bak"
+Set ddl timeout to 1 seconds
+SET ddl_wait_timeout = 1;
+SHOW VARIABLES LIKE 'ddl%';
+Variable_name	Value
+ddl_wait_timeout	1
+SET GLOBAL ddl_wait_timeout = 0;
+SHOW GLOBAL VARIABLES LIKE 'ddl%';
+Variable_name	Value
+ddl_wait_timeout	0
+con2: Try a ddl operation and it should expire
+CREATE TABLE bup_ddl_blocker.t3 (col_a CHAR(40)) ENGINE=MEMORY;
+ERROR HY000: The DDL operation has timed out for query CREATE TABLE bup_ddl_blocker.t3 (col_a CHAR(40)) ENGINE=MEMORY.
+Set ddl timeout to 0 seconds
+SET ddl_wait_timeout = 0;
+SHOW VARIABLES LIKE 'ddl%';
+Variable_name	Value
+ddl_wait_timeout	0
+SET GLOBAL ddl_wait_timeout = 0;
+SHOW GLOBAL VARIABLES LIKE 'ddl%';
+Variable_name	Value
+ddl_wait_timeout	0
+con3: Try a ddl operation and it should not expire
+CREATE TABLE bup_ddl_blocker.t3 (col_a CHAR(40)) ENGINE=MEMORY;
+con6: Checking locks
+SELECT state, info FROM INFORMATION_SCHEMA.PROCESSLIST
+WHERE info LIKE "CREATE TABLE bup_ddl_blocker.t3%";
+state	info
+DDL blocker: DDL is blocked	CREATE TABLE bup_ddl_blocker.t3 (col_a CHAR(40)) ENGINE=MEMORY
+release the lock.
+con5: Releasing lock
+SELECT release_lock("DDL_blocked");
+release_lock("DDL_blocked")
+1
+backup_id
+#
+USE bup_ddl_blocker;
+SHOW FULL TABLES;
+Tables_in_bup_ddl_blocker	Table_type
+t1	BASE TABLE
+t2	BASE TABLE
+t3	BASE TABLE
 DROP DATABASE bup_ddl_blocker;
diff -Nrup a/mysql-test/t/backup_ddl_blocker.test b/mysql-test/t/backup_ddl_blocker.test
--- a/mysql-test/t/backup_ddl_blocker.test	2008-02-14 15:57:14 -05:00
+++ b/mysql-test/t/backup_ddl_blocker.test	2008-03-05 17:06:00 -05:00
@@ -2360,8 +2360,233 @@ SELECT count(*) FROM INFORMATION_SCHEMA.
 WHERE TABLE_NAME = 't3' AND TABLE_SCHEMA = 'bup_ddl_blocker';
 
 DROP TABLE test.t2;
+
+
+
+
+##############################################################
+--echo 
+--echo Starting Test 8
+--echo 
+##############################################################
+
+--disable_warnings
+DROP TABLE IF EXISTS bup_ddl_blocker.t1, bup_ddl_blocker.t2,
+                     bup_ddl_blocker.t3, bup_ddl_blocker.t4;
+--enable_warnings
+
+# Create a table and load it with data.
+--echo con1: Creating tables
+CREATE TABLE bup_ddl_blocker.t1 (col_a CHAR(40)) ENGINE=INNODB;
+
+--echo con1: Loading data
+INSERT INTO bup_ddl_blocker.t1 VALUES ("01 Some data to test");
+INSERT INTO bup_ddl_blocker.t1 VALUES ("02 Some data to test");
+INSERT INTO bup_ddl_blocker.t1 VALUES ("03 Some data to test");
+
+#
+# Part A - test timeout for one session
+#
+--echo Part A
+
+connection con5;
+
+# Set the breakpoint for DDL in progress.
+--echo con5: Getting lock on DDL in progress.
+SELECT get_lock("DDL_blocked", 0);
+
+--error 0,1
+--remove_file $MYSQLTEST_VARDIR/master-data/bup_ddl_blocker.bak
+
+connection con1;
+
+--echo con2: Get a backup going and stop after the DDL blocker is fired.
+send BACKUP DATABASE bup_ddl_blocker TO "bup_ddl_blocker.bak";
+
+connection con6;
+
+--echo con6: Checking locks
+let $wait_condition = SELECT state = "debug_sync_point: DDL_blocked"
+                      FROM INFORMATION_SCHEMA.PROCESSLIST
+                      WHERE info LIKE "BACKUP DATABASE%";
+--source include/wait_condition.inc
+
+SELECT state, info FROM INFORMATION_SCHEMA.PROCESSLIST
+WHERE info LIKE "BACKUP DATABASE%";
+
+connection con2;
+
+--echo Set ddl timeout to 1 second
+SET ddl_wait_timeout = 1; 
+SHOW VARIABLES LIKE 'ddl%';
+
+--echo con2: Try a ddl operation and watch it expire
+--error ER_DDL_TIMEOUT
+CREATE TABLE bup_ddl_blocker.t2 (col_a CHAR(40)) ENGINE=MEMORY;
+
+connection con5;
+--echo release the lock.
+--echo con5: Releasing lock
+SELECT release_lock("DDL_blocked");
+
+# Reconnect to con1 and let backup finish.
+
+connection con1;
+--replace_column 1 #
+reap;
+
+#
+# Part B - test timeout for one session using global
+#
+--echo Part B
+
+connection con5;
+
+# Set the breakpoint for DDL in progress.
+--echo con5: Getting lock on DDL in progress.
+SELECT get_lock("DDL_blocked", 0);
+
+--error 0,1
+--remove_file $MYSQLTEST_VARDIR/master-data/bup_ddl_blocker.bak
+
+connection con1;
+
+--echo con2: Get a backup going and stop after the DDL blocker is fired.
+send BACKUP DATABASE bup_ddl_blocker TO "bup_ddl_blocker.bak";
+
+connection con6;
+
+--echo con6: Checking locks
+let $wait_condition = SELECT state = "debug_sync_point: DDL_blocked"
+                      FROM INFORMATION_SCHEMA.PROCESSLIST
+                      WHERE info LIKE "BACKUP DATABASE%";
+--source include/wait_condition.inc
+
+SELECT state, info FROM INFORMATION_SCHEMA.PROCESSLIST
+WHERE info LIKE "BACKUP DATABASE%";
+
+connection con2;
+
+--echo Set ddl timeout to 1,000,000 seconds
+SET ddl_wait_timeout = 0; 
+SHOW VARIABLES LIKE 'ddl%';
+SET GLOBAL ddl_wait_timeout = 1000000; 
+SHOW GLOBAL VARIABLES LIKE 'ddl%';
+
+--echo con2: Try a ddl operation and it should not expire
+send CREATE TABLE bup_ddl_blocker.t2 (col_a CHAR(40)) ENGINE=MEMORY;
+
+connection con6;
+
+--echo con6: Checking locks
+let $wait_condition = SELECT state = "DDL blocker: DDL is blocked"
+                      FROM INFORMATION_SCHEMA.PROCESSLIST
+                      WHERE info LIKE "CREATE TABLE bup_ddl_blocker.t2%";
+--source include/wait_condition.inc
+
+SELECT state, info FROM INFORMATION_SCHEMA.PROCESSLIST
+WHERE info LIKE "CREATE TABLE bup_ddl_blocker.t2%";
+
+connection con5;
+--echo release the lock.
+--echo con5: Releasing lock
+SELECT release_lock("DDL_blocked");
+
+# Reconnect to con1 and let backup finish.
+
+connection con1;
+--replace_column 1 #
+reap;
+
+connection con2;
+reap;
+
+#
+# Part C - test timeout for a session with a local timeout, 
+#          and a session with no timeout
+#
+--echo Part C
+
+connection con5;
+
+# Set the breakpoint for DDL in progress.
+--echo con5: Getting lock on DDL in progress.
+SELECT get_lock("DDL_blocked", 0);
+
+--error 0,1
+--remove_file $MYSQLTEST_VARDIR/master-data/bup_ddl_blocker.bak
+
+connection con1;
+
+--echo con2: Get a backup going and stop after the DDL blocker is fired.
+send BACKUP DATABASE bup_ddl_blocker TO "bup_ddl_blocker.bak";
+
+connection con6;
+
+--echo con6: Checking locks
+let $wait_condition = SELECT state = "debug_sync_point: DDL_blocked"
+                      FROM INFORMATION_SCHEMA.PROCESSLIST
+                      WHERE info LIKE "BACKUP DATABASE%";
+--source include/wait_condition.inc
+
+SELECT state, info FROM INFORMATION_SCHEMA.PROCESSLIST
+WHERE info LIKE "BACKUP DATABASE%";
+
+connection con2;
+
+--echo Set ddl timeout to 1 seconds
+SET ddl_wait_timeout = 1; 
+SHOW VARIABLES LIKE 'ddl%';
+SET GLOBAL ddl_wait_timeout = 0; 
+SHOW GLOBAL VARIABLES LIKE 'ddl%';
+
+--echo con2: Try a ddl operation and it should expire
+--error ER_DDL_TIMEOUT
+CREATE TABLE bup_ddl_blocker.t3 (col_a CHAR(40)) ENGINE=MEMORY;
+
+connection con3;
+
+--echo Set ddl timeout to 0 seconds
+SET ddl_wait_timeout = 0; 
+SHOW VARIABLES LIKE 'ddl%';
+SET GLOBAL ddl_wait_timeout = 0; 
+SHOW GLOBAL VARIABLES LIKE 'ddl%';
+
+--echo con3: Try a ddl operation and it should not expire
+send CREATE TABLE bup_ddl_blocker.t3 (col_a CHAR(40)) ENGINE=MEMORY;
+
+connection con6;
+
+--echo con6: Checking locks
+let $wait_condition = SELECT state = "DDL blocker: DDL is blocked"
+                      FROM INFORMATION_SCHEMA.PROCESSLIST
+                      WHERE info LIKE "CREATE TABLE bup_ddl_blocker.t3%";
+--source include/wait_condition.inc
+
+SELECT state, info FROM INFORMATION_SCHEMA.PROCESSLIST
+WHERE info LIKE "CREATE TABLE bup_ddl_blocker.t3%";
+
+connection con5;
+
+--echo release the lock.
+--echo con5: Releasing lock
+SELECT release_lock("DDL_blocked");
+
+# Reconnect to con1 and let backup finish.
+
+connection con1;
+--replace_column 1 #
+reap;
+
+connection con3;
+reap;
+
+USE bup_ddl_blocker;
+SHOW FULL TABLES;
+
 DROP DATABASE bup_ddl_blocker;
 
+
 #
 # Normally, when tests are run the test/ directory corresponding to the test database
 # is empty. In particular, it doesn't contain the db.opt file storing database settings.
@@ -2373,7 +2598,9 @@ DROP DATABASE bup_ddl_blocker;
 #
 --error 0,1
 --remove_file $MYSQLTEST_VARDIR/master-data/test/db.opt
+--error 0,1
 --remove_file $MYSQLTEST_VARDIR/master-data/bup_ddl_blocker_orig.bak
+--error 0,1
 --remove_file $MYSQLTEST_VARDIR/master-data/bup_ddl_blocker.bak
 
 
diff -Nrup a/sql/ddl_blocker.cc b/sql/ddl_blocker.cc
--- a/sql/ddl_blocker.cc	2007-12-12 15:13:23 -05:00
+++ b/sql/ddl_blocker.cc	2008-03-05 17:06:01 -05:00
@@ -104,26 +104,58 @@ void DDL_blocker_class::end_DDL()
     Check to see if we are blocked from continuing. If so,
     wait until the blocked process signals the condition.
 
-    @param thd The THD object from the caller.
-    @returns TRUE
+    @param[in] thd        The THD object from the caller.
+
+    @returns TRUE if not blocked
+    @returns FALSE if timeout occurs
+
+    @note The method will attempt to use the local instance of the 
+          timeout value first. If it is 0 (turned off), it will then
+          attempt to use the global instance of the timeout. If that
+          is not turned off, it will use the global value.
   */
 my_bool DDL_blocker_class::check_DDL_blocker(THD *thd)
 {
+  int ret = 0;
+  bool timeout= FALSE;
   DBUG_ENTER("check_DDL_blocker()");
   BACKUP_BREAKPOINT("DDL_not_blocked");
 
+  if (thd->variables.ddl_wait_timeout > 0)
+  {
+    set_timespec(thd->ddl_timeout, thd->variables.ddl_wait_timeout);
+    timeout= TRUE;
+  }
+  else if (global_system_variables.ddl_wait_timeout > 0)
+  {
+    set_timespec(thd->ddl_timeout, global_system_variables.ddl_wait_timeout);
+    timeout= TRUE;
+  }
+
   /*
     Check the ddl blocker condition. Rest until ddl blocker is released.
   */
   pthread_mutex_lock(&THR_LOCK_DDL_is_blocked);
   thd->enter_cond(&COND_DDL_blocker, &THR_LOCK_DDL_is_blocked,
                   "DDL blocker: DDL is blocked");
-  while (DDL_blocked && !thd->DDL_exception)
-    pthread_cond_wait(&COND_DDL_blocker, &THR_LOCK_DDL_is_blocked);
-  start_DDL();
-  thd->exit_cond("DDL blocker: Ok to run DDL");
-  BACKUP_BREAKPOINT("DDL_in_progress");
-  DBUG_RETURN(TRUE);
+  while (DDL_blocked && !thd->DDL_exception && (ret == 0))
+  {
+    if (!timeout)
+      pthread_cond_wait(&COND_DDL_blocker, &THR_LOCK_DDL_is_blocked);
+    else
+      ret= pthread_cond_timedwait(&COND_DDL_blocker, &THR_LOCK_DDL_is_blocked,
+                                  &thd->ddl_timeout);
+  }
+  if (ret == 0)
+  {
+    start_DDL();
+    thd->exit_cond("DDL blocker: Ok to run DDL");
+    BACKUP_BREAKPOINT("DDL_in_progress");
+    DBUG_RETURN(TRUE);
+  }
+  thd->exit_cond("DDL blocker: DDL timeout period has expired");
+  my_error(ER_DDL_TIMEOUT, MYF(0), thd->query);
+  DBUG_RETURN(FALSE);
 }
 
 /**
diff -Nrup a/sql/mysqld.cc b/sql/mysqld.cc
--- a/sql/mysqld.cc	2008-02-25 14:48:27 -05:00
+++ b/sql/mysqld.cc	2008-03-05 17:06:02 -05:00
@@ -3428,6 +3428,8 @@ static int init_common_variables(const c
   global_system_variables.optimizer_use_mrr= 1;
   global_system_variables.optimizer_switch= 0;
 
+  global_system_variables.ddl_wait_timeout= 0;
+
   if (!(character_set_filesystem= 
         get_charset_by_csname(character_set_filesystem_name,
                               MY_CS_PRIMARY, MYF(MY_WME))))
@@ -5587,7 +5589,8 @@ enum options_mysqld
 #if HAVE_POOL_OF_THREADS == 1
   OPT_POOL_OF_THREADS,
 #endif
-  OPT_SLAVE_EXEC_MODE
+  OPT_SLAVE_EXEC_MODE,
+  OPT_DDL_WAIT_TIMEOUT
 };
 
 
@@ -6392,7 +6395,12 @@ log and this option does nothing anymore
     (uchar**) &opt_date_time_formats[MYSQL_TIMESTAMP_DATETIME],
     (uchar**) &opt_date_time_formats[MYSQL_TIMESTAMP_DATETIME],
     0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
-  { "default_week_format", OPT_DEFAULT_WEEK_FORMAT,
+  {"ddl_wait_timeout", OPT_DDL_WAIT_TIMEOUT,
+   "The number of seconds a DDL can be blocked before cancelled.",
+   (uchar**) &global_system_variables.ddl_wait_timeout,
+   (uchar**) &max_system_variables.ddl_wait_timeout, 0, GET_ULONG,
+   REQUIRED_ARG, DDL_WAIT_TIMEOUT, 0, 1024 * 1024 * 1024, 0, 1, 0},
+   { "default_week_format", OPT_DEFAULT_WEEK_FORMAT,
     "The default week format used by WEEK() functions.",
     (uchar**) &global_system_variables.default_week_format,
     (uchar**) &max_system_variables.default_week_format,
diff -Nrup a/sql/set_var.cc b/sql/set_var.cc
--- a/sql/set_var.cc	2008-02-22 10:03:43 -05:00
+++ b/sql/set_var.cc	2008-03-05 17:06:03 -05:00
@@ -213,6 +213,8 @@ static sys_var_long_ptr	sys_concurrent_i
 static sys_var_long_ptr	sys_connect_timeout(&vars, "connect_timeout",
 					    &connect_timeout);
 static sys_var_const_str       sys_datadir(&vars, "datadir", mysql_real_data_home);
+static sys_var_thd_ulong  sys_ddl_wait_timeout(&vars, "ddl_wait_timeout",
+                                               &SV::ddl_wait_timeout);
 #ifndef DBUG_OFF
 static sys_var_thd_dbug        sys_dbug(&vars, "debug");
 #endif
diff -Nrup a/sql/share/errmsg.txt b/sql/share/errmsg.txt
--- a/sql/share/errmsg.txt	2008-02-15 11:09:47 -05:00
+++ b/sql/share/errmsg.txt	2008-03-05 17:07:11 -05:00
@@ -6246,3 +6246,7 @@ ER_SLAVE_HEARTBEAT_FAILURE
   eng "Unexpected master's heartbeat data: %s"
 ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE
   eng "The requested value for the heartbeat period %s %s"
+
+ER_DDL_TIMEOUT
+  eng "The DDL operation has timed out for query %-.64s."
+
diff -Nrup a/sql/sql_class.h b/sql/sql_class.h
--- a/sql/sql_class.h	2008-02-08 15:22:30 -05:00
+++ b/sql/sql_class.h	2008-03-05 17:06:04 -05:00
@@ -278,6 +278,7 @@ struct system_variables
   ha_rows max_join_size;
   ulong auto_increment_increment, auto_increment_offset;
   ulong bulk_insert_buff_size;
+  ulong ddl_wait_timeout;
   ulong join_buff_size;
   ulong max_allowed_packet;
   ulong max_error_count;
@@ -1689,6 +1690,7 @@ public:
           when the DDL blocker is engaged.
   */
   my_bool DDL_exception; // Allow some DDL if there is an exception
+  struct timespec ddl_timeout; // Timeout for DDL blocker
 
   sp_rcontext *spcont;		// SP runtime context
   sp_cache   *sp_proc_cache;
diff -Nrup a/sql/sql_parse.cc b/sql/sql_parse.cc
--- a/sql/sql_parse.cc	2008-02-25 14:48:33 -05:00
+++ b/sql/sql_parse.cc	2008-03-05 17:06:04 -05:00
@@ -2290,7 +2290,11 @@ mysql_execute_command(THD *thd)
       TABLE in the same way. That way we avoid that a new table is
       created during a gobal read lock.
     */
-    DDL_blocker->check_DDL_blocker(thd);
+    if (!DDL_blocker->check_DDL_blocker(thd))
+    {
+      res= 1;
+      goto end_with_restore_list;
+    }
     if (!thd->locked_tables &&
         !(need_start_waiting= !wait_if_global_read_lock(thd, 0, 1)))
     {
@@ -2431,7 +2435,8 @@ end_with_restore_list:
     table without having to do a full rebuild.
   */
   {
-    DDL_blocker->check_DDL_blocker(thd);
+    if (!DDL_blocker->check_DDL_blocker(thd))
+      goto error;
     /* Prepare stack copies to be re-execution safe */
     HA_CREATE_INFO create_info;
     Alter_info alter_info(lex->alter_info, thd->mem_root);
@@ -2501,7 +2506,8 @@ end_with_restore_list:
   case SQLCOM_ALTER_TABLE:
     DBUG_ASSERT(first_table == all_tables && first_table != 0);
     {
-      DDL_blocker->check_DDL_blocker(thd);
+      if (!DDL_blocker->check_DDL_blocker(thd))
+        goto error;
       ulong priv=0;
       ulong priv_needed= ALTER_ACL;
       /*
@@ -2613,7 +2619,8 @@ end_with_restore_list:
         goto error;
     }
 
-      DDL_blocker->check_DDL_blocker(thd);
+      if (!DDL_blocker->check_DDL_blocker(thd))
+        goto error;
     if (end_active_trans(thd) || mysql_rename_tables(thd, first_table, 0))
       {
         DDL_blocker->end_DDL();
@@ -2671,7 +2678,8 @@ end_with_restore_list:
                            UINT_MAX, FALSE))
       goto error; /* purecov: inspected */
     thd->enable_slow_log= opt_log_slow_admin_statements;
-    DDL_blocker->check_DDL_blocker(thd);
+    if (!DDL_blocker->check_DDL_blocker(thd))
+      goto error;
     res= mysql_repair_table(thd, first_table, &lex->check_opt);
     DDL_blocker->end_DDL();
     /* ! we write after unlocking the table */
@@ -2726,7 +2734,8 @@ end_with_restore_list:
                            UINT_MAX, FALSE))
       goto error; /* purecov: inspected */
     thd->enable_slow_log= opt_log_slow_admin_statements;
-    DDL_blocker->check_DDL_blocker(thd);
+    if (!DDL_blocker->check_DDL_blocker(thd))
+      goto error;
     res= (specialflag & (SPECIAL_SAFE_MODE | SPECIAL_NO_NEW_FUNC)) ?
       mysql_recreate_table(thd, first_table) :
       mysql_optimize_table(thd, first_table, &lex->check_opt);
@@ -2973,7 +2982,8 @@ end_with_restore_list:
       goto error;
     }
 
-    DDL_blocker->check_DDL_blocker(thd);
+    if (!DDL_blocker->check_DDL_blocker(thd))
+      goto error;
     res= mysql_truncate(thd, first_table, 0);
     DDL_blocker->end_DDL();
 
@@ -3078,7 +3088,8 @@ end_with_restore_list:
       /* So that DROP TEMPORARY TABLE gets to binlog at commit/rollback */
       thd->options|= OPTION_KEEP_LOG;
     }
-      DDL_blocker->check_DDL_blocker(thd);
+      if (!DDL_blocker->check_DDL_blocker(thd))
+        goto error;
     /* DDL and binlog write order protected by LOCK_open */
     res= mysql_rm_table(thd, first_table, lex->drop_if_exists,
 			lex->drop_temporary);
@@ -3314,7 +3325,8 @@ end_with_restore_list:
     if (check_access(thd,CREATE_ACL,lex->name.str, 0, 1, 0,
                      is_schema_db(lex->name.str)))
       break;
-    DDL_blocker->check_DDL_blocker(thd);
+    if (!DDL_blocker->check_DDL_blocker(thd))
+      goto error;
     res= mysql_create_db(thd,(lower_case_table_names == 2 ? alias :
                               lex->name.str), &create_info, 0);
     DDL_blocker->end_DDL();
@@ -3357,7 +3369,8 @@ end_with_restore_list:
                  ER(ER_LOCK_OR_ACTIVE_TRANSACTION), MYF(0));
       goto error;
     }
-    DDL_blocker->check_DDL_blocker(thd);
+    if (!DDL_blocker->check_DDL_blocker(thd))
+      goto error;
     res= mysql_rm_db(thd, lex->name.str, lex->drop_if_exists, 0);
     DDL_blocker->end_DDL();
     break;
@@ -3400,7 +3413,8 @@ end_with_restore_list:
       goto error;
     }
 
-    DDL_blocker->check_DDL_blocker(thd);
+    if (!DDL_blocker->check_DDL_blocker(thd))
+      goto error;
     res= mysql_upgrade_db(thd, db);
     DDL_blocker->end_DDL();
     if (!res)
@@ -3440,7 +3454,8 @@ end_with_restore_list:
                  ER(ER_LOCK_OR_ACTIVE_TRANSACTION), MYF(0));
       goto error;
     }
-    DDL_blocker->check_DDL_blocker(thd);
+    if (!DDL_blocker->check_DDL_blocker(thd))
+      goto error;
     res= mysql_alter_db(thd, db->str, &create_info);
     DDL_blocker->end_DDL();
     break;

Thread
bk commit into 6.0 tree (cbell:1.2575) BUG#33414cbell5 Mar
  • Re: bk commit into 6.0 tree (cbell:1.2575) BUG#33414Rafal Somla10 Mar
    • RE: bk commit into 6.0 tree (cbell:1.2575) BUG#33414Chuck Bell10 Mar
      • Re: bk commit into 6.0 tree (cbell:1.2575) BUG#33414Rafal Somla11 Mar
        • RE: bk commit into 6.0 tree (cbell:1.2575) BUG#33414Chuck Bell11 Mar
          • Re: bk commit into 6.0 tree (cbell:1.2575) BUG#33414Rafal Somla12 Mar
RE: bk commit into 6.0 tree (cbell:1.2575) BUG#33414Chuck Bell12 Mar