Debian Codegraph @

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

raw
1 --echo ##
2 --echo ## Test the Performance Schema-based implementation of SHOW PROCESSLIST.
3 --echo ##
4 --echo ## Test cases:
5 --echo ## 1. Execute the new SHOW [FULL] PROCESSLIST and SELECT on performance_schema.processlist
6 --echo ## 2. Execute the legacy SHOW [FULL] PROCESSLIST and SELECT on information_schema.processlist
7 --echo ## 3. Verify that performance_schema_show_processlist = ON executes the new implementation
8 --echo ## 4. Verify that performance_schema_show_processlist = OFF executes the legacy code path
9 --echo ##
10 --echo ## Results must be manually verified.
11
12 --source include/no_protocol.inc
13 --source include/have_debug.inc
14 --source include/have_debug_sync.inc
15
16 --echo
17 --echo ### Setup ###
18 --echo
19 select @@global.performance_schema_show_processlist into @save_processlist;
20
21 --echo
22 create user user1@localhost, user2@localhost,
23 user3@localhost, user4@localhost;
24 --echo
25 grant ALL on *.* to user1@localhost;
26 grant ALL on *.* to user2@localhost;
27 grant ALL on *.* to user3@localhost;
28 grant ALL on *.* to user4@localhost;
29 --echo
30 flush privileges;
31
32 --echo
33 use test;
34 create table test.t1 (s1 int, s2 int, s3 int, s4 int);
35
36 --echo
37 --echo # Switch to (con0, localhost, root, , )
38 connect (con0, localhost, root, , );
39 --echo
40 insert into test.t1 values(1, 1, 1, 1);
41 insert into test.t1 values(2, 2, 2, 2);
42 insert into test.t1 values(3, 3, 3, 3);
43 insert into test.t1 values(4, 4, 4, 4);
44
45 --echo
46 --echo # Lock test.t1, insert/update/deletes will block
47 lock tables t1 read;
48
49 --echo
50 --echo # Connect (con1, localhost, user1, , )
51 connect (con1, localhost, user1, , );
52 --send insert into test.t1 values (0, 0, 0, 0)
53
54 --echo
55 --echo # Connect (con2, localhost, user2, , )
56 connect (con2, localhost, user2, , );
57 # Create a query > 100 characters
58 --send update test.t1 set s1 = s1 + 1, s2 = s2 + 2, s3 = s3 + 3, s4 = ((s4 + 4) * (s4 + 5)) + 12345 + 67890 + 11111 + 22222 + 33333 + 44444 + 55555 + 99999;
59 --echo
60 --echo # Connect (con3, localhost, user3, , )
61 connect (con3, localhost, user3, , );
62 --send delete from test.t1 where s1 = 3
63
64 --echo
65 --echo # Connect (con4, localhost, user4, , )
66 connect (con4, localhost, user4, , );
67 --send insert into test.t1 values (4, 4, 4, 4)
68
69 --echo
70 --echo # Connection default
71 --connection default
72
73 --echo
74 --echo # Wait for queries to appear in the processlist table
75 let $wait_condition = select count(*) >= 4 from information_schema.processlist
76 where state like '%metadata%';
77 --source include/wait_condition.inc
78
79 --echo
80 --echo
81 --echo ### Execute new SHOW [FULL] PROCESSLIST and SELECT on performance_schema.processlist
82 --echo
83 let $pfs_spl = on;
84 --source ../include/processlist_set.inc
85 --source ../include/processlist_load.inc
86
87 --echo
88 --echo
89 --echo ### Execute legacy SHOW [FULL] PROCESSLIST and SELECT on information_schema.processlist
90 --echo
91 let $pfs_spl = off;
92 --source ../include/processlist_set.inc
93 --source ../include/processlist_load.inc
94
95 --echo
96 --echo
97 --echo ### Verify feature code path
98 --echo
99 --echo # Enable SHOW PROCESSLIST via the Performance Schema
100 let $pfs_spl = on;
101 --source ../include/processlist_set.inc
102
103 --echo
104 --echo # Connection default, send SHOW PROCESSLIST
105 --connection default
106 SET DEBUG_SYNC='pfs_show_processlist_performance_schema SIGNAL pfs_processlist_pfs WAIT_FOR continue';
107 --send SHOW FULL PROCESSLIST
108
109 --echo
110 --echo # Connection con0
111 --connection con0
112 SET DEBUG_SYNC='now WAIT_FOR pfs_processlist_pfs';
113 SET DEBUG_SYNC='now SIGNAL continue';
114
115 --echo
116 --echo # Connection default, reap
117 --connection default
118 --replace_column 1 <Id> 3 <Host> 5 <Command> 6 <Time> 7 <State> 8 <Info>
119 --replace_regex /Waiting on empty queue/WAITING/ /Waiting for next activation/WAITING/ /Daemon/<Command>/ /Connect/<Command>/
120 --sorted_result
121 --reap
122
123 --echo
124 --echo
125 --echo ### Verify legacy code path
126 --echo
127 --echo # Enable the legacy SHOW PROCESSLIST
128 let $pfs_spl = off;
129 --source ../include/processlist_set.inc
130
131 --echo
132 --echo # Connection default, send SHOW PROCESSLIST
133 --connection default
134 SET DEBUG_SYNC='RESET';
135 SET DEBUG_SYNC='pfs_show_processlist_legacy SIGNAL pfs_processlist_legacy WAIT_FOR continue';
136 --send SHOW FULL PROCESSLIST
137
138 --echo
139 --echo # Connection con0
140 --connection con0
141 SET DEBUG_SYNC='now WAIT_FOR pfs_processlist_legacy';
142 SET DEBUG_SYNC='now SIGNAL continue';
143
144 --echo
145 --echo # Connection default, reap
146 --connection default
147 --replace_column 1 <Id> 3 <Host> 5 <Command> 6 <Time> 7 <State> 8 <Info>
148 --replace_regex /Waiting on empty queue/WAITING/ /Waiting for next activation/WAITING/ /Daemon/<Command>/ /Connect/<Command>/
149 --sorted_result
150 --reap
151
152 --echo
153 --echo
154 --echo ### Clean up ###
155 --echo
156
157 --echo # Connection con0, unlock test.t1, disconnect
158 --connection con0
159 unlock tables;
160 --disconnect con0
161
162 --disable_query_log
163 --disable_result_log
164 --echo
165 --echo # Connection con1, reap, disconnect
166 --connection con1
167 --reap
168 --disconnect con1
169
170 --echo # Connection con2, reap, disconnect
171 --connection con2
172 --reap
173 --disconnect con2
174
175 --echo # Connection con3, reap, disconnect
176 --connection con3
177 --reap
178 --disconnect con3
179
180 --echo # Connection con4, reap, disconnect
181 --connection con4
182 --reap
183 --disconnect con4
184 --enable_result_log
185 --enable_query_log
186
187 --echo
188 --echo # Connection default
189 --connection default
190
191 --echo
192 drop table test.t1;
193 drop user user1@localhost;
194 drop user user2@localhost;
195 drop user user3@localhost;
196 drop user user4@localhost;
197 --echo
198 set @@global.performance_schema_show_processlist = @save_processlist;