Merge lp:~tsarev/percona-server/5.5_fix_bug_716210_3 into lp:percona-server/5.5
- 5.5_fix_bug_716210_3
- Merge into 5.5
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Oleg Tsarev | ||||
Approved revision: | no longer in the source branch. | ||||
Merge reported by: | Laurynas Biveinis | ||||
Merged at revision: | not available | ||||
Proposed branch: | lp:~tsarev/percona-server/5.5_fix_bug_716210_3 | ||||
Merge into: | lp:percona-server/5.5 | ||||
Prerequisite: | lp:~tsarev/percona-server/5.5.16-porting | ||||
Diff against target: |
741 lines (+519/-92) 1 file modified
patches/slow_extended.patch (+519/-92) |
||||
To merge this branch: | bzr merge lp:~tsarev/percona-server/5.5_fix_bug_716210_3 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Laurynas Biveinis (community) | Approve | ||
Alexey Kopytov | Pending | ||
Review via email: mp+79027@code.launchpad.net |
This proposal supersedes a proposal from 2011-10-07.
Commit message
Description of the change
From previous version of MP: I added additional tests (Rows_{
Applied Laurynas's recomendations. I can't do method "reset_
But I add const to argument of "restore_
Laurynas, thank you for your review and attention to details.
Clean Jenkins results: http://
Origianl description:
* "all statistics variables used in slow_extended.patch and thd->send_row_count and thd->examined_
* Added to class THD (sql/sql_class.h) following methods:
1) clear_slow_extended - clear SESV
2) reset_sub_
3) restore_
* Added to class Sub_statement_state (sql/sql_class.h) required for correct backup variables
* Added to class THD (sql/sql_class.h) comments near the SESV with explanations of purpose of variables
* Added call of clear_slow_extended to THD::init() (required on THD class initialisation and change_user)
* Fix admin command processing in LOGGER:
1) query and query_length according to comment in sql_class.h always correlated - if query == NULL => query_length == 0, and if query != NULL => query_length != 0
2) After "if (!query) { ... }" query_lenght always not 0
3) if (!query_length) (code before my fix) always trye
* Fixed accoring to code policy code formating in "increment_
* Fixed THD::reset_
* Fixed bug #716210: add thd->clear_
Oleg Tsarev (tsarev) wrote : Posted in a previous version of this proposal | # |
Oleg Tsarev (tsarev) wrote : Posted in a previous version of this proposal | # |
Laurynas Biveinis (laurynas-biveinis) wrote : Posted in a previous version of this proposal | # |
LGTM provided that Jenkins result are clean
Alexey Kopytov (akopytov) wrote : Posted in a previous version of this proposal | # |
last_errno is not the only variable that has to be reset for admin commands after a failing statement. Most other counters from slow_extended are affected by the same problem.
Here's an test case:
create table t1(a int primary key);
insert into t1 values (1), (2), (3);
insert into t1 select * from t1 order by rand();
The last statement will fail ER_DUP_ENTRY, and the next admin command will have the same Last_errno, Rows_{sent,
I'm fairly sure InnoDB stats have the same problem.
Some comments on the test case:
- with use_global_
- please replace 1050 with ER_TABLE_
Laurynas Biveinis (laurynas-biveinis) wrote : Posted in a previous version of this proposal | # |
- I am not sure the class Sub_statement_state is the best place to piggyback the backup info too (maybe Alexey can comment on this.) Perhaps a separate struct is needed?
- Please extend the testcase to show that other variables (Rows_{
Typos in the comment at 282--294:
1) "write_to_slow _log"
2) s/inited/
3) I'm not sure what "2)" and "3)" in the comment are trying to say.
Lines 313: I'm not sure what "Following Variables innodb_*** (is |should be) different from" is supposed to mean
Lines 324,329: s/collect/collects
Line 335: s/generates/
Line 337: s/contain/contains the
Line 346: constify the argument (unless something prevents this)
Oleg Tsarev (tsarev) wrote : Posted in a previous version of this proposal | # |
> - I am not sure the class Sub_statement_state is the best place to piggyback
> the backup info too (maybe Alexey can comment on this.) Perhaps a separate
> struct is needed?
You can look intо:
void THD::reset_
This method use Sub_statement_state for backup all required variables.
I just extend it by me variables (as this was in first version of patch).
Of course, I can extract structure to separated Sub_statement_
> - Please extend the testcase to show that other variables
> (Rows_{
> and Tmp_table_sizes) are reset correctly, as pointed out by Alexey.
ACK
>
> Typos in the comment at 282--294:
> 1) "write_to_slow _log"
> 2) s/inited/
> 3) I'm not sure what "2)" and "3)" in the comment are trying to say.
2) and 3) about variable "write_
2) write_to_slow_log never changed (changed just on thread start time)
3) write_to_slow_log should be used in implementation of feature "sampling by query"
>
> Lines 313: I'm not sure what "Following Variables innodb_*** (is |should be)
> different from" is supposed to mean
> Lines 324,329: s/collect/collects
> Line 335: s/generates/
> Line 337: s/contain/contains the
> Line 346: constify the argument (unless something prevents this)
Laurynas Biveinis (laurynas-biveinis) wrote : Posted in a previous version of this proposal | # |
> This method use Sub_statement_state for backup all required variables.
> I just extend it by me variables (as this was in first version of patch).
>
> Of course, I can extract structure to separated
> Sub_statement_
I have looked more carefully, and I see that some of the already-existing Sub_statement_state fields are used for backup too. Now I agree that just extending it is OK.
> > 3) I'm not sure what "2)" and "3)" in the comment are trying to say.
>
> 2) and 3) about variable "write_
> 2) write_to_slow_log never changed (changed just on thread start time)
> 3) write_to_slow_log should be used in implementation of feature "sampling
> by query"
2) The variable is initialized on the thread startup and remains constant afterwards. This will change when LP #712396 ("log_slow_
3) An implementation of LP #688646 ("Make query sampling possible by query") should use it.
Laurynas Biveinis (laurynas-biveinis) wrote : Posted in a previous version of this proposal | # |
LGTM with the the first comment below replied to and the rest of the changes. As far as I'm concerned, if the adjusted patch will be different from the current one with the changes below and nothing else, a new MP is not necessary.
- Can the argument of
THD::
*backup) and the method void
THD::
*backup) be constified?
- Line 294: s/save/saves
- Line 305: s/innodb_was used show/innodb_
- Line 272: s/Belowing/
- Line 288: please wrap at 78th column
- Line 337: s/Belowing/
Laurynas Biveinis (laurynas-biveinis) wrote : | # |
LGTM
Preview Diff
1 | === modified file 'patches/slow_extended.patch' |
2 | --- patches/slow_extended.patch 2011-10-11 20:41:24 +0000 |
3 | +++ patches/slow_extended.patch 2011-10-11 20:41:24 +0000 |
4 | @@ -227,29 +227,16 @@ |
5 | } |
6 | else |
7 | { |
8 | -@@ -1239,8 +1255,20 @@ |
9 | - query_length= command_name[thd->command].length; |
10 | +@@ -1240,7 +1256,7 @@ |
11 | } |
12 | |
13 | -+ if (!query_length) |
14 | -+ { |
15 | -+ thd->sent_row_count= thd->examined_row_count= 0; |
16 | -+ thd->sent_row_count= 0; |
17 | -+ thd->bytes_sent_old= thd->status_var.bytes_sent; |
18 | -+ thd->tmp_tables_used= thd->tmp_tables_disk_used= 0; |
19 | -+ thd->tmp_tables_size= 0; |
20 | -+ thd->innodb_was_used= FALSE; |
21 | -+ thd->query_plan_flags= QPLAN_NONE; |
22 | -+ thd->query_plan_fsort_passes= 0; |
23 | -+ } |
24 | -+ |
25 | for (current_handler= slow_log_handler_list; *current_handler ;) |
26 | - error= (*current_handler++)->log_slow(thd, current_time, thd->start_time, |
27 | + error= (*current_handler++)->log_slow(thd, current_utime, thd->start_time, |
28 | user_host_buff, user_host_len, |
29 | query_utime, lock_utime, is_command, |
30 | query, query_length) || error; |
31 | -@@ -2656,12 +2684,13 @@ |
32 | +@@ -2656,12 +2672,13 @@ |
33 | TRUE - error occured |
34 | */ |
35 | |
36 | @@ -264,7 +251,7 @@ |
37 | bool error= 0; |
38 | DBUG_ENTER("MYSQL_QUERY_LOG::write"); |
39 | |
40 | -@@ -2683,17 +2712,28 @@ |
41 | +@@ -2683,17 +2700,28 @@ |
42 | |
43 | if (!(specialflag & SPECIAL_SHORT_LOG_FORMAT)) |
44 | { |
45 | @@ -300,9 +287,11 @@ |
46 | |
47 | /* Note that my_b_write() assumes it knows the length for this */ |
48 | if (my_b_write(&log_file, (uchar*) buff, buff_len)) |
49 | -@@ -2711,12 +2751,69 @@ |
50 | +@@ -2710,13 +2738,71 @@ |
51 | + /* For slow query log */ |
52 | sprintf(query_time_buff, "%.6f", ulonglong2double(query_utime)/1000000.0); |
53 | sprintf(lock_time_buff, "%.6f", ulonglong2double(lock_utime)/1000000.0); |
54 | ++ DBUG_PRINT("info", ("Last_errno: %u", thd->last_errno)); |
55 | if (my_b_printf(&log_file, |
56 | - "# Query_time: %s Lock_time: %s" |
57 | - " Rows_sent: %lu Rows_examined: %lu\n", |
58 | @@ -521,22 +510,22 @@ |
59 | |
60 | +extern "C" |
61 | +void increment_thd_innodb_stats(THD* thd, |
62 | -+ unsigned long long trx_id, |
63 | -+ long io_reads, |
64 | -+ long long io_read, |
65 | -+ long io_reads_wait_timer, |
66 | -+ long lock_que_wait_timer, |
67 | -+ long que_wait_timer, |
68 | -+ long page_access) |
69 | ++ unsigned long long trx_id, |
70 | ++ long io_reads, |
71 | ++ long long io_read, |
72 | ++ long io_reads_wait_timer, |
73 | ++ long lock_que_wait_timer, |
74 | ++ long que_wait_timer, |
75 | ++ long page_access) |
76 | +{ |
77 | -+ thd->innodb_was_used = TRUE; |
78 | -+ thd->innodb_trx_id = trx_id; |
79 | -+ thd->innodb_io_reads += io_reads; |
80 | -+ thd->innodb_io_read += io_read; |
81 | -+ thd->innodb_io_reads_wait_timer += io_reads_wait_timer; |
82 | -+ thd->innodb_lock_que_wait_timer += lock_que_wait_timer; |
83 | -+ thd->innodb_innodb_que_wait_timer += que_wait_timer; |
84 | -+ thd->innodb_page_access += page_access; |
85 | ++ thd->innodb_was_used= TRUE; |
86 | ++ thd->innodb_trx_id= trx_id; |
87 | ++ thd->innodb_io_reads+= io_reads; |
88 | ++ thd->innodb_io_read+= io_read; |
89 | ++ thd->innodb_io_reads_wait_timer+= io_reads_wait_timer; |
90 | ++ thd->innodb_lock_que_wait_timer+= lock_que_wait_timer; |
91 | ++ thd->innodb_innodb_que_wait_timer+= que_wait_timer; |
92 | ++ thd->innodb_page_access+= page_access; |
93 | +} |
94 | + |
95 | +extern "C" |
96 | @@ -562,44 +551,124 @@ |
97 | if (!m_internal_handler) |
98 | { |
99 | *cond_hdl= NULL; |
100 | -@@ -3675,6 +3708,12 @@ |
101 | +@@ -1201,6 +1234,8 @@ |
102 | + /* Initialize the Debug Sync Facility. See debug_sync.cc. */ |
103 | + debug_sync_init_thread(this); |
104 | + #endif /* defined(ENABLED_DEBUG_SYNC) */ |
105 | ++ |
106 | ++ clear_slow_extended(); |
107 | + } |
108 | + |
109 | + |
110 | +@@ -3647,8 +3682,6 @@ |
111 | + backup->in_sub_stmt= in_sub_stmt; |
112 | + backup->enable_slow_log= enable_slow_log; |
113 | + backup->limit_found_rows= limit_found_rows; |
114 | +- backup->examined_row_count= examined_row_count; |
115 | +- backup->sent_row_count= sent_row_count; |
116 | + backup->cuted_fields= cuted_fields; |
117 | + backup->client_capabilities= client_capabilities; |
118 | + backup->savepoints= transaction.savepoints; |
119 | +@@ -3656,6 +3689,7 @@ |
120 | first_successful_insert_id_in_prev_stmt; |
121 | backup->first_successful_insert_id_in_cur_stmt= |
122 | first_successful_insert_id_in_cur_stmt; |
123 | -+ backup->innodb_io_reads= innodb_io_reads; |
124 | -+ backup->innodb_io_read= innodb_io_read; |
125 | -+ backup->innodb_io_reads_wait_timer= innodb_io_reads_wait_timer; |
126 | -+ backup->innodb_lock_que_wait_timer= innodb_lock_que_wait_timer; |
127 | -+ backup->innodb_innodb_que_wait_timer= innodb_innodb_que_wait_timer; |
128 | -+ backup->innodb_page_access= innodb_page_access; |
129 | ++ reset_sub_statement_state_slow_extended(backup); |
130 | |
131 | if ((!lex->requires_prelocking() || is_update_query(lex->sql_command)) && |
132 | !is_current_stmt_binlog_format_row()) |
133 | -@@ -3695,6 +3734,14 @@ |
134 | +@@ -3671,13 +3705,74 @@ |
135 | + /* Disable result sets */ |
136 | + client_capabilities &= ~CLIENT_MULTI_RESULTS; |
137 | + in_sub_stmt|= new_state; |
138 | +- examined_row_count= 0; |
139 | +- sent_row_count= 0; |
140 | cuted_fields= 0; |
141 | transaction.savepoints= 0; |
142 | first_successful_insert_id_in_cur_stmt= 0; |
143 | -+ last_errno= 0; |
144 | -+ innodb_trx_id= 0; |
145 | -+ innodb_io_reads= 0; |
146 | -+ innodb_io_read= 0; |
147 | -+ innodb_io_reads_wait_timer= 0; |
148 | -+ innodb_lock_que_wait_timer= 0; |
149 | + } |
150 | + |
151 | ++void THD::clear_slow_extended() |
152 | ++{ |
153 | ++ DBUG_ENTER("THD::clear_slow_extended"); |
154 | ++ sent_row_count= 0; |
155 | ++ examined_row_count= 0; |
156 | ++ bytes_sent_old= status_var.bytes_sent; |
157 | ++ tmp_tables_used= 0; |
158 | ++ tmp_tables_disk_used= 0; |
159 | ++ tmp_tables_size= 0; |
160 | ++ innodb_was_used= FALSE; |
161 | ++ innodb_trx_id= 0; |
162 | ++ innodb_io_reads= 0; |
163 | ++ innodb_io_read= 0; |
164 | ++ innodb_io_reads_wait_timer= 0; |
165 | ++ innodb_lock_que_wait_timer= 0; |
166 | + innodb_innodb_que_wait_timer= 0; |
167 | -+ innodb_page_access= 0; |
168 | - } |
169 | - |
170 | - |
171 | -@@ -3757,6 +3804,12 @@ |
172 | ++ innodb_page_access= 0; |
173 | ++ query_plan_flags= QPLAN_NONE; |
174 | ++ query_plan_fsort_passes= 0; |
175 | ++ last_errno= 0; |
176 | ++ DBUG_VOID_RETURN; |
177 | ++} |
178 | ++ |
179 | ++void THD::reset_sub_statement_state_slow_extended(Sub_statement_state *backup) |
180 | ++{ |
181 | ++ DBUG_ENTER("THD::reset_sub_statement_state_slow_extended"); |
182 | ++ backup->sent_row_count= sent_row_count; |
183 | ++ backup->examined_row_count= examined_row_count; |
184 | ++ backup->tmp_tables_used= tmp_tables_used; |
185 | ++ backup->tmp_tables_disk_used= tmp_tables_disk_used; |
186 | ++ backup->tmp_tables_size= tmp_tables_size; |
187 | ++ backup->innodb_was_used= innodb_was_used; |
188 | ++ backup->innodb_io_reads= innodb_io_reads; |
189 | ++ backup->innodb_io_read= innodb_io_read; |
190 | ++ backup->innodb_io_reads_wait_timer= innodb_io_reads_wait_timer; |
191 | ++ backup->innodb_lock_que_wait_timer= innodb_lock_que_wait_timer; |
192 | ++ backup->innodb_innodb_que_wait_timer= innodb_innodb_que_wait_timer; |
193 | ++ backup->innodb_page_access= innodb_page_access; |
194 | ++ backup->query_plan_flags= query_plan_flags; |
195 | ++ backup->query_plan_fsort_passes= query_plan_fsort_passes; |
196 | ++ clear_slow_extended(); |
197 | ++ DBUG_VOID_RETURN; |
198 | ++} |
199 | ++ |
200 | ++void THD::restore_sub_statement_state_slow_extended(const Sub_statement_state *backup) |
201 | ++{ |
202 | ++ DBUG_ENTER("THD::restore_sub_statement_state_slow_extended"); |
203 | ++ sent_row_count= backup->sent_row_count; |
204 | ++ examined_row_count+= backup->examined_row_count; |
205 | ++ tmp_tables_used+= backup->tmp_tables_used; |
206 | ++ tmp_tables_disk_used+= backup->tmp_tables_disk_used; |
207 | ++ tmp_tables_size+= backup->tmp_tables_size; |
208 | ++ innodb_was_used= (innodb_was_used || backup->innodb_was_used); |
209 | ++ innodb_io_reads+= backup->innodb_io_reads; |
210 | ++ innodb_io_read+= backup->innodb_io_read; |
211 | ++ innodb_io_reads_wait_timer+= backup->innodb_io_reads_wait_timer; |
212 | ++ innodb_lock_que_wait_timer+= backup->innodb_lock_que_wait_timer; |
213 | ++ innodb_innodb_que_wait_timer+= backup->innodb_innodb_que_wait_timer; |
214 | ++ innodb_page_access+= backup->innodb_page_access; |
215 | ++ query_plan_flags|= backup->query_plan_flags; |
216 | ++ query_plan_fsort_passes+= backup->query_plan_fsort_passes; |
217 | ++ DBUG_VOID_RETURN; |
218 | ++} |
219 | + |
220 | + void THD::restore_sub_statement_state(Sub_statement_state *backup) |
221 | + { |
222 | +@@ -3718,7 +3813,6 @@ |
223 | + first_successful_insert_id_in_cur_stmt= |
224 | + backup->first_successful_insert_id_in_cur_stmt; |
225 | + limit_found_rows= backup->limit_found_rows; |
226 | +- sent_row_count= backup->sent_row_count; |
227 | + client_capabilities= backup->client_capabilities; |
228 | + /* |
229 | + If we've left sub-statement mode, reset the fatal error flag. |
230 | +@@ -3736,8 +3830,8 @@ |
231 | + The following is added to the old values as we are interested in the |
232 | + total complexity of the query |
233 | */ |
234 | - examined_row_count+= backup->examined_row_count; |
235 | +- examined_row_count+= backup->examined_row_count; |
236 | cuted_fields+= backup->cuted_fields; |
237 | -+ innodb_io_reads+= backup->innodb_io_reads; |
238 | -+ innodb_io_read+= backup->innodb_io_read; |
239 | -+ innodb_io_reads_wait_timer+= backup->innodb_io_reads_wait_timer; |
240 | -+ innodb_lock_que_wait_timer+= backup->innodb_lock_que_wait_timer; |
241 | -+ innodb_innodb_que_wait_timer+= backup->innodb_innodb_que_wait_timer; |
242 | -+ innodb_page_access+= backup->innodb_page_access; |
243 | ++ restore_sub_statement_state_slow_extended(backup); |
244 | DBUG_VOID_RETURN; |
245 | } |
246 | |
247 | @@ -661,11 +730,17 @@ |
248 | double long_query_time_double; |
249 | |
250 | } SV; |
251 | -@@ -1140,6 +1182,14 @@ |
252 | +@@ -1140,6 +1182,24 @@ |
253 | uint in_sub_stmt; |
254 | bool enable_slow_log; |
255 | bool last_insert_id_used; |
256 | + |
257 | ++ /*** Following variables used in slow_extended.patch ***/ |
258 | ++ ulong tmp_tables_used; |
259 | ++ ulong tmp_tables_disk_used; |
260 | ++ ulonglong tmp_tables_size; |
261 | ++ |
262 | ++ bool innodb_was_used; |
263 | + ulong innodb_io_reads; |
264 | + ulonglong innodb_io_read; |
265 | + ulong innodb_io_reads_wait_timer; |
266 | @@ -673,20 +748,49 @@ |
267 | + ulong innodb_innodb_que_wait_timer; |
268 | + ulong innodb_page_access; |
269 | + |
270 | ++ ulong query_plan_flags; |
271 | ++ ulong query_plan_fsort_passes; |
272 | ++ /*** The variables above used in slow_extended.patch ***/ |
273 | ++ |
274 | SAVEPOINT *savepoints; |
275 | enum enum_check_fields count_cuted_fields; |
276 | }; |
277 | -@@ -1588,6 +1638,26 @@ |
278 | +@@ -1588,6 +1648,71 @@ |
279 | thr_lock_type update_lock_default; |
280 | Delayed_insert *di; |
281 | |
282 | ++ /*** Following variables used in slow_extended.patch ***/ |
283 | ++ /* |
284 | ++ Variable write_to_slow_log: |
285 | ++ 1) initialized in |
286 | ++ * sql_connect.cc (log_slow_rate_limit support) |
287 | ++ * slave.cc (log_slow_slave_statements support) |
288 | ++ 2) The variable is initialized on the thread startup and remains |
289 | ++ constant afterwards. This will change when |
290 | ++ LP #712396 ("log_slow_slave_statements not work on replication |
291 | ++ threads without RESTART") is implemented. |
292 | ++ 3) An implementation of LP #688646 ("Make query sampling possible by query") should use it. |
293 | ++ */ |
294 | + bool write_to_slow_log; |
295 | -+ |
296 | ++ /* |
297 | ++ Variable bytes_send_old saves value of thd->status_var.bytes_sent |
298 | ++ before query execution. |
299 | ++ */ |
300 | + ulonglong bytes_sent_old; |
301 | ++ /* |
302 | ++ Variables tmp_tables_*** collect statistics about usage of temporary tables |
303 | ++ */ |
304 | + ulong tmp_tables_used; |
305 | + ulong tmp_tables_disk_used; |
306 | + ulonglong tmp_tables_size; |
307 | ++ /* |
308 | ++ Variable innodb_was_used shows used or not InnoDB engine in current query. |
309 | ++ */ |
310 | + bool innodb_was_used; |
311 | ++ /* |
312 | ++ Following Variables innodb_*** (is |should be) different from |
313 | ++ default values only if (innodb_was_used==TRUE) |
314 | ++ */ |
315 | + ulonglong innodb_trx_id; |
316 | + ulong innodb_io_reads; |
317 | + ulonglong innodb_io_read; |
318 | @@ -695,10 +799,30 @@ |
319 | + ulong innodb_innodb_que_wait_timer; |
320 | + ulong innodb_page_access; |
321 | + |
322 | ++ /* |
323 | ++ Variable query_plan_flags collects information about query plan entites |
324 | ++ used on query execution. |
325 | ++ */ |
326 | + ulong query_plan_flags; |
327 | ++ /* |
328 | ++ Variable query_plan_fsort_passes collects information about file sort passes |
329 | ++ acquired during query execution. |
330 | ++ */ |
331 | + ulong query_plan_fsort_passes; |
332 | -+ |
333 | ++ /* |
334 | ++ Query can generate several errors/warnings during execution |
335 | ++ (see THD::handle_condition comment in sql_class.h) |
336 | ++ Variable last_errno contains the last error/warning acquired during |
337 | ++ query execution. |
338 | ++ */ |
339 | + uint last_errno; |
340 | ++ /*** The variables above used in slow_extended.patch ***/ |
341 | ++ |
342 | ++ /*** Following methods used in slow_extended.patch ***/ |
343 | ++ void clear_slow_extended(); |
344 | ++ void reset_sub_statement_state_slow_extended(Sub_statement_state *backup); |
345 | ++ void restore_sub_statement_state_slow_extended(const Sub_statement_state *backup); |
346 | ++ /*** The methods above used in slow_extended.patch ***/ |
347 | + |
348 | /* <> 0 if we are inside of trigger or stored function. */ |
349 | uint in_sub_stmt; |
350 | @@ -731,7 +855,15 @@ |
351 | |
352 | const char *any_db="*any*"; // Special symbol for check_access |
353 | |
354 | -@@ -1430,6 +1431,60 @@ |
355 | +@@ -888,6 +889,7 @@ |
356 | + the slow log only if opt_log_slow_admin_statements is set. |
357 | + */ |
358 | + thd->enable_slow_log= TRUE; |
359 | ++ thd->clear_slow_extended(); |
360 | + thd->lex->sql_command= SQLCOM_END; /* to avoid confusing VIEW detectors */ |
361 | + thd->set_time(); |
362 | + if (!thd->is_valid_time()) |
363 | +@@ -1430,6 +1432,60 @@ |
364 | DBUG_RETURN(error); |
365 | } |
366 | |
367 | @@ -792,7 +924,7 @@ |
368 | |
369 | void log_slow_statement(THD *thd) |
370 | { |
371 | -@@ -1443,13 +1498,48 @@ |
372 | +@@ -1443,13 +1499,48 @@ |
373 | if (unlikely(thd->in_sub_stmt)) |
374 | DBUG_VOID_RETURN; // Don't set time for sub stmt |
375 | |
376 | @@ -842,38 +974,16 @@ |
377 | thd_proc_info(thd, "logging slow query"); |
378 | |
379 | if (((thd->server_status & SERVER_QUERY_WAS_SLOW) || |
380 | -@@ -1879,6 +1969,9 @@ |
381 | - context.resolve_in_table_list_only(select_lex-> |
382 | - table_list.first); |
383 | - |
384 | -+ /* Reset the counter at all cases for the extended slow query log */ |
385 | -+ thd->sent_row_count= 0; |
386 | -+ |
387 | - /* |
388 | - Reset warning count for each query that uses tables |
389 | - A better approach would be to reset this for any commands |
390 | -@@ -5297,6 +5390,21 @@ |
391 | +@@ -5295,7 +5386,8 @@ |
392 | + thd->stmt_da->reset_diagnostics_area(); |
393 | + thd->warning_info->reset_for_next_command(); |
394 | thd->rand_used= 0; |
395 | - thd->sent_row_count= thd->examined_row_count= 0; |
396 | +- thd->sent_row_count= thd->examined_row_count= 0; |
397 | ++ |
398 | ++ thd->clear_slow_extended(); |
399 | |
400 | -+ thd->bytes_sent_old= thd->status_var.bytes_sent; |
401 | -+ thd->tmp_tables_used= thd->tmp_tables_disk_used= 0; |
402 | -+ thd->tmp_tables_size= 0; |
403 | -+ thd->innodb_was_used= FALSE; |
404 | -+ thd->innodb_trx_id= 0; |
405 | -+ thd->innodb_io_reads= 0; |
406 | -+ thd->innodb_io_read= 0; |
407 | -+ thd->innodb_io_reads_wait_timer= 0; |
408 | -+ thd->innodb_lock_que_wait_timer= 0; |
409 | -+ thd->innodb_innodb_que_wait_timer= 0; |
410 | -+ thd->innodb_page_access= 0; |
411 | -+ thd->query_plan_flags= QPLAN_NONE; |
412 | -+ thd->query_plan_fsort_passes= 0; |
413 | -+ thd->last_errno= 0; |
414 | -+ |
415 | thd->reset_current_stmt_binlog_format_row(); |
416 | thd->binlog_unsafe_warning_flags= 0; |
417 | - |
418 | --- a/sql/sql_select.cc |
419 | +++ b/sql/sql_select.cc |
420 | @@ -6902,7 +6902,10 @@ |
421 | @@ -2651,3 +2761,320 @@ |
422 | sort-buffer-size 2097152 |
423 | sporadic-binlog-dump-fail FALSE |
424 | sql-mode |
425 | +--- /dev/null |
426 | ++++ b/mysql-test/t/percona_slow_extended_error_on_quit.test |
427 | +@@ -0,0 +1,87 @@ |
428 | ++################################################################################ |
429 | ++# Current test check following attributes: # |
430 | ++# 1) "Last_errno" # |
431 | ++# 2) "Rows_{sent,examined|affected|read} # |
432 | ++# 3) Bytes_sent # |
433 | ++# 4) Tmp_{tables|dist_tables|table_size} # |
434 | ++# 5) InnoDB statistic counters # |
435 | ++# in Slow Query Log # |
436 | ++# for administrative command "Quit" # |
437 | ++# # |
438 | ++# See Launchpad Bug #716210 # |
439 | ++################################################################################ |
440 | ++ |
441 | ++--source include/have_innodb.inc |
442 | ++ |
443 | ++################################################################################ |
444 | ++--let log_file=percona.slow_extended.error_on_quit |
445 | ++--let wait_condition=SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST; |
446 | ++################################################################################ |
447 | ++ |
448 | ++--disable_warnings |
449 | ++DROP TABLE IF EXISTS t; |
450 | ++--enable_warnings |
451 | ++CREATE TABLE t(a INT) engine=InnoDB; |
452 | ++INSERT INTO t VALUES(0),(1),(2),(3),(4); |
453 | ++ |
454 | ++################################################################################ |
455 | ++--source include/log_start.inc |
456 | ++ |
457 | ++--connect(additional,localhost,root,,) |
458 | ++--connection additional |
459 | ++ |
460 | ++ SET log_slow_verbosity=innodb; |
461 | ++ SET long_query_time= 0; |
462 | ++ |
463 | ++--disable_result_log |
464 | ++--error ER_TABLE_EXISTS_ERROR |
465 | ++ CREATE TABLE t(a INT) engine=InnoDB; |
466 | ++--enable_result_log |
467 | ++ |
468 | ++--connection default |
469 | ++--echo # Disconnecting (passing to Slow Query Log "# administrative command: Quit") |
470 | ++--disconnect additional |
471 | ++--source include/wait_condition.inc |
472 | ++--source include/log_stop.inc |
473 | ++--source include/percona_slow_extended_error_on_quit.inc |
474 | ++################################################################################ |
475 | ++--source include/log_start.inc |
476 | ++ |
477 | ++--connect(additional,localhost,root,,) |
478 | ++--connection additional |
479 | ++ |
480 | ++ SET log_slow_verbosity=innodb; |
481 | ++ SET long_query_time= 0; |
482 | ++ |
483 | ++--disable_result_log |
484 | ++ INSERT INTO t SELECT * FROM t ORDER BY RAND(); |
485 | ++--enable_result_log |
486 | ++ |
487 | ++--connection default |
488 | ++--echo # Disconnecting (passing to Slow Query Log "# administrative command: Quit") |
489 | ++--disconnect additional |
490 | ++--source include/wait_condition.inc |
491 | ++--source include/log_stop.inc |
492 | ++--source include/percona_slow_extended_error_on_quit.inc |
493 | ++################################################################################ |
494 | ++--source include/log_start.inc |
495 | ++ |
496 | ++--connect(additional,localhost,root,,) |
497 | ++--connection additional |
498 | ++ |
499 | ++ SET log_slow_verbosity=innodb; |
500 | ++ SET long_query_time= 0; |
501 | ++ |
502 | ++--disable_result_log |
503 | ++ SELECT * FROM t; |
504 | ++--enable_result_log |
505 | ++ |
506 | ++--connection default |
507 | ++--echo # Disconnecting (passing to Slow Query Log "# administrative command: Quit") |
508 | ++--disconnect additional |
509 | ++--source include/wait_condition.inc |
510 | ++--source include/log_stop.inc |
511 | ++--source include/percona_slow_extended_error_on_quit.inc |
512 | ++################################################################################ |
513 | ++ |
514 | ++DROP TABLE t; |
515 | +--- /dev/null |
516 | ++++ b/mysql-test/r/percona_slow_extended_error_on_quit.result |
517 | +@@ -0,0 +1,171 @@ |
518 | ++DROP TABLE IF EXISTS t; |
519 | ++CREATE TABLE t(a INT) engine=InnoDB; |
520 | ++INSERT INTO t VALUES(0),(1),(2),(3),(4); |
521 | ++[log_start.inc] percona.slow_extended.error_on_quit |
522 | ++SET log_slow_verbosity=innodb; |
523 | ++SET long_query_time= 0; |
524 | ++CREATE TABLE t(a INT) engine=InnoDB; |
525 | ++# Disconnecting (passing to Slow Query Log "# administrative command: Quit") |
526 | ++[log_stop.inc] percona.slow_extended.error_on_quit |
527 | ++################################################################################ |
528 | ++[log_grep.inc] file: percona.slow_extended.error_on_quit pattern: CREATE |
529 | ++[log_grep.inc] lines: 1 |
530 | ++[log_grep.inc] file: percona.slow_extended.error_on_quit pattern: INSERT |
531 | ++[log_grep.inc] lines: 0 |
532 | ++[log_grep.inc] file: percona.slow_extended.error_on_quit pattern: SELECT |
533 | ++[log_grep.inc] lines: 0 |
534 | ++[log_grep.inc] file: percona.slow_extended.error_on_quit pattern: Quit |
535 | ++[log_grep.inc] lines: 1 |
536 | ++[log_grep.inc] file: percona.slow_extended.error_on_quit pattern: Last_errno: [^0]+ |
537 | ++[log_grep.inc] lines: 1 |
538 | ++[log_grep.inc] file: percona.slow_extended.error_on_quit pattern: Last_errno: 0 |
539 | ++[log_grep.inc] lines: 2 |
540 | ++[log_grep.inc] file: percona.slow_extended.error_on_quit pattern: Rows_sent: [^0]+ |
541 | ++[log_grep.inc] lines: 0 |
542 | ++[log_grep.inc] file: percona.slow_extended.error_on_quit pattern: Rows_sent: 0 |
543 | ++[log_grep.inc] lines: 3 |
544 | ++[log_grep.inc] file: percona.slow_extended.error_on_quit pattern: Rows_examined: [^0]+ |
545 | ++[log_grep.inc] lines: 0 |
546 | ++[log_grep.inc] file: percona.slow_extended.error_on_quit pattern: Rows_examined: 0 |
547 | ++[log_grep.inc] lines: 3 |
548 | ++[log_grep.inc] file: percona.slow_extended.error_on_quit pattern: Rows_affected: [^0]+ |
549 | ++[log_grep.inc] lines: 0 |
550 | ++[log_grep.inc] file: percona.slow_extended.error_on_quit pattern: Rows_affected: 0 |
551 | ++[log_grep.inc] lines: 3 |
552 | ++[log_grep.inc] file: percona.slow_extended.error_on_quit pattern: Rows_read: [^0]+ |
553 | ++[log_grep.inc] lines: 0 |
554 | ++[log_grep.inc] file: percona.slow_extended.error_on_quit pattern: Rows_read: 0 |
555 | ++[log_grep.inc] lines: 3 |
556 | ++[log_grep.inc] file: percona.slow_extended.error_on_quit pattern: Bytes_sent: [^0]+ |
557 | ++[log_grep.inc] lines: 2 |
558 | ++[log_grep.inc] file: percona.slow_extended.error_on_quit pattern: Bytes_sent: 0 |
559 | ++[log_grep.inc] lines: 1 |
560 | ++[log_grep.inc] file: percona.slow_extended.error_on_quit pattern: Tmp_tables: [^0]+ |
561 | ++[log_grep.inc] lines: 0 |
562 | ++[log_grep.inc] file: percona.slow_extended.error_on_quit pattern: Tmp_tables: 0 |
563 | ++[log_grep.inc] lines: 3 |
564 | ++[log_grep.inc] file: percona.slow_extended.error_on_quit pattern: Tmp_disk_tables: [^0]+ |
565 | ++[log_grep.inc] lines: 0 |
566 | ++[log_grep.inc] file: percona.slow_extended.error_on_quit pattern: Tmp_disk_tables: 0 |
567 | ++[log_grep.inc] lines: 3 |
568 | ++[log_grep.inc] file: percona.slow_extended.error_on_quit pattern: Tmp_table_sizes: [^0]+ |
569 | ++[log_grep.inc] lines: 0 |
570 | ++[log_grep.inc] file: percona.slow_extended.error_on_quit pattern: Tmp_table_sizes: 0 |
571 | ++[log_grep.inc] lines: 3 |
572 | ++[log_grep.inc] file: percona.slow_extended.error_on_quit pattern: # No InnoDB statistics available for this query |
573 | ++[log_grep.inc] lines: 2 |
574 | ++[log_grep.inc] file: percona.slow_extended.error_on_quit pattern: # InnoDB_trx_id: |
575 | ++[log_grep.inc] lines: 1 |
576 | ++################################################################################ |
577 | ++[log_start.inc] percona.slow_extended.error_on_quit |
578 | ++SET log_slow_verbosity=innodb; |
579 | ++SET long_query_time= 0; |
580 | ++INSERT INTO t SELECT * FROM t ORDER BY RAND(); |
581 | ++# Disconnecting (passing to Slow Query Log "# administrative command: Quit") |
582 | ++[log_stop.inc] percona.slow_extended.error_on_quit |
583 | ++################################################################################ |
584 | ++[log_grep.inc] file: percona.slow_extended.error_on_quit pattern: CREATE |
585 | ++[log_grep.inc] lines: 0 |
586 | ++[log_grep.inc] file: percona.slow_extended.error_on_quit pattern: INSERT |
587 | ++[log_grep.inc] lines: 1 |
588 | ++[log_grep.inc] file: percona.slow_extended.error_on_quit pattern: SELECT |
589 | ++[log_grep.inc] lines: 1 |
590 | ++[log_grep.inc] file: percona.slow_extended.error_on_quit pattern: Quit |
591 | ++[log_grep.inc] lines: 1 |
592 | ++[log_grep.inc] file: percona.slow_extended.error_on_quit pattern: Last_errno: [^0]+ |
593 | ++[log_grep.inc] lines: 0 |
594 | ++[log_grep.inc] file: percona.slow_extended.error_on_quit pattern: Last_errno: 0 |
595 | ++[log_grep.inc] lines: 3 |
596 | ++[log_grep.inc] file: percona.slow_extended.error_on_quit pattern: Rows_sent: [^0]+ |
597 | ++[log_grep.inc] lines: 0 |
598 | ++[log_grep.inc] file: percona.slow_extended.error_on_quit pattern: Rows_sent: 0 |
599 | ++[log_grep.inc] lines: 3 |
600 | ++[log_grep.inc] file: percona.slow_extended.error_on_quit pattern: Rows_examined: [^0]+ |
601 | ++[log_grep.inc] lines: 1 |
602 | ++[log_grep.inc] file: percona.slow_extended.error_on_quit pattern: Rows_examined: 0 |
603 | ++[log_grep.inc] lines: 2 |
604 | ++[log_grep.inc] file: percona.slow_extended.error_on_quit pattern: Rows_affected: [^0]+ |
605 | ++[log_grep.inc] lines: 2 |
606 | ++[log_grep.inc] file: percona.slow_extended.error_on_quit pattern: Rows_affected: 0 |
607 | ++[log_grep.inc] lines: 1 |
608 | ++[log_grep.inc] file: percona.slow_extended.error_on_quit pattern: Rows_read: [^0]+ |
609 | ++[log_grep.inc] lines: 0 |
610 | ++[log_grep.inc] file: percona.slow_extended.error_on_quit pattern: Rows_read: 0 |
611 | ++[log_grep.inc] lines: 3 |
612 | ++[log_grep.inc] file: percona.slow_extended.error_on_quit pattern: Bytes_sent: [^0]+ |
613 | ++[log_grep.inc] lines: 2 |
614 | ++[log_grep.inc] file: percona.slow_extended.error_on_quit pattern: Bytes_sent: 0 |
615 | ++[log_grep.inc] lines: 1 |
616 | ++[log_grep.inc] file: percona.slow_extended.error_on_quit pattern: Tmp_tables: [^0]+ |
617 | ++[log_grep.inc] lines: 1 |
618 | ++[log_grep.inc] file: percona.slow_extended.error_on_quit pattern: Tmp_tables: 0 |
619 | ++[log_grep.inc] lines: 2 |
620 | ++[log_grep.inc] file: percona.slow_extended.error_on_quit pattern: Tmp_disk_tables: [^0]+ |
621 | ++[log_grep.inc] lines: 0 |
622 | ++[log_grep.inc] file: percona.slow_extended.error_on_quit pattern: Tmp_disk_tables: 0 |
623 | ++[log_grep.inc] lines: 3 |
624 | ++[log_grep.inc] file: percona.slow_extended.error_on_quit pattern: Tmp_table_sizes: [^0]+ |
625 | ++[log_grep.inc] lines: 1 |
626 | ++[log_grep.inc] file: percona.slow_extended.error_on_quit pattern: Tmp_table_sizes: 0 |
627 | ++[log_grep.inc] lines: 2 |
628 | ++[log_grep.inc] file: percona.slow_extended.error_on_quit pattern: # No InnoDB statistics available for this query |
629 | ++[log_grep.inc] lines: 2 |
630 | ++[log_grep.inc] file: percona.slow_extended.error_on_quit pattern: # InnoDB_trx_id: |
631 | ++[log_grep.inc] lines: 1 |
632 | ++################################################################################ |
633 | ++[log_start.inc] percona.slow_extended.error_on_quit |
634 | ++SET log_slow_verbosity=innodb; |
635 | ++SET long_query_time= 0; |
636 | ++SELECT * FROM t; |
637 | ++# Disconnecting (passing to Slow Query Log "# administrative command: Quit") |
638 | ++[log_stop.inc] percona.slow_extended.error_on_quit |
639 | ++################################################################################ |
640 | ++[log_grep.inc] file: percona.slow_extended.error_on_quit pattern: CREATE |
641 | ++[log_grep.inc] lines: 0 |
642 | ++[log_grep.inc] file: percona.slow_extended.error_on_quit pattern: INSERT |
643 | ++[log_grep.inc] lines: 0 |
644 | ++[log_grep.inc] file: percona.slow_extended.error_on_quit pattern: SELECT |
645 | ++[log_grep.inc] lines: 1 |
646 | ++[log_grep.inc] file: percona.slow_extended.error_on_quit pattern: Quit |
647 | ++[log_grep.inc] lines: 1 |
648 | ++[log_grep.inc] file: percona.slow_extended.error_on_quit pattern: Last_errno: [^0]+ |
649 | ++[log_grep.inc] lines: 0 |
650 | ++[log_grep.inc] file: percona.slow_extended.error_on_quit pattern: Last_errno: 0 |
651 | ++[log_grep.inc] lines: 3 |
652 | ++[log_grep.inc] file: percona.slow_extended.error_on_quit pattern: Rows_sent: [^0]+ |
653 | ++[log_grep.inc] lines: 1 |
654 | ++[log_grep.inc] file: percona.slow_extended.error_on_quit pattern: Rows_sent: 0 |
655 | ++[log_grep.inc] lines: 2 |
656 | ++[log_grep.inc] file: percona.slow_extended.error_on_quit pattern: Rows_examined: [^0]+ |
657 | ++[log_grep.inc] lines: 1 |
658 | ++[log_grep.inc] file: percona.slow_extended.error_on_quit pattern: Rows_examined: 0 |
659 | ++[log_grep.inc] lines: 2 |
660 | ++[log_grep.inc] file: percona.slow_extended.error_on_quit pattern: Rows_affected: [^0]+ |
661 | ++[log_grep.inc] lines: 0 |
662 | ++[log_grep.inc] file: percona.slow_extended.error_on_quit pattern: Rows_affected: 0 |
663 | ++[log_grep.inc] lines: 3 |
664 | ++[log_grep.inc] file: percona.slow_extended.error_on_quit pattern: Rows_read: [^0]+ |
665 | ++[log_grep.inc] lines: 1 |
666 | ++[log_grep.inc] file: percona.slow_extended.error_on_quit pattern: Rows_read: 0 |
667 | ++[log_grep.inc] lines: 2 |
668 | ++[log_grep.inc] file: percona.slow_extended.error_on_quit pattern: Bytes_sent: [^0]+ |
669 | ++[log_grep.inc] lines: 2 |
670 | ++[log_grep.inc] file: percona.slow_extended.error_on_quit pattern: Bytes_sent: 0 |
671 | ++[log_grep.inc] lines: 1 |
672 | ++[log_grep.inc] file: percona.slow_extended.error_on_quit pattern: Tmp_tables: [^0]+ |
673 | ++[log_grep.inc] lines: 0 |
674 | ++[log_grep.inc] file: percona.slow_extended.error_on_quit pattern: Tmp_tables: 0 |
675 | ++[log_grep.inc] lines: 3 |
676 | ++[log_grep.inc] file: percona.slow_extended.error_on_quit pattern: Tmp_disk_tables: [^0]+ |
677 | ++[log_grep.inc] lines: 0 |
678 | ++[log_grep.inc] file: percona.slow_extended.error_on_quit pattern: Tmp_disk_tables: 0 |
679 | ++[log_grep.inc] lines: 3 |
680 | ++[log_grep.inc] file: percona.slow_extended.error_on_quit pattern: Tmp_table_sizes: [^0]+ |
681 | ++[log_grep.inc] lines: 0 |
682 | ++[log_grep.inc] file: percona.slow_extended.error_on_quit pattern: Tmp_table_sizes: 0 |
683 | ++[log_grep.inc] lines: 3 |
684 | ++[log_grep.inc] file: percona.slow_extended.error_on_quit pattern: # No InnoDB statistics available for this query |
685 | ++[log_grep.inc] lines: 2 |
686 | ++[log_grep.inc] file: percona.slow_extended.error_on_quit pattern: # InnoDB_trx_id: |
687 | ++[log_grep.inc] lines: 1 |
688 | ++################################################################################ |
689 | +--- /dev/null |
690 | ++++ b/mysql-test/include/percona_slow_extended_error_on_quit.inc |
691 | +@@ -0,0 +1,50 @@ |
692 | ++--echo ################################################################################ |
693 | ++--let grep_pattern=CREATE |
694 | ++--source include/log_grep.inc |
695 | ++--let grep_pattern=INSERT |
696 | ++--source include/log_grep.inc |
697 | ++--let grep_pattern=SELECT |
698 | ++--source include/log_grep.inc |
699 | ++--let grep_pattern=Quit |
700 | ++--source include/log_grep.inc |
701 | ++--let grep_pattern=Last_errno: [^0]+ |
702 | ++--source include/log_grep.inc |
703 | ++--let grep_pattern=Last_errno: 0 |
704 | ++--source include/log_grep.inc |
705 | ++--let grep_pattern=Rows_sent: [^0]+ |
706 | ++--source include/log_grep.inc |
707 | ++--let grep_pattern=Rows_sent: 0 |
708 | ++--source include/log_grep.inc |
709 | ++--let grep_pattern=Rows_examined: [^0]+ |
710 | ++--source include/log_grep.inc |
711 | ++--let grep_pattern=Rows_examined: 0 |
712 | ++--source include/log_grep.inc |
713 | ++--let grep_pattern=Rows_affected: [^0]+ |
714 | ++--source include/log_grep.inc |
715 | ++--let grep_pattern=Rows_affected: 0 |
716 | ++--source include/log_grep.inc |
717 | ++--let grep_pattern=Rows_read: [^0]+ |
718 | ++--source include/log_grep.inc |
719 | ++--let grep_pattern=Rows_read: 0 |
720 | ++--source include/log_grep.inc |
721 | ++--let grep_pattern=Bytes_sent: [^0]+ |
722 | ++--source include/log_grep.inc |
723 | ++--let grep_pattern=Bytes_sent: 0 |
724 | ++--source include/log_grep.inc |
725 | ++--let grep_pattern=Tmp_tables: [^0]+ |
726 | ++--source include/log_grep.inc |
727 | ++--let grep_pattern=Tmp_tables: 0 |
728 | ++--source include/log_grep.inc |
729 | ++--let grep_pattern=Tmp_disk_tables: [^0]+ |
730 | ++--source include/log_grep.inc |
731 | ++--let grep_pattern=Tmp_disk_tables: 0 |
732 | ++--source include/log_grep.inc |
733 | ++--let grep_pattern=Tmp_table_sizes: [^0]+ |
734 | ++--source include/log_grep.inc |
735 | ++--let grep_pattern=Tmp_table_sizes: 0 |
736 | ++--source include/log_grep.inc |
737 | ++--let grep_pattern=# No InnoDB statistics available for this query |
738 | ++--source include/log_grep.inc |
739 | ++--let grep_pattern=# InnoDB_trx_id: |
740 | ++--source include/log_grep.inc |
741 | ++--echo ################################################################################ |
http:// jenkins. percona. com/view/ Percona% 20Server% 205.1/job/ percona- server- 5.1-param/ 133/