Debian Codegraph @

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

raw
1 # Tests for PERFORMANCE_SCHEMA
2 #
3 # Test the effect of a flush tables with read lock on setup_ tables.
4
5 use performance_schema;
6
7 # Make test robust against errors in other tests.
8 # Ensure that instrumentation is turned on when we create new connection.
9 update performance_schema.setup_instruments set enabled='YES';
10
11 create user pfsuser@localhost;
12 grant SELECT, UPDATE, LOCK TABLES on performance_schema.* to pfsuser@localhost;
13 flush privileges;
14
15 --echo connect (con1, localhost, pfsuser, , test);
16 connect (con1, localhost, pfsuser, , test);
17
18 lock tables performance_schema.setup_instruments read;
19 --disable_result_log
20 select * from performance_schema.setup_instruments;
21 --enable_result_log
22 unlock tables;
23
24 lock tables performance_schema.setup_instruments write;
25 update performance_schema.setup_instruments set enabled='NO';
26 update performance_schema.setup_instruments set enabled='YES';
27 unlock tables;
28
29 --echo connection default;
30 connection default;
31
32 flush tables with read lock;
33
34 --echo connection con1;
35 connection con1;
36
37 lock tables performance_schema.setup_instruments read;
38 --disable_result_log
39 select * from performance_schema.setup_instruments;
40 --enable_result_log
41 unlock tables;
42
43 # This will block
44 --send
45 lock tables performance_schema.setup_instruments write;
46
47 --echo connection default;
48 connection default;
49
50 let $wait_condition= select 1 from performance_schema.events_waits_current where event_name like "wait/synch/cond/sql/MDL_context::COND_wait_status";
51
52 --source include/wait_condition.inc
53
54 # Observe the blocked thread in the performance schema :)
55 select event_name,
56 left(source, locate(":", source)) as short_source,
57 if(timer_end IS NULL, NULL, "SET") as timer_end,
58 if(timer_wait IS NULL, NULL, "SET") as timer_wait,
59 operation
60 from performance_schema.events_waits_current
61 where event_name like "wait/synch/cond/sql/MDL_context::COND_wait_status";
62
63 unlock tables;
64
65 connection con1;
66 --reap
67
68 update performance_schema.setup_instruments set enabled='NO';
69 update performance_schema.setup_instruments set enabled='YES';
70 unlock tables;
71
72 disconnect con1;
73 --source include/wait_until_disconnected.inc
74
75 --echo connection default;
76 connection default;
77
78 drop user pfsuser@localhost;
79 flush privileges;
80