| 1 |
## |
| 2 |
## WL#4818, 4.1.3 MUTEXES, RW-LOCKS, ... |
| 3 |
## |
| 4 |
## Functional testing of mutexes and RW-locks |
| 5 |
## |
| 6 |
|
| 7 |
--source include/not_embedded.inc |
| 8 |
--source include/have_perfschema.inc |
| 9 |
|
| 10 |
UPDATE performance_schema.setup_instruments SET enabled = 'NO', timed = 'YES'; |
| 11 |
|
| 12 |
UPDATE performance_schema.setup_instruments SET enabled = 'YES' |
| 13 |
WHERE name LIKE 'wait/synch/mutex/%' |
| 14 |
OR name LIKE 'wait/synch/rwlock/%'; |
| 15 |
|
| 16 |
# reset lost counters |
| 17 |
truncate table performance_schema.events_statements_summary_by_digest; |
| 18 |
flush global status; |
| 19 |
|
| 20 |
# Make sure objects are instrumented |
| 21 |
select NAME from performance_schema.mutex_instances |
| 22 |
where NAME = 'wait/synch/mutex/mysys/THR_LOCK::mutex' GROUP BY NAME; |
| 23 |
select NAME from performance_schema.rwlock_instances |
| 24 |
where NAME = 'wait/synch/rwlock/sql/LOCK_grant' limit 1; |
| 25 |
|
| 26 |
--disable_warnings |
| 27 |
DROP TABLE IF EXISTS t1; |
| 28 |
--enable_warnings |
| 29 |
|
| 30 |
# |
| 31 |
# TODO: Change to InnoDB when it gets instrumentation |
| 32 |
# |
| 33 |
|
| 34 |
CREATE TABLE t1 (id INT PRIMARY KEY, b CHAR(100) DEFAULT 'initial value') |
| 35 |
ENGINE=MyISAM; |
| 36 |
|
| 37 |
INSERT INTO t1 (id) VALUES (1), (2), (3), (4), (5), (6), (7), (8); |
| 38 |
|
| 39 |
# |
| 40 |
# FM1: Count for mutex should increase with instrumentation enabled and |
| 41 |
# FM2: Count for mutex should not increase with instrumentation disabled |
| 42 |
# |
| 43 |
|
| 44 |
TRUNCATE TABLE performance_schema.events_waits_history_long; |
| 45 |
TRUNCATE TABLE performance_schema.events_waits_history; |
| 46 |
TRUNCATE TABLE performance_schema.events_waits_current; |
| 47 |
|
| 48 |
SELECT * FROM t1 WHERE id = 1; |
| 49 |
|
| 50 |
SET @before_count = (SELECT SUM(TIMER_WAIT) |
| 51 |
FROM performance_schema.events_waits_history_long |
| 52 |
WHERE (EVENT_NAME = 'wait/synch/mutex/mysys/THR_LOCK::mutex')); |
| 53 |
|
| 54 |
SELECT * FROM t1; |
| 55 |
|
| 56 |
SET @after_count = (SELECT SUM(TIMER_WAIT) |
| 57 |
FROM performance_schema.events_waits_history_long |
| 58 |
WHERE (EVENT_NAME = 'wait/synch/mutex/mysys/THR_LOCK::mutex')); |
| 59 |
|
| 60 |
SELECT IF((@after_count - @before_count) > 0, 'Success', 'Failure') test_fm1_timed; |
| 61 |
|
| 62 |
UPDATE performance_schema.setup_instruments SET enabled = 'NO' |
| 63 |
WHERE NAME = 'wait/synch/mutex/mysys/THR_LOCK::mutex'; |
| 64 |
|
| 65 |
TRUNCATE TABLE performance_schema.events_waits_history_long; |
| 66 |
TRUNCATE TABLE performance_schema.events_waits_history; |
| 67 |
TRUNCATE TABLE performance_schema.events_waits_current; |
| 68 |
|
| 69 |
SELECT * FROM t1 WHERE id = 1; |
| 70 |
|
| 71 |
SET @before_count = (SELECT SUM(TIMER_WAIT) |
| 72 |
FROM performance_schema.events_waits_history_long |
| 73 |
WHERE (EVENT_NAME = 'wait/synch/mutex/mysys/THR_LOCK::mutex')); |
| 74 |
|
| 75 |
SELECT * FROM t1; |
| 76 |
|
| 77 |
SET @after_count = (SELECT SUM(TIMER_WAIT) |
| 78 |
FROM performance_schema.events_waits_history_long |
| 79 |
WHERE (EVENT_NAME = 'wait/synch/mutex/mysys/THR_LOCK::mutex')); |
| 80 |
|
| 81 |
SELECT IF((COALESCE(@after_count, 0) - COALESCE(@before_count, 0)) = 0, 'Success', 'Failure') test_fm2_timed; |
| 82 |
|
| 83 |
# |
| 84 |
# Repeat for RW-lock |
| 85 |
# |
| 86 |
|
| 87 |
TRUNCATE TABLE performance_schema.events_waits_history_long; |
| 88 |
TRUNCATE TABLE performance_schema.events_waits_history; |
| 89 |
TRUNCATE TABLE performance_schema.events_waits_current; |
| 90 |
|
| 91 |
show variables like "%not_found%"; |
| 92 |
|
| 93 |
SET @before_count = (SELECT SUM(TIMER_WAIT) |
| 94 |
FROM performance_schema.events_waits_history_long |
| 95 |
WHERE (EVENT_NAME = 'wait/synch/rwlock/sql/LOCK_system_variables_hash')); |
| 96 |
|
| 97 |
show variables like "%not_found%"; |
| 98 |
|
| 99 |
SET @after_count = (SELECT SUM(TIMER_WAIT) |
| 100 |
FROM performance_schema.events_waits_history_long |
| 101 |
WHERE (EVENT_NAME = 'wait/synch/rwlock/sql/LOCK_system_variables_hash')); |
| 102 |
|
| 103 |
SELECT IF((@after_count - @before_count) > 0, 'Success', 'Failure') test_fm1_rw_timed; |
| 104 |
|
| 105 |
UPDATE performance_schema.setup_instruments SET enabled = 'NO' |
| 106 |
WHERE NAME = 'wait/synch/rwlock/sql/LOCK_system_variables_hash'; |
| 107 |
|
| 108 |
TRUNCATE TABLE performance_schema.events_waits_history_long; |
| 109 |
TRUNCATE TABLE performance_schema.events_waits_history; |
| 110 |
TRUNCATE TABLE performance_schema.events_waits_current; |
| 111 |
|
| 112 |
show variables like "%not_found%"; |
| 113 |
|
| 114 |
SET @before_count = (SELECT SUM(TIMER_WAIT) |
| 115 |
FROM performance_schema.events_waits_history_long |
| 116 |
WHERE (EVENT_NAME = 'wait/synch/rwlock/sql/LOCK_system_variables_hash')); |
| 117 |
|
| 118 |
show variables like "%not_found%"; |
| 119 |
|
| 120 |
SET @after_count = (SELECT SUM(TIMER_WAIT) |
| 121 |
FROM performance_schema.events_waits_history_long |
| 122 |
WHERE (EVENT_NAME = 'LOCK_system_variables_hash')); |
| 123 |
|
| 124 |
SELECT IF((COALESCE(@after_count, 0) - COALESCE(@before_count, 0)) = 0, 'Success', 'Failure') test_fm2_rw_timed; |
| 125 |
|
| 126 |
# Clean-up. |
| 127 |
UPDATE performance_schema.setup_instruments SET enabled = 'YES'; |
| 128 |
DROP TABLE t1; |
| 129 |
|
| 130 |
UPDATE performance_schema.setup_instruments SET enabled = 'YES', timed = 'YES'; |
| 131 |
|
| 132 |
# In case of failure, will indicate the root cause |
| 133 |
show global status like "performance_schema%"; |
| 134 |
|