Debian Codegraph @

mysql-test/suite/perfschema/t/func_mutex.test

raw
1 ##
2 ## WL#4818, 4.1.3 MUTEXES, RW-LOCKS, ...
3 ##
4 ## Functional testing of mutexes and RW-locks
5 ##
6
7 --source include/have_myisam.inc
8 --source include/force_myisam_default.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 status;
19
20 # Make sure objects are instrumented
21 select NAME from performance_schema.mutex_instances
22 where NAME = 'wait/synch/mutex/sql/LOCK_open';
23
24 --disable_warnings
25 DROP TABLE IF EXISTS t1;
26 --enable_warnings
27
28 #
29 # TODO: Change to InnoDB when it gets instrumentation
30 #
31
32 CREATE TABLE t1 (id INT PRIMARY KEY, b CHAR(100) DEFAULT 'initial value')
33 ENGINE=MyISAM;
34
35 INSERT INTO t1 (id) VALUES (1), (2), (3), (4), (5), (6), (7), (8);
36
37 #
38 # FM1: Count for mutex should increase with instrumentation enabled and
39 # FM2: Count for mutex should not increase with instrumentation disabled
40 #
41
42 TRUNCATE TABLE performance_schema.events_waits_history_long;
43 TRUNCATE TABLE performance_schema.events_waits_history;
44 TRUNCATE TABLE performance_schema.events_waits_current;
45
46 SELECT * FROM t1 WHERE id = 1;
47
48 CREATE TABLE t2 SELECT * FROM performance_schema.events_waits_history_long
49 WHERE (EVENT_NAME = 'wait/synch/mutex/sql/LOCK_table_cache');
50 SET @before_count = (SELECT SUM(TIMER_WAIT) FROM t2);
51
52 TRUNCATE TABLE performance_schema.events_waits_history_long;
53
54 SELECT * FROM t1;
55
56 INSERT INTO t2 SELECT * FROM performance_schema.events_waits_history_long
57 WHERE (EVENT_NAME = 'wait/synch/mutex/sql/LOCK_table_cache');
58 SET @after_count = (SELECT SUM(TIMER_WAIT) FROM t2);
59
60 SELECT IF(@after_count < @before_count, 'Failue', 'Success') test_fm1_timed;
61
62 DROP TABLE t2;
63
64 UPDATE performance_schema.setup_instruments SET enabled = 'NO'
65 WHERE NAME = 'wait/synch/mutex/sql/LOCK_table_cache';
66
67 TRUNCATE TABLE performance_schema.events_waits_history_long;
68 TRUNCATE TABLE performance_schema.events_waits_history;
69 TRUNCATE TABLE performance_schema.events_waits_current;
70
71 SELECT * FROM t1 WHERE id = 1;
72
73 SET @before_count = (SELECT SUM(TIMER_WAIT)
74 FROM performance_schema.events_waits_history_long
75 WHERE (EVENT_NAME = 'wait/synch/mutex/sql/LOCK_table_cache'));
76
77 SELECT * FROM t1;
78
79 SET @after_count = (SELECT SUM(TIMER_WAIT)
80 FROM performance_schema.events_waits_history_long
81 WHERE (EVENT_NAME = 'wait/synch/mutex/sql/LOCK_table_cache'));
82
83 SELECT IF((COALESCE(@after_count, 0) - COALESCE(@before_count, 0)) = 0, 'Success', 'Failure') test_fm2_timed;
84
85 # Clean-up.
86 UPDATE performance_schema.setup_instruments SET enabled = 'YES';
87 DROP TABLE t1;
88
89 UPDATE performance_schema.setup_instruments SET enabled = 'YES', timed = 'YES';
90
91 # In case of failure, will indicate the root cause
92 show global status like "performance_schema%_lost";
93