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 --source include/not_embedded.inc
16
17 --echo
18 --echo ### Setup ###
19 --echo
20 select @@global.performance_schema_show_processlist into @save_processlist;
21
22 --echo
23 create user user1@localhost, user2@localhost,
24 user3@localhost, user4@localhost;
25 --echo
26 grant ALL on *.* to user1@localhost;
27 grant ALL on *.* to user2@localhost;
28 grant ALL on *.* to user3@localhost;
29 grant ALL on *.* to user4@localhost;
30 --echo
31 flush privileges;
32
33 --echo
34 use test;
35 create table test.t1 (s1 int, s2 int, s3 int, s4 int);
36
37 --echo
38 --echo # Switch to (con0, localhost, root, , )
39 connect (con0, localhost, root, , );
40 --echo
41 insert into test.t1 values(1, 1, 1, 1);
42 insert into test.t1 values(2, 2, 2, 2);
43 insert into test.t1 values(3, 3, 3, 3);
44 insert into test.t1 values(4, 4, 4, 4);
45
46 --echo
47 --echo # Lock test.t1, insert/update/deletes will block
48 lock tables t1 read;
49
50 --echo
51 --echo # Connect (con1, localhost, user1, , )
52 connect (con1, localhost, user1, , );
53 --send insert into test.t1 values (0, 0, 0, 0)
54
55 --echo
56 --echo # Connect (con2, localhost, user2, , )
57 connect (con2, localhost, user2, , );
58 # Create a query > 100 characters
59 --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;
60 --echo
61 --echo # Connect (con3, localhost, user3, , )
62 connect (con3, localhost, user3, , );
63 --send delete from test.t1 where s1 = 3
64
65 --echo
66 --echo # Connect (con4, localhost, user4, , )
67 connect (con4, localhost, user4, , );
68 --send insert into test.t1 values (4, 4, 4, 4)
69
70 --echo
71 --echo # Connection default
72 --connection default
73
74 --echo
75 --echo # Wait for queries to appear in the processlist table
76 let $wait_condition = select count(*) >= 4 from information_schema.processlist
77 where state like '%metadata%';
78 --source include/wait_condition.inc
79
80 --echo
81 --echo
82 --echo ### Execute new SHOW [FULL] PROCESSLIST and SELECT on performance_schema.processlist
83 --echo
84 let $pfs_spl = on;
85 --source ../include/processlist_set.inc
86 --source ../include/processlist_load.inc
87
88 --echo
89 --echo
90 --echo ### Execute legacy SHOW [FULL] PROCESSLIST and SELECT on information_schema.processlist
91 --echo
92 let $pfs_spl = off;
93 --source ../include/processlist_set.inc
94 --source ../include/processlist_load.inc
95
96 --echo
97 --echo
98 --echo ### Verify feature code path
99 --echo
100 --echo # Enable SHOW PROCESSLIST via the Performance Schema
101 let $pfs_spl = on;
102 --source ../include/processlist_set.inc
103
104 --echo
105 --echo # Connection default, send SHOW PROCESSLIST
106 --connection default
107 SET DEBUG_SYNC='pfs_show_processlist_performance_schema SIGNAL pfs_processlist_pfs WAIT_FOR continue';
108 --send SHOW FULL PROCESSLIST
109
110 --echo
111 --echo # Connection con0
112 --connection con0
113 SET DEBUG_SYNC='now WAIT_FOR pfs_processlist_pfs';
114 SET DEBUG_SYNC='now SIGNAL continue';
115
116 --echo
117 --echo # Connection default, reap
118 --connection default
119 --replace_column 1 <Id> 3 <Host> 5 <Command> 6 <Time> 7 <State> 8 <Info>
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 --sorted_result
149 --reap
150
151 --echo
152 --echo
153 --echo ### Clean up ###
154 --echo
155
156 --echo # Connection con0, unlock test.t1, disconnect
157 --connection con0
158 unlock tables;
159 --disconnect con0
160
161 --disable_query_log
162 --disable_result_log
163 --echo
164 --echo # Connection con1, reap, disconnect
165 --connection con1
166 --reap
167 --disconnect con1
168
169 --echo # Connection con2, reap, disconnect
170 --connection con2
171 --reap
172 --disconnect con2
173
174 --echo # Connection con3, reap, disconnect
175 --connection con3
176 --reap
177 --disconnect con3
178
179 --echo # Connection con4, reap, disconnect
180 --connection con4
181 --reap
182 --disconnect con4
183 --enable_result_log
184 --enable_query_log
185
186 --echo
187 --echo # Connection default
188 --connection default
189
190 --echo
191 drop table test.t1;
192 drop user user1@localhost;
193 drop user user2@localhost;
194 drop user user3@localhost;
195 drop user user4@localhost;
196 --echo
197 set @@global.performance_schema_show_processlist = @save_processlist;