| 1 |
--source include/have_innodb.inc |
| 2 |
--source include/count_sessions.inc |
| 3 |
|
| 4 |
CREATE TABLE `t`(`id` INT, PRIMARY KEY(`id`)) ENGINE=InnoDB STATS_PERSISTENT=0; |
| 5 |
|
| 6 |
INSERT INTO t VALUES (1); |
| 7 |
|
| 8 |
SET GLOBAL innodb_monitor_disable="lock_row_lock_time"; |
| 9 |
SET GLOBAL innodb_monitor_disable="lock_row_lock_time_max"; |
| 10 |
SET GLOBAL innodb_monitor_reset_all='lock_row_lock_time'; |
| 11 |
SET GLOBAL innodb_monitor_reset_all='lock_row_lock_time_max'; |
| 12 |
SET GLOBAL innodb_monitor_enable="lock_row_lock_time"; |
| 13 |
SET GLOBAL innodb_monitor_enable="lock_row_lock_time_max"; |
| 14 |
|
| 15 |
BEGIN; |
| 16 |
SELECT * FROM t FOR UPDATE; |
| 17 |
|
| 18 |
# We can't predict (innodb/lock)_row_lock_time_avg value, because it's counted |
| 19 |
# as the whole waiting time divided by the amount of waits. The |
| 20 |
# corresponding counters in lock_sys can't be reset with any query. |
| 21 |
|
| 22 |
--disable_result_log |
| 23 |
SELECT @innodb_row_lock_time_before := variable_value |
| 24 |
FROM information_schema.global_status |
| 25 |
WHERE LOWER(variable_name) = 'innodb_row_lock_time'; |
| 26 |
--enable_result_log |
| 27 |
|
| 28 |
--connect(con1,localhost,root,,) |
| 29 |
SET innodb_lock_wait_timeout = 1; |
| 30 |
--error ER_LOCK_WAIT_TIMEOUT |
| 31 |
SELECT * FROM t FOR UPDATE; |
| 32 |
--disconnect con1 |
| 33 |
|
| 34 |
--connection default |
| 35 |
COMMIT; |
| 36 |
|
| 37 |
SELECT variable_value - @innodb_row_lock_time_before > 100 |
| 38 |
FROM information_schema.global_status |
| 39 |
WHERE LOWER(variable_name) = 'innodb_row_lock_time'; |
| 40 |
# We can't use 'variable_value - @innodb_row_lock_time_max_before' trick for |
| 41 |
# innodb_row_lock_time_max, because we can't reset it, and we don't know the |
| 42 |
# initial value at the moment of the test execution. |
| 43 |
SELECT variable_value > 100 |
| 44 |
FROM information_schema.global_status |
| 45 |
WHERE LOWER(variable_name) = 'innodb_row_lock_time_max'; |
| 46 |
SELECT count_reset > 100 |
| 47 |
FROM INFORMATION_SCHEMA.INNODB_METRICS |
| 48 |
WHERE NAME='lock_row_lock_time'; |
| 49 |
SELECT count_reset > 100 |
| 50 |
FROM INFORMATION_SCHEMA.INNODB_METRICS |
| 51 |
WHERE NAME='lock_row_lock_time_max'; |
| 52 |
|
| 53 |
DROP TABLE t; |
| 54 |
|
| 55 |
--disable_warnings |
| 56 |
SET GLOBAL innodb_monitor_enable=default; |
| 57 |
SET GLOBAL innodb_monitor_disable=default; |
| 58 |
SET GLOBAL innodb_monitor_reset_all=default; |
| 59 |
--enable_warnings |
| 60 |
|
| 61 |
--source include/wait_until_count_sessions.inc |