mariadb/mysql-test/suite
Jon Olav Hauglid 3d6a89e792 Bug #45225 Locking: hang if drop table with no timeout
This patch introduces timeouts for metadata locks. 

The timeout is specified in seconds using the new dynamic system 
variable  "lock_wait_timeout" which has both GLOBAL and SESSION
scopes. Allowed values range from 1 to 31536000 seconds (= 1 year). 
The default value is 1 year.

The new server parameter "lock-wait-timeout" can be used to set
the default value parameter upon server startup.

"lock_wait_timeout" applies to all statements that use metadata locks.
These include DML and DDL operations on tables, views, stored procedures
and stored functions. They also include LOCK TABLES, FLUSH TABLES WITH
READ LOCK and HANDLER statements.

The patch also changes thr_lock.c code (table data locks used by MyISAM
and other simplistic engines) to use the same system variable.
InnoDB row locks are unaffected.

One exception to the handling of the "lock_wait_timeout" variable
is delayed inserts. All delayed inserts are executed with a timeout
of 1 year regardless of the setting for the global variable. As the
connection issuing the delayed insert gets no notification of 
delayed insert timeouts, we want to avoid unnecessary timeouts.

It's important to note that the timeout value is used for each lock
acquired and that one statement can take more than one lock.
A statement can therefore block for longer than the lock_wait_timeout 
value before reporting a timeout error. When lock timeout occurs, 
ER_LOCK_WAIT_TIMEOUT is reported.

Test case added to lock_multi.test.


include/my_pthread.h:
  Added macros for comparing two timespec structs.
include/thr_lock.h:
  Introduced timeouts for thr_lock.c locks.
mysql-test/r/mysqld--help-notwin.result:
  Updated result file with the new server variable.
mysql-test/r/mysqld--help-win.result:
  Updated result file with the new server variable.
mysql-test/suite/sys_vars/r/lock_wait_timeout_basic.result:
  Added basic test for the new server variable.
mysql-test/suite/sys_vars/t/lock_wait_timeout_basic.test:
  Added basic test for the new server variable.
mysys/thr_lock.c:
  Introduced timeouts for thr_lock.c locks.
sql/mdl.cc:
  Introduced timeouts for metadata locks.
sql/mdl.h:
  Introduced timeouts for metadata locks.
sql/sql_base.cc:
  Introduced timeouts in tdc_wait_for_old_versions().
sql/sql_class.h:
  Added new server variable lock_wait_timeout.
sql/sys_vars.cc:
  Added new server variable lock_wait_timeout.
2010-02-11 11:23:39 +01:00
..
binlog Merge next-mr -> next-4284. 2010-02-06 13:28:06 +03:00
bugs
federated merging 5.1 main -> rpl+2. Some manual work required mostly due to bug46640 2009-11-06 18:35:04 +02:00
funcs_1 Update result file. 2010-02-10 19:31:34 +03:00
funcs_2
ibmdb2i Bug#49329 example (and other) engines use wrong collation for open tables hash 2009-12-11 12:31:16 +05:30
innodb WL#4738 streamline/simplify @@variable creation process 2009-12-22 10:35:56 +01:00
jp WL#2360 Performance schema 2010-01-11 18:47:27 -07:00
large_tests This is the downport of 2009-09-11 22:26:35 +02:00
manual
ndb Auto-merge from mysql-next-mr. 2010-02-09 13:40:08 +03:00
ndb_team
parts Merge next-mr -> next-4284. 2010-02-05 01:08:08 +03:00
perfschema Merge backport of WL#3771 with mysql-next-mr. 2010-01-19 20:42:25 +04:00
perfschema_stress WL#2360 Performance schema 2010-01-11 18:47:27 -07:00
rpl 1. Disable ndb_condition_pushdown.test due to Bug 49746. 2010-02-09 13:16:01 +03:00
rpl_ndb 1. Disable ndb_condition_pushdown.test due to Bug 49746. 2010-02-09 13:16:01 +03:00
stress
sys_vars Bug #45225 Locking: hang if drop table with no timeout 2010-02-11 11:23:39 +01:00