Merge lp:~tsarev/percona-server/5.5_fix_bug_688646 into lp:percona-server/5.5
- 5.5_fix_bug_688646
- Merge into 5.5
Proposed by
Oleg Tsarev
Status: | Superseded | ||||
---|---|---|---|---|---|
Proposed branch: | lp:~tsarev/percona-server/5.5_fix_bug_688646 | ||||
Merge into: | lp:percona-server/5.5 | ||||
Diff against target: |
775 lines (+373/-55) 3 files modified
doc/source/diagnostics/slow_extended_55.rst (+32/-4) patches/mysql-test.diff (+5/-12) patches/slow_extended.patch (+336/-39) |
||||
To merge this branch: | bzr merge lp:~tsarev/percona-server/5.5_fix_bug_688646 | ||||
Related bugs: |
|
||||
Related blueprints: |
Make query sampling possible by query
(Undefined)
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Laurynas Biveinis (community) | Needs Fixing | ||
Review via email: mp+86145@code.launchpad.net |
This proposal has been superseded by a proposal from 2012-01-29.
Commit message
Description of the change
http://
Added implementation of #688646 (Made possible query sampling by query), tests and documentation for it.
To post a comment you must log in.
Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote : | # |
review:
Needs Fixing
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'doc/source/diagnostics/slow_extended_55.rst' |
2 | --- doc/source/diagnostics/slow_extended_55.rst 2011-10-07 23:38:41 +0000 |
3 | +++ doc/source/diagnostics/slow_extended_55.rst 2012-01-29 07:52:23 +0000 |
4 | @@ -67,6 +67,18 @@ |
5 | |
6 | For example, to log only queries that perform a full table scan, set the value to ``full_scan``. To log only queries that use on-disk temporary storage for intermediate results, set the value to ``tmp_table_on_disk,filesort_on_disk``. |
7 | |
8 | +.. variable:: log_slow_rate_type |
9 | + |
10 | + :cli: Yes |
11 | + :conf: Yes |
12 | + :scope: Global |
13 | + :dyn: Yes |
14 | + :vartype: Enumerated |
15 | + :default: ``session`` |
16 | + :range: ``session``, ``query`` |
17 | + |
18 | +Specifies semantic of :variable:`log_slow_rate_limit` - ``session`` or ``query``. |
19 | + |
20 | .. variable:: log_slow_rate_limit |
21 | |
22 | :cli: Yes |
23 | @@ -74,10 +86,26 @@ |
24 | :scope: Global, session |
25 | :dyn: Yes |
26 | |
27 | -Specifies that only a fraction of sessions should be logged. Logging is enabled for every nth session. By default, n is 1, so logging is enabled for every session. Rate limiting is disabled for the replication thread. |
28 | - |
29 | -Logging all queries might consume I/O bandwidth and cause the log file to grow large. This option lets you log full sessions, so you have complete records of sessions for later analysis; but you can rate-limit the number of sessions that are logged. For example, if you set the value to 100, then one percent of sessions will be logged in their entirety. Note that this feature will not work well if your application uses any type of connection pooling or persistent connections. |
30 | - |
31 | +Behavior of this variable depends from :variable:`log_slow_rate_type`. |
32 | + |
33 | +Specifies that only a fraction of ``session/query`` should be logged. Logging is enabled for every nth ``session/query``. By default, n is 1, so logging is enabled for every ``session/query``. Please note: when :variable:`log_slow_rate_type` is ``session`` rate limiting is disabled for the replication thread. |
34 | + |
35 | +Logging all queries might consume I/O bandwidth and cause the log file to grow large. |
36 | + * When :variable:`log_slow_rate_type` is ``session``, this option lets you log full sessions, so you have complete records of sessions for later analysis; but you can rate-limit the number of sessions that are logged. Note that this feature will not work well if your application uses any type of connection pooling or persistent connections. |
37 | + Note that you change :variable:`log_slow_rate_limit` in ``session`` mode, you should reconnect for get effect. |
38 | + |
39 | + * When :variable:`log_slow_rate_type` is ``query``, this option lets you log just some queries for later analysis. For example, if you set the value to 100, then one percona of queryies will logged. |
40 | + |
41 | +Note that every query has global unique ``query_id`` and every connection can has it own (session) :variable:``log_slow_rate_limit`. |
42 | +Decision "log or no" calculated in following manner: |
43 | + |
44 | + * if ``log_slow_rate_limit`` is 0 - log every query |
45 | + |
46 | + * If ``log_slow_rate_limit`` > 0 - log query when (``query_id`` % ``log_slow_rate_limit``) is zero. |
47 | + |
48 | +This allows flexible setup logging behavior. |
49 | + |
50 | +For example, if you set the value to 100, then one percent of ``sessions/queries`` will be logged. |
51 | |
52 | .. variable:: log_slow_slave_statements |
53 | |
54 | |
55 | === modified file 'patches/mysql-test.diff' |
56 | --- patches/mysql-test.diff 2012-01-10 11:28:15 +0000 |
57 | +++ patches/mysql-test.diff 2012-01-29 07:52:23 +0000 |
58 | @@ -749,12 +749,6 @@ |
59 | +@@global.log_slow_filter |
60 | + |
61 | --- /dev/null |
62 | -+++ b/mysql-test/suite/sys_vars/r/log_slow_rate_limit_basic.result |
63 | -@@ -0,0 +1,3 @@ |
64 | -+SELECT @@global.log_slow_rate_limit; |
65 | -+@@global.log_slow_rate_limit |
66 | -+1 |
67 | ---- /dev/null |
68 | +++ b/mysql-test/suite/sys_vars/r/log_slow_slave_statements_basic.result |
69 | @@ -0,0 +1,3 @@ |
70 | +SELECT @@global.log_slow_slave_statements; |
71 | @@ -943,10 +937,6 @@ |
72 | @@ -0,0 +1 @@ |
73 | +SELECT @@global.log_slow_filter; |
74 | --- /dev/null |
75 | -+++ b/mysql-test/suite/sys_vars/t/log_slow_rate_limit_basic.test |
76 | -@@ -0,0 +1 @@ |
77 | -+SELECT @@global.log_slow_rate_limit; |
78 | ---- /dev/null |
79 | +++ b/mysql-test/suite/sys_vars/t/log_slow_slave_statements_basic.test |
80 | @@ -0,0 +1 @@ |
81 | +SELECT @@global.log_slow_slave_statements; |
82 | @@ -1050,7 +1040,7 @@ |
83 | +SELECT Variable_name FROM INFORMATION_SCHEMA.SESSION_VARIABLES ORDER BY 1; |
84 | --- /dev/null |
85 | +++ b/mysql-test/r/percona_server_variables_debug.result |
86 | -@@ -0,0 +1,382 @@ |
87 | +@@ -0,0 +1,384 @@ |
88 | +SELECT Variable_name FROM INFORMATION_SCHEMA.SESSION_VARIABLES ORDER BY 1; |
89 | +Variable_name |
90 | +AUTOCOMMIT |
91 | @@ -1252,6 +1242,7 @@ |
92 | +LOG_SLOW_FILTER |
93 | +LOG_SLOW_QUERIES |
94 | +LOG_SLOW_RATE_LIMIT |
95 | ++LOG_SLOW_RATE_TYPE |
96 | +LOG_SLOW_SLAVE_STATEMENTS |
97 | +LOG_SLOW_SP_STATEMENTS |
98 | +LOG_SLOW_VERBOSITY |
99 | @@ -1338,6 +1329,7 @@ |
100 | +QUERY_CACHE_STRIP_COMMENTS |
101 | +QUERY_CACHE_TYPE |
102 | +QUERY_CACHE_WLOCK_INVALIDATE |
103 | ++QUERY_EXEC_ID |
104 | +QUERY_EXEC_TIME |
105 | +QUERY_PREALLOC_SIZE |
106 | +QUERY_RESPONSE_TIME_RANGE_BASE |
107 | @@ -1435,7 +1427,7 @@ |
108 | +WARNING_COUNT |
109 | --- /dev/null |
110 | +++ b/mysql-test/r/percona_server_variables_release.result |
111 | -@@ -0,0 +1,377 @@ |
112 | +@@ -0,0 +1,378 @@ |
113 | +SELECT Variable_name FROM INFORMATION_SCHEMA.SESSION_VARIABLES ORDER BY 1; |
114 | +Variable_name |
115 | +AUTOCOMMIT |
116 | @@ -1633,6 +1625,7 @@ |
117 | +LOG_SLOW_FILTER |
118 | +LOG_SLOW_QUERIES |
119 | +LOG_SLOW_RATE_LIMIT |
120 | ++LOG_SLOW_RATE_TYPE |
121 | +LOG_SLOW_SLAVE_STATEMENTS |
122 | +LOG_SLOW_SP_STATEMENTS |
123 | +LOG_SLOW_VERBOSITY |
124 | |
125 | === modified file 'patches/slow_extended.patch' |
126 | --- patches/slow_extended.patch 2011-12-27 15:32:16 +0000 |
127 | +++ patches/slow_extended.patch 2012-01-29 07:52:23 +0000 |
128 | @@ -411,7 +411,7 @@ |
129 | ulonglong lock_utime, bool is_command, |
130 | --- a/sql/mysqld.cc |
131 | +++ b/sql/mysqld.cc |
132 | -@@ -421,6 +421,10 @@ |
133 | +@@ -421,6 +421,11 @@ |
134 | char* opt_secure_file_priv; |
135 | my_bool opt_log_slow_admin_statements= 0; |
136 | my_bool opt_log_slow_slave_statements= 0; |
137 | @@ -419,10 +419,11 @@ |
138 | +my_bool opt_slow_query_log_timestamp_always= 0; |
139 | +ulonglong opt_slow_query_log_use_global_control= 0; |
140 | +ulong opt_slow_query_log_timestamp_precision= 0; |
141 | ++ulong opt_slow_query_log_rate_type= 0; |
142 | my_bool lower_case_file_system= 0; |
143 | my_bool opt_large_pages= 0; |
144 | my_bool opt_super_large_pages= 0; |
145 | -@@ -5892,14 +5896,10 @@ |
146 | +@@ -5892,14 +5897,10 @@ |
147 | "Don't log extra information to update and slow-query logs.", |
148 | &opt_short_log_format, &opt_short_log_format, |
149 | 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, |
150 | @@ -439,7 +440,7 @@ |
151 | {"log-slow-queries", OPT_SLOW_QUERY_LOG, |
152 | "Log slow queries to a table or log file. Defaults logging to table " |
153 | "mysql.slow_log or hostname-slow.log if --log-output=file is used. " |
154 | -@@ -7288,6 +7288,10 @@ |
155 | +@@ -7288,6 +7289,10 @@ |
156 | |
157 | C_MODE_END |
158 | |
159 | @@ -450,7 +451,7 @@ |
160 | /** |
161 | Get server options from the command line, |
162 | and perform related server initializations. |
163 | -@@ -7437,6 +7441,8 @@ |
164 | +@@ -7437,6 +7442,8 @@ |
165 | global_system_variables.long_query_time= (ulonglong) |
166 | (global_system_variables.long_query_time_double * 1e6); |
167 | |
168 | @@ -461,7 +462,7 @@ |
169 | |
170 | --- a/sql/mysqld.h |
171 | +++ b/sql/mysqld.h |
172 | -@@ -116,6 +116,10 @@ |
173 | +@@ -116,6 +116,11 @@ |
174 | extern char* opt_secure_backup_file_priv; |
175 | extern size_t opt_secure_backup_file_priv_len; |
176 | extern my_bool opt_log_slow_admin_statements, opt_log_slow_slave_statements; |
177 | @@ -469,6 +470,7 @@ |
178 | +extern my_bool opt_slow_query_log_timestamp_always; |
179 | +extern ulonglong opt_slow_query_log_use_global_control; |
180 | +extern ulong opt_slow_query_log_timestamp_precision; |
181 | ++extern ulong opt_slow_query_log_rate_type; |
182 | extern my_bool sp_automatic_privileges, opt_noacl; |
183 | extern my_bool opt_old_style_user_limits, trust_function_creators; |
184 | extern uint opt_crash_binlog_innodb; |
185 | @@ -681,9 +683,52 @@ |
186 | DBUG_VOID_RETURN; |
187 | } |
188 | |
189 | +@@ -3802,7 +3896,7 @@ |
190 | + { |
191 | + mysql_mutex_lock(&LOCK_thd_data); |
192 | + set_query_inner(query_arg, query_length_arg, cs); |
193 | +- query_id= new_query_id; |
194 | ++ do_set_query_id(new_query_id); |
195 | + mysql_mutex_unlock(&LOCK_thd_data); |
196 | + } |
197 | + |
198 | +@@ -3811,9 +3905,32 @@ |
199 | + void THD::set_query_id(query_id_t new_query_id) |
200 | + { |
201 | + mysql_mutex_lock(&LOCK_thd_data); |
202 | +- query_id= new_query_id; |
203 | ++ do_set_query_id(new_query_id); |
204 | + mysql_mutex_unlock(&LOCK_thd_data); |
205 | + } |
206 | ++void THD::do_set_query_id(query_id_t new_query_id) |
207 | ++{ |
208 | ++#ifndef DBUG_OFF |
209 | ++ if (variables.query_exec_id != 0 && |
210 | ++ lex->sql_command != SQLCOM_SET_OPTION) |
211 | ++ { |
212 | ++ new_query_id= variables.query_exec_id; |
213 | ++ } |
214 | ++#endif /* DBUG_OFF */ |
215 | ++ query_id= new_query_id; |
216 | ++ if (opt_slow_query_log_rate_type == SLOG_RT_QUERY) |
217 | ++ { |
218 | ++ if ((variables.log_slow_rate_limit == 0) || |
219 | ++ (query_id % variables.log_slow_rate_limit) == 0) |
220 | ++ { |
221 | ++ write_to_slow_log= TRUE; |
222 | ++ } |
223 | ++ else |
224 | ++ { |
225 | ++ write_to_slow_log= FALSE; |
226 | ++ } |
227 | ++ } |
228 | ++} |
229 | + |
230 | + /** Assign a new value to thd->mysys_var. */ |
231 | + void THD::set_mysys_var(struct st_my_thread_var *new_mysys_var) |
232 | --- a/sql/sql_class.h |
233 | +++ b/sql/sql_class.h |
234 | -@@ -60,6 +60,33 @@ |
235 | +@@ -60,6 +60,36 @@ |
236 | enum enum_duplicates { DUP_ERROR, DUP_REPLACE, DUP_UPDATE }; |
237 | enum enum_delay_key_write { DELAY_KEY_WRITE_NONE, DELAY_KEY_WRITE_ON, |
238 | DELAY_KEY_WRITE_ALL }; |
239 | @@ -700,6 +745,9 @@ |
240 | +enum enum_slow_query_log_timestamp_precision { |
241 | + SLOG_SECOND, SLOG_MICROSECOND |
242 | +}; |
243 | ++enum enum_slow_query_log_rate_type { |
244 | ++ SLOG_RT_SESSION, SLOG_RT_QUERY |
245 | ++}; |
246 | +#define QPLAN_NONE 0 |
247 | +#define QPLAN_QC 1 << 0 |
248 | +#define QPLAN_QC_NO 1 << 1 |
249 | @@ -717,13 +765,14 @@ |
250 | enum enum_slave_exec_mode { SLAVE_EXEC_MODE_STRICT, |
251 | SLAVE_EXEC_MODE_IDEMPOTENT, |
252 | SLAVE_EXEC_MODE_LAST_BIT}; |
253 | -@@ -506,6 +533,21 @@ |
254 | +@@ -508,6 +538,22 @@ |
255 | |
256 | my_bool sysdate_is_now; |
257 | |
258 | +#ifndef DBUG_OFF |
259 | + ulonglong query_exec_time; |
260 | + double query_exec_time_double; |
261 | ++ ulong query_exec_id; |
262 | +#endif |
263 | + ulong log_slow_rate_limit; |
264 | + ulonglong log_slow_filter; |
265 | @@ -739,7 +788,7 @@ |
266 | double long_query_time_double; |
267 | |
268 | } SV; |
269 | -@@ -1138,6 +1180,24 @@ |
270 | +@@ -1140,6 +1186,24 @@ |
271 | uint in_sub_stmt; |
272 | bool enable_slow_log; |
273 | bool last_insert_id_used; |
274 | @@ -764,7 +813,7 @@ |
275 | SAVEPOINT *savepoints; |
276 | enum enum_check_fields count_cuted_fields; |
277 | }; |
278 | -@@ -1586,6 +1646,71 @@ |
279 | +@@ -1588,6 +1652,71 @@ |
280 | thr_lock_type update_lock_default; |
281 | Delayed_insert *di; |
282 | |
283 | @@ -836,20 +885,36 @@ |
284 | /* <> 0 if we are inside of trigger or stored function. */ |
285 | uint in_sub_stmt; |
286 | |
287 | +@@ -2784,6 +2913,9 @@ |
288 | + void set_query_and_id(char *query_arg, uint32 query_length_arg, |
289 | + CHARSET_INFO *cs, query_id_t new_query_id); |
290 | + void set_query_id(query_id_t new_query_id); |
291 | ++private: |
292 | ++ void do_set_query_id(query_id_t new_query_id); |
293 | ++public: |
294 | + void set_open_tables(TABLE *open_tables_arg) |
295 | + { |
296 | + mysql_mutex_lock(&LOCK_thd_data); |
297 | --- a/sql/sql_connect.cc |
298 | +++ b/sql/sql_connect.cc |
299 | -@@ -721,6 +721,15 @@ |
300 | +@@ -721,6 +721,21 @@ |
301 | MYSQL_CONNECTION_START(thd->thread_id, &thd->security_ctx->priv_user[0], |
302 | (char *) thd->security_ctx->host_or_ip); |
303 | |
304 | -+ /* |
305 | ++ /* |
306 | + If rate limiting of slow log writes is enabled, decide whether to log this |
307 | -+ new thread's queries or not. Uses extremely simple algorithm. :) |
308 | -+ */ |
309 | -+ thd->write_to_slow_log= FALSE; |
310 | -+ if (thd->variables.log_slow_rate_limit <= 1 || |
311 | -+ (thd->thread_id % thd->variables.log_slow_rate_limit) == 0) |
312 | -+ thd->write_to_slow_log= TRUE; |
313 | ++ new thread's queries or not. Uses extremely simple algorithm. :) |
314 | ++ */ |
315 | ++ if (opt_slow_query_log_rate_type == SLOG_RT_SESSION && |
316 | ++ (thd->variables.log_slow_rate_limit == 0 || |
317 | ++ (thd->thread_id % thd->variables.log_slow_rate_limit) == 0)) |
318 | ++ { |
319 | ++ thd->write_to_slow_log= TRUE; |
320 | ++ } |
321 | ++ else |
322 | ++ { |
323 | ++ thd->write_to_slow_log= FALSE; |
324 | ++ } |
325 | + |
326 | prepare_new_connection_state(thd); |
327 | return FALSE; |
328 | @@ -1072,7 +1137,7 @@ |
329 | { |
330 | --- a/sql/sys_vars.cc |
331 | +++ b/sql/sys_vars.cc |
332 | -@@ -972,6 +972,29 @@ |
333 | +@@ -972,6 +972,36 @@ |
334 | NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), |
335 | ON_UPDATE(update_cached_long_query_time)); |
336 | |
337 | @@ -1097,12 +1162,19 @@ |
338 | + NO_CMD_LINE, VALID_RANGE(0, LONG_TIMEOUT), DEFAULT(0), |
339 | + NO_MUTEX_GUARD, IN_BINLOG, ON_CHECK(0), |
340 | + ON_UPDATE(update_cached_query_exec_time)); |
341 | ++static Sys_var_ulong sys_query_exec_id( |
342 | ++ "query_exec_id", |
343 | ++ "Pretend queries take this query id. When 0 (the default) use the" |
344 | ++ "actual query id. Used only for debugging.", |
345 | ++ SESSION_VAR(query_exec_id), |
346 | ++ NO_CMD_LINE, VALID_RANGE(0, ULONG_MAX), DEFAULT(0), BLOCK_SIZE(1), |
347 | ++ NO_MUTEX_GUARD, IN_BINLOG); |
348 | +#endif |
349 | + |
350 | static bool fix_low_prio_updates(sys_var *self, THD *thd, enum_var_type type) |
351 | { |
352 | if (type == OPT_SESSION) |
353 | -@@ -2904,6 +2927,123 @@ |
354 | +@@ -2898,6 +2928,134 @@ |
355 | DEFAULT(FALSE), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), |
356 | ON_UPDATE(fix_log_state)); |
357 | |
358 | @@ -1222,7 +1294,18 @@ |
359 | + "Log slow statements executed by stored procedure to the slow log if it is open. [second, microsecond]", |
360 | + GLOBAL_VAR(opt_slow_query_log_timestamp_precision), CMD_LINE(REQUIRED_ARG), |
361 | + slow_query_log_timestamp_precision_name, DEFAULT(SLOG_SECOND)); |
362 | -+ |
363 | ++ |
364 | ++const char* slow_query_log_rate_name[]= {"session", "query", 0}; |
365 | ++static Sys_var_enum Sys_slow_query_log_rate_type( |
366 | ++ "log_slow_rate_type", |
367 | ++ "Choose the log_slow_rate_limit behavior: session or query. " |
368 | ++ "When you choose 'session' - every %log_slow_rate_limit connection " |
369 | ++ "will be processed to slow query log. " |
370 | ++ "When you choose 'query' - every %log_slow_rate_limit query " |
371 | ++ "will be processed to slow query log. " |
372 | ++ "[session, query]", |
373 | ++ GLOBAL_VAR(opt_slow_query_log_rate_type), CMD_LINE(REQUIRED_ARG), |
374 | ++ slow_query_log_rate_name, DEFAULT(SLOG_RT_SESSION)); |
375 | /* Synonym of "slow_query_log" for consistency with SHOW VARIABLES output */ |
376 | static Sys_var_mybool Sys_log_slow( |
377 | "log_slow_queries", |
378 | @@ -1476,23 +1559,47 @@ |
379 | # endif /* HAVE_PROFILING */ |
380 | --- /dev/null |
381 | +++ b/mysql-test/include/log_grep.inc |
382 | -@@ -0,0 +1,17 @@ |
383 | -+--disable_query_log |
384 | +@@ -0,0 +1,41 @@ |
385 | +--echo [log_grep.inc] file: $log_file pattern: $grep_pattern |
386 | +perl; |
387 | + $log_file= $ENV{'log_file'}; |
388 | + $log_file_full_path= $ENV{'log_file_full_path'}; |
389 | -+ $grep_pattern= $ENV{'grep_pattern'}; |
390 | -+ |
391 | ++ $log_slow_rate_test= $ENV{'log_slow_rate_test'}; |
392 | + open(FILE, "$log_file_full_path") |
393 | + or die("Cannot open file $log_file_full_path: $!\n"); |
394 | + |
395 | -+ $lines = 0; |
396 | -+ while(<FILE>) { |
397 | -+ $lines++ if (/$grep_pattern/); |
398 | ++ if ($log_slow_rate_test) { |
399 | ++ $one= 0; |
400 | ++ $two= 0; |
401 | ++ $three= 0; |
402 | ++ while(<FILE>) { |
403 | ++ $one++ if(/'connection_one'/); |
404 | ++ $two++ if(/'connection_two'/); |
405 | ++ $three++ if(/'connection_three'/); |
406 | ++ } |
407 | ++ $sum= $one + $two + $three; |
408 | ++ $zero= 0; |
409 | ++ if ($one == 0) { |
410 | ++ $zero++; |
411 | ++ } |
412 | ++ if ($two == 0) { |
413 | ++ $zero++; |
414 | ++ } |
415 | ++ if ($three == 0) { |
416 | ++ $zero++; |
417 | ++ } |
418 | ++ print "[log_grep.inc] sum: $sum\n"; |
419 | ++ print "[log_grep.inc] zero: $zero\n"; |
420 | ++ } |
421 | ++ else { |
422 | ++ $grep_pattern= $ENV{'grep_pattern'}; |
423 | ++ $lines= 0; |
424 | ++ while(<FILE>) { |
425 | ++ $lines++ if (/$grep_pattern/); |
426 | ++ } |
427 | ++ print "[log_grep.inc] lines: $lines\n"; |
428 | + } |
429 | + close(FILE); |
430 | -+ print "[log_grep.inc] lines: $lines\n"; |
431 | +EOF |
432 | --- /dev/null |
433 | +++ b/mysql-test/include/log_start.inc |
434 | @@ -1513,7 +1620,6 @@ |
435 | +EVAL SET GLOBAL slow_query_log_file="$log_file_full_path"; |
436 | +SET GLOBAL slow_query_log=ON; |
437 | +--enable_query_log |
438 | -\ No newline at end of file |
439 | --- /dev/null |
440 | +++ b/mysql-test/include/log_stop.inc |
441 | @@ -0,0 +1,7 @@ |
442 | @@ -1559,7 +1665,7 @@ |
443 | +log_slow_filter full_join |
444 | --- /dev/null |
445 | +++ b/mysql-test/r/percona_log_slow_filter.result |
446 | -@@ -0,0 +1,15 @@ |
447 | +@@ -0,0 +1,16 @@ |
448 | +CREATE TABLE t(id INT PRIMARY KEY); |
449 | +INSERT INTO t VALUES(1); |
450 | +INSERT INTO t VALUES(2); |
451 | @@ -1575,6 +1681,7 @@ |
452 | +SET long_query_time=default; |
453 | +[log_grep.inc] file: percona.slow_extended.log_slow_filter pattern: Query_time |
454 | +[log_grep.inc] lines: 1 |
455 | ++DROP TABLE t; |
456 | --- /dev/null |
457 | +++ b/mysql-test/r/percona_log_slow_slave_statements-cl.result |
458 | @@ -0,0 +1,6 @@ |
459 | @@ -1586,7 +1693,7 @@ |
460 | +log_slow_slave_statements ON |
461 | --- /dev/null |
462 | +++ b/mysql-test/r/percona_log_slow_slave_statements-innodb.result |
463 | -@@ -0,0 +1,18 @@ |
464 | +@@ -0,0 +1,19 @@ |
465 | +include/master-slave.inc |
466 | +[connection master] |
467 | +DROP TABLE IF EXISTS t; |
468 | @@ -1604,10 +1711,11 @@ |
469 | +[log_stop.inc] percona.slow_extended.log_slow_slave_statements-innodb |
470 | +[log_grep.inc] file: percona.slow_extended.log_slow_slave_statements-innodb pattern: InnoDB_IO_r_ops |
471 | +[log_grep.inc] lines: 1 |
472 | ++DROP TABLE t; |
473 | +include/rpl_end.inc |
474 | --- /dev/null |
475 | +++ b/mysql-test/r/percona_log_slow_slave_statements.result |
476 | -@@ -0,0 +1,44 @@ |
477 | +@@ -0,0 +1,45 @@ |
478 | +include/master-slave.inc |
479 | +[connection master] |
480 | +DROP TABLE IF EXISTS t; |
481 | @@ -1651,6 +1759,7 @@ |
482 | +[log_grep.inc] lines: 0 |
483 | +[log_grep.inc] file: percona.slow_extended.log_slow_slave_statements pattern: INSERT INTO t VALUES \(7\) |
484 | +[log_grep.inc] lines: 1 |
485 | ++DROP TABLE t; |
486 | +include/rpl_end.inc |
487 | --- /dev/null |
488 | +++ b/mysql-test/r/percona_log_slow_sp_statements-cl.result |
489 | @@ -1663,7 +1772,7 @@ |
490 | +log_slow_sp_statements ON |
491 | --- /dev/null |
492 | +++ b/mysql-test/r/percona_log_slow_sp_statements.result |
493 | -@@ -0,0 +1,24 @@ |
494 | +@@ -0,0 +1,25 @@ |
495 | +SET long_query_time=1; |
496 | +SET GLOBAL log_slow_sp_statements=ON; |
497 | +SET SESSION query_exec_time=0.1; |
498 | @@ -1688,6 +1797,7 @@ |
499 | +SET long_query_time=default; |
500 | +[log_grep.inc] file: percona.slow_extended.log_slow_sp_statements pattern: Query_time |
501 | +[log_grep.inc] lines: 3 |
502 | ++DROP PROCEDURE test_f; |
503 | --- /dev/null |
504 | +++ b/mysql-test/r/percona_log_slow_verbosity-cl.result |
505 | @@ -0,0 +1,6 @@ |
506 | @@ -2373,7 +2483,7 @@ |
507 | +SHOW GLOBAL VARIABLES LIKE 'slow_query_log_use_global_control'; |
508 | --- /dev/null |
509 | +++ b/mysql-test/r/percona_min_examined_row_limit.result |
510 | -@@ -0,0 +1,34 @@ |
511 | +@@ -0,0 +1,35 @@ |
512 | +drop table if exists t; |
513 | +create table t(id INT PRIMARY KEY); |
514 | +insert into t values(1); |
515 | @@ -2408,6 +2518,7 @@ |
516 | +SET GLOBAL long_query_time=default; |
517 | +[log_grep.inc] file: percona.slow_extended.min_examined_row_limit pattern: Query_time |
518 | +[log_grep.inc] lines: 1 |
519 | ++DROP TABLE t; |
520 | --- /dev/null |
521 | +++ b/mysql-test/t/percona_min_examined_row_limit.test |
522 | @@ -0,0 +1,35 @@ |
523 | @@ -2516,7 +2627,7 @@ |
524 | +SET GLOBAL slow_query_log_use_global_control=default; |
525 | --- /dev/null |
526 | +++ b/mysql-test/r/percona_slow_extended_log_error.result |
527 | -@@ -0,0 +1,9 @@ |
528 | +@@ -0,0 +1,10 @@ |
529 | +SET long_query_time=0; |
530 | +DROP TABLE IF EXISTS t1; |
531 | +CREATE TABLE t(a INT); |
532 | @@ -2526,6 +2637,7 @@ |
533 | +[log_stop.inc] percona.slow_extended.log_error |
534 | +[log_grep.inc] file: percona.slow_extended.log_error pattern: Last_errno: 1050 |
535 | +[log_grep.inc] lines: 1 |
536 | ++DROP TABLE t; |
537 | --- /dev/null |
538 | +++ b/mysql-test/t/percona_slow_extended_log_error.test |
539 | @@ -0,0 +1,15 @@ |
540 | @@ -2695,7 +2807,7 @@ |
541 | +SELECT * FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME='log_slow_admin_statements'; |
542 | --- a/mysql-test/r/mysqld--help-notwin.result |
543 | +++ b/mysql-test/r/mysqld--help-notwin.result |
544 | -@@ -250,15 +250,31 @@ |
545 | +@@ -250,15 +250,38 @@ |
546 | --log-slow-admin-statements |
547 | Log slow OPTIMIZE, ANALYZE, ALTER and other |
548 | administrative statements to the slow log if it is open. |
549 | @@ -2713,6 +2825,13 @@ |
550 | + --log-slow-rate-limit=# |
551 | + Rate limit statement writes to slow log to only those |
552 | + from every (1/log_slow_rate_limit) session. |
553 | ++ --log-slow-rate-type=name |
554 | ++ Choose the log_slow_rate_limit behavior: session or |
555 | ++ query. When you choose 'session' - every |
556 | ++ %log_slow_rate_limit connection will be processed to slow |
557 | ++ query log. When you choose 'query' - every |
558 | ++ %log_slow_rate_limit query will be processed to slow |
559 | ++ query log. [session, query] |
560 | --log-slow-slave-statements |
561 | - Log slow statements executed by slave thread to the slow |
562 | - log if it is open. |
563 | @@ -2729,7 +2848,7 @@ |
564 | --log-tc=name Path to transaction coordinator log (used for |
565 | transactions that affect more than one storage engine, |
566 | when binary log is disabled). |
567 | -@@ -662,6 +678,18 @@ |
568 | +@@ -660,6 +683,18 @@ |
569 | Log slow queries to given log file. Defaults logging to |
570 | hostname-slow.log. Must be enabled to activate other slow |
571 | log options |
572 | @@ -2748,19 +2867,20 @@ |
573 | --socket=name Socket file to use for connection |
574 | --sort-buffer-size=# |
575 | Each thread that needs to do a sort allocates a buffer of |
576 | -@@ -819,7 +847,11 @@ |
577 | +@@ -817,7 +852,12 @@ |
578 | log-short-format FALSE |
579 | log-slave-updates FALSE |
580 | log-slow-admin-statements FALSE |
581 | +log-slow-filter |
582 | +log-slow-rate-limit 1 |
583 | ++log-slow-rate-type session |
584 | log-slow-slave-statements FALSE |
585 | +log-slow-sp-statements TRUE |
586 | +log-slow-verbosity |
587 | log-tc tc.log |
588 | log-tc-size 24576 |
589 | log-warnings 1 |
590 | -@@ -936,6 +968,9 @@ |
591 | +@@ -933,6 +973,9 @@ |
592 | slave-type-conversions |
593 | slow-launch-time 2 |
594 | slow-query-log FALSE |
595 | @@ -2770,3 +2890,180 @@ |
596 | sort-buffer-size 2097152 |
597 | sporadic-binlog-dump-fail FALSE |
598 | sql-mode |
599 | +--- /dev/null |
600 | ++++ b/mysql-test/r/percona_slow_query_log_rate.result |
601 | +@@ -0,0 +1,78 @@ |
602 | ++SET GLOBAL long_query_time=1; |
603 | ++SET GLOBAL log_slow_rate_type='session'; |
604 | ++SET GLOBAL log_slow_rate_limit=3; |
605 | ++[log_start.inc] percona.slow_extended.log_slow_rate_limit |
606 | ++SET SESSION query_exec_time=1.1; |
607 | ++SET SESSION query_exec_id=1; |
608 | ++SELECT 'connection_one'; |
609 | ++connection_one |
610 | ++connection_one |
611 | ++SET SESSION query_exec_time=1.1; |
612 | ++SET SESSION query_exec_id=2; |
613 | ++SELECT 'connection_two'; |
614 | ++connection_two |
615 | ++connection_two |
616 | ++SET SESSION query_exec_time=1.1; |
617 | ++SET SESSION query_exec_id=3; |
618 | ++SELECT 'connection_three'; |
619 | ++connection_three |
620 | ++connection_three |
621 | ++SET SESSION query_exec_time=1.1; |
622 | ++SET SESSION query_exec_id=4; |
623 | ++SELECT 'connection_one'; |
624 | ++connection_one |
625 | ++connection_one |
626 | ++SET SESSION query_exec_time=1.1; |
627 | ++SET SESSION query_exec_id=5; |
628 | ++SELECT 'connection_two'; |
629 | ++connection_two |
630 | ++connection_two |
631 | ++SET SESSION query_exec_time=1.1; |
632 | ++SET SESSION query_exec_id=6; |
633 | ++SELECT 'connection_three'; |
634 | ++connection_three |
635 | ++connection_three |
636 | ++[log_stop.inc] percona.slow_extended.log_slow_rate_limit |
637 | ++[log_grep.inc] file: percona.slow_extended.log_slow_rate_limit pattern: |
638 | ++[log_grep.inc] sum: 2 |
639 | ++[log_grep.inc] zero: 2 |
640 | ++SET GLOBAL log_slow_rate_type='query'; |
641 | ++SET GLOBAL log_slow_rate_limit=2; |
642 | ++[log_start.inc] percona.slow_extended.log_slow_rate_limit |
643 | ++SET SESSION query_exec_time=1.1; |
644 | ++SET SESSION query_exec_id=1; |
645 | ++SELECT 'connection_one'; |
646 | ++connection_one |
647 | ++connection_one |
648 | ++SET SESSION query_exec_time=1.1; |
649 | ++SET SESSION query_exec_id=2; |
650 | ++SELECT 'connection_two'; |
651 | ++connection_two |
652 | ++connection_two |
653 | ++SET SESSION query_exec_time=1.1; |
654 | ++SET SESSION query_exec_id=3; |
655 | ++SELECT 'connection_three'; |
656 | ++connection_three |
657 | ++connection_three |
658 | ++SET SESSION query_exec_time=1.1; |
659 | ++SET SESSION query_exec_id=4; |
660 | ++SELECT 'connection_one'; |
661 | ++connection_one |
662 | ++connection_one |
663 | ++SET SESSION query_exec_time=1.1; |
664 | ++SET SESSION query_exec_id=5; |
665 | ++SELECT 'connection_two'; |
666 | ++connection_two |
667 | ++connection_two |
668 | ++SET SESSION query_exec_time=1.1; |
669 | ++SET SESSION query_exec_id=6; |
670 | ++SELECT 'connection_three'; |
671 | ++connection_three |
672 | ++connection_three |
673 | ++[log_stop.inc] percona.slow_extended.log_slow_rate_limit |
674 | ++[log_grep.inc] file: percona.slow_extended.log_slow_rate_limit pattern: |
675 | ++[log_grep.inc] sum: 3 |
676 | ++[log_grep.inc] zero: 0 |
677 | ++SET GLOBAL long_query_time=default; |
678 | ++SET GLOBAL log_slow_rate_type=default; |
679 | ++SET GLOBAL log_slow_rate_limit=default; |
680 | +--- /dev/null |
681 | ++++ b/mysql-test/t/percona_slow_query_log_rate.test |
682 | +@@ -0,0 +1,16 @@ |
683 | ++--source include/have_debug.inc |
684 | ++--let log_file=percona.slow_extended.log_slow_rate_limit |
685 | ++ |
686 | ++SET GLOBAL long_query_time=1; |
687 | ++ |
688 | ++SET GLOBAL log_slow_rate_type='session'; |
689 | ++SET GLOBAL log_slow_rate_limit=3; |
690 | ++--source include/percona_slow_query_log_rate.inc |
691 | ++ |
692 | ++SET GLOBAL log_slow_rate_type='query'; |
693 | ++SET GLOBAL log_slow_rate_limit=2; |
694 | ++--source include/percona_slow_query_log_rate.inc |
695 | ++ |
696 | ++SET GLOBAL long_query_time=default; |
697 | ++SET GLOBAL log_slow_rate_type=default; |
698 | ++SET GLOBAL log_slow_rate_limit=default; |
699 | +--- /dev/null |
700 | ++++ b/mysql-test/suite/sys_vars/t/log_slow_rate_limit_basic.test |
701 | +@@ -0,0 +1 @@ |
702 | ++SELECT @@global.log_slow_rate_limit; |
703 | +--- /dev/null |
704 | ++++ b/mysql-test/suite/sys_vars/r/log_slow_rate_limit_basic.result |
705 | +@@ -0,0 +1,3 @@ |
706 | ++SELECT @@global.log_slow_rate_limit; |
707 | ++@@global.log_slow_rate_limit |
708 | ++1 |
709 | +--- /dev/null |
710 | ++++ b/mysql-test/suite/sys_vars/t/log_slow_rate_type_basic.test |
711 | +@@ -0,0 +1 @@ |
712 | ++SELECT @@global.log_slow_rate_type; |
713 | +--- /dev/null |
714 | ++++ b/mysql-test/suite/sys_vars/r/log_slow_rate_type_basic.result |
715 | +@@ -0,0 +1,3 @@ |
716 | ++SELECT @@global.log_slow_rate_type; |
717 | ++@@global.log_slow_rate_type |
718 | ++session |
719 | +--- /dev/null |
720 | ++++ b/mysql-test/include/percona_slow_query_log_rate.inc |
721 | +@@ -0,0 +1,42 @@ |
722 | ++--let wait_condition=SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST; |
723 | ++--connection default |
724 | ++--source include/log_start.inc |
725 | ++ |
726 | ++--connect (connection_one,localhost,root,,) |
727 | ++--connect (connection_two,localhost,root,,) |
728 | ++--connect (connection_three,localhost,root,,) |
729 | ++ |
730 | ++--let i=2 |
731 | ++--let k=1 |
732 | ++ |
733 | ++while($i) |
734 | ++{ |
735 | ++--connection connection_one |
736 | ++SET SESSION query_exec_time=1.1; |
737 | ++eval SET SESSION query_exec_id=$k; |
738 | ++inc $k; |
739 | ++SELECT 'connection_one'; |
740 | ++ |
741 | ++--connection connection_two |
742 | ++SET SESSION query_exec_time=1.1; |
743 | ++eval SET SESSION query_exec_id=$k; |
744 | ++inc $k; |
745 | ++SELECT 'connection_two'; |
746 | ++ |
747 | ++--connection connection_three |
748 | ++SET SESSION query_exec_time=1.1; |
749 | ++eval SET SESSION query_exec_id=$k; |
750 | ++inc $k; |
751 | ++SELECT 'connection_three'; |
752 | ++ |
753 | ++dec $i; |
754 | ++} |
755 | ++ |
756 | ++--connection default |
757 | ++--disconnect connection_one |
758 | ++--disconnect connection_two |
759 | ++--disconnect connection_three |
760 | ++--source include/wait_condition.inc |
761 | ++--source include/log_stop.inc |
762 | ++--let log_slow_rate_test=1 |
763 | ++--source include/log_grep.inc |
764 | +--- /dev/null |
765 | ++++ b/mysql-test/suite/sys_vars/r/query_exec_id_basic.result |
766 | +@@ -0,0 +1,2 @@ |
767 | ++SET GLOBAL query_exec_id=default; |
768 | ++SET SESSION query_exec_id=default; |
769 | +--- /dev/null |
770 | ++++ b/mysql-test/suite/sys_vars/t/query_exec_id_basic.test |
771 | +@@ -0,0 +1,4 @@ |
772 | ++--source include/have_debug.inc |
773 | ++ |
774 | ++SET GLOBAL query_exec_id=default; |
775 | ++SET SESSION query_exec_id=default; |
The commit message does not have a detailed change description.
The MP seems to contain unrelated changes to clean up better after the slow query log tests, please split into a separate MP (with a bugĀ #).
Why does log_grep.inc become aware of this feature?
Please rewrite if (CONDITION) foo= TRUE; else foo= FALSE; to foo= CONDITION;
The documentation and option description for help need a rewrite for clarity IMHO.
s/debussing/ debugging