Merge lp:~percona-dev/percona-server/release-5.1.52-12-bug643149 into lp:~percona-dev/percona-server/release-5.1.53

Proposed by Alexey Kopytov
Status: Merged
Approved by: Vadim Tkachenko
Approved revision: no longer in the source branch.
Merged at revision: 153
Proposed branch: lp:~percona-dev/percona-server/release-5.1.52-12-bug643149
Merge into: lp:~percona-dev/percona-server/release-5.1.53
Diff against target: 411 lines (+226/-47)
3 files modified
mysql-test/profiling_slow.patch/percona_bug643149.result (+16/-0)
mysql-test/profiling_slow.patch/percona_bug643149.test (+46/-0)
profiling_slow.patch (+164/-47)
To merge this branch: bzr merge lp:~percona-dev/percona-server/release-5.1.52-12-bug643149
Reviewer Review Type Date Requested Status
Vadim Tkachenko Approve
Fred Linhoss (community) documentation Approve
Percona Needs Information
Review via email: mp+41903@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Percona (percona-team) wrote :

looks good now

review: Approve
Revision history for this message
Percona (percona-team) wrote :

actually it requires documentation changes.
Assigned to Fred

review: Needs Information
Revision history for this message
Fred Linhoss (fred-linhoss) wrote :
review: Approve (documentation)
Revision history for this message
Vadim Tkachenko (vadim-tk) wrote :

approved

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'mysql-test/profiling_slow.patch'
2=== added file 'mysql-test/profiling_slow.patch/percona_bug643149.result'
3--- mysql-test/profiling_slow.patch/percona_bug643149.result 1970-01-01 00:00:00 +0000
4+++ mysql-test/profiling_slow.patch/percona_bug643149.result 2010-11-25 21:08:58 +0000
5@@ -0,0 +1,16 @@
6+SET @old_slow_query_log_file=@@global.slow_query_log_file;
7+SET GLOBAL slow_query_log=on;
8+SET LOCAL profiling_server=on;
9+SET LOCAL long_query_time=1;
10+SET GLOBAL slow_query_log_file='/Users/kaa/src/percona/release-5.1.52-12-bug643149/Percona-Server/mysql-test/var/percona_bug643149_slow.log';;
11+SELECT SLEEP(2);
12+SLEEP(2)
13+0
14+# Time: X X:X:X
15+# User@Host: root[root] @ localhost []
16+# Thread_id: X Schema: test Last_errno: X Killed: X
17+# Query_time: X.X Lock_time: X.X Rows_sent: X Rows_examined: X Rows_affected: X Rows_read: X
18+# Bytes_sent: X Tmp_tables: X Tmp_disk_tables: X Tmp_table_sizes: X
19+# Profile_starting: X.X Profile_starting_cpu: X.X Profile_checking_permissions: X.X Profile_checking_permissions_cpu: X.X Profile_Opening_tables: X.X Profile_Opening_tables_cpu: X.X Profile_init: X.X Profile_init_cpu: X.X Profile_optimizing: X.X Profile_optimizing_cpu: X.X Profile_executing: X.X Profile_executing_cpu: X.X Profile_User_sleep: X.X Profile_User_sleep_cpu: X.X Profile_end: X.X Profile_end_cpu: X.X Profile_query_end: X.X Profile_query_end_cpu: X.X Profile_freeing_items: X.X Profile_freeing_items_cpu: X.X Profile_logging_slow_query: X.X Profile_logging_slow_query_cpu: X.X
20+# Profile_total: X.X Profile_total_cpu: X.X
21+SET GLOBAL slow_query_log_file=@old_slow_query_log_file;
22
23=== added file 'mysql-test/profiling_slow.patch/percona_bug643149.test'
24--- mysql-test/profiling_slow.patch/percona_bug643149.test 1970-01-01 00:00:00 +0000
25+++ mysql-test/profiling_slow.patch/percona_bug643149.test 2010-11-25 21:08:58 +0000
26@@ -0,0 +1,46 @@
27+#
28+# This test suffers from server
29+# Bug#38124 "general_log_file" variable silently unset when using expression
30+# In short:
31+# SET GLOBAL general_log_file = @<whatever>
32+# SET GLOBAL slow_query_log = @<whatever>
33+# cause that the value of these server system variables is set to default
34+# instead of the assigned values. There comes no error message or warning.
35+# If this bug is fixed please
36+# 1. try this test with "let $fixed_bug38124 = 0;"
37+# 2. remove all workarounds if 1. was successful.
38+let $fixed_bug38124 = 0;
39+
40+SET @old_slow_query_log_file=@@global.slow_query_log_file;
41+SET GLOBAL slow_query_log=on;
42+SET LOCAL profiling_server=on;
43+SET LOCAL long_query_time=1;
44+
45+let slogfile=$MYSQLTEST_VARDIR/percona_bug643149_slow.log;
46+--eval SET GLOBAL slow_query_log_file='$slogfile';
47+
48+SELECT SLEEP(2);
49+
50+perl;
51+ $slogfile= $ENV{'slogfile'};
52+
53+ open(FILE, "$slogfile") or
54+ die("Unable to read slow query log file $slogfile: $!\n");
55+ while(<FILE>) {
56+ next if (!/^#/);
57+ s/[0-9]+/X/g;
58+ print;
59+ }
60+
61+ close(FILE);
62+EOF
63+
64+SET GLOBAL slow_query_log_file=@old_slow_query_log_file;
65+
66+if(!$fixed_bug38124)
67+{
68+ --disable_query_log
69+ let $my_var = `SELECT @old_slow_query_log_file`;
70+ eval SET @@global.slow_query_log_file = '$my_var';
71+ --enable_query_log
72+}
73
74=== modified file 'profiling_slow.patch'
75--- profiling_slow.patch 2010-11-16 13:48:48 +0000
76+++ profiling_slow.patch 2010-11-25 21:08:58 +0000
77@@ -5,9 +5,76 @@
78 #!!! notice !!!
79 # Any small change to this file in the main branch
80 # should be done or reviewed by the maintainer!
81-diff -ruN /dev/null b/patch_info/profiling_slow.info
82---- /dev/null 1970-01-01 03:00:00.000000000 +0300
83-+++ b/patch_info/profiling_slow.info 2010-07-07 03:32:18.108972002 +0400
84+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
85++++ b/mysql-test/r/percona_bug643149.result 2010-11-25 23:52:28.000000000 +0300
86+@@ -0,0 +1,16 @@
87++SET @old_slow_query_log_file=@@global.slow_query_log_file;
88++SET GLOBAL slow_query_log=on;
89++SET LOCAL profiling_server=on;
90++SET LOCAL long_query_time=1;
91++SET GLOBAL slow_query_log_file='/Users/kaa/src/percona/release-5.1.52-12-bug643149/Percona-Server/mysql-test/var/percona_bug643149_slow.log';;
92++SELECT SLEEP(2);
93++SLEEP(2)
94++0
95++# Time: X X:X:X
96++# User@Host: root[root] @ localhost []
97++# Thread_id: X Schema: test Last_errno: X Killed: X
98++# Query_time: X.X Lock_time: X.X Rows_sent: X Rows_examined: X Rows_affected: X Rows_read: X
99++# Bytes_sent: X Tmp_tables: X Tmp_disk_tables: X Tmp_table_sizes: X
100++# Profile_starting: X.X Profile_starting_cpu: X.X Profile_checking_permissions: X.X Profile_checking_permissions_cpu: X.X Profile_Opening_tables: X.X Profile_Opening_tables_cpu: X.X Profile_init: X.X Profile_init_cpu: X.X Profile_optimizing: X.X Profile_optimizing_cpu: X.X Profile_executing: X.X Profile_executing_cpu: X.X Profile_User_sleep: X.X Profile_User_sleep_cpu: X.X Profile_end: X.X Profile_end_cpu: X.X Profile_query_end: X.X Profile_query_end_cpu: X.X Profile_freeing_items: X.X Profile_freeing_items_cpu: X.X Profile_logging_slow_query: X.X Profile_logging_slow_query_cpu: X.X
101++# Profile_total: X.X Profile_total_cpu: X.X
102++SET GLOBAL slow_query_log_file=@old_slow_query_log_file;
103+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
104++++ b/mysql-test/t/percona_bug643149.test 2010-11-25 23:52:08.000000000 +0300
105+@@ -0,0 +1,46 @@
106++#
107++# This test suffers from server
108++# Bug#38124 "general_log_file" variable silently unset when using expression
109++# In short:
110++# SET GLOBAL general_log_file = @<whatever>
111++# SET GLOBAL slow_query_log = @<whatever>
112++# cause that the value of these server system variables is set to default
113++# instead of the assigned values. There comes no error message or warning.
114++# If this bug is fixed please
115++# 1. try this test with "let $fixed_bug38124 = 0;"
116++# 2. remove all workarounds if 1. was successful.
117++let $fixed_bug38124 = 0;
118++
119++SET @old_slow_query_log_file=@@global.slow_query_log_file;
120++SET GLOBAL slow_query_log=on;
121++SET LOCAL profiling_server=on;
122++SET LOCAL long_query_time=1;
123++
124++let slogfile=$MYSQLTEST_VARDIR/percona_bug643149_slow.log;
125++--eval SET GLOBAL slow_query_log_file='$slogfile';
126++
127++SELECT SLEEP(2);
128++
129++perl;
130++ $slogfile= $ENV{'slogfile'};
131++
132++ open(FILE, "$slogfile") or
133++ die("Unable to read slow query log file $slogfile: $!\n");
134++ while(<FILE>) {
135++ next if (!/^#/);
136++ s/[0-9]+/X/g;
137++ print;
138++ }
139++
140++ close(FILE);
141++EOF
142++
143++SET GLOBAL slow_query_log_file=@old_slow_query_log_file;
144++
145++if(!$fixed_bug38124)
146++{
147++ --disable_query_log
148++ let $my_var = `SELECT @old_slow_query_log_file`;
149++ eval SET @@global.slow_query_log_file = '$my_var';
150++ --enable_query_log
151++}
152+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
153++++ b/patch_info/profiling_slow.info 2010-11-24 19:33:02.000000000 +0300
154 @@ -0,0 +1,9 @@
155 +File=profiling_slow.info
156 +Name=profiling from SHOW PROFILE to slow.log
157@@ -18,9 +85,8 @@
158 +Changelog
159 +2009-05-18
160 +Initial implementation
161-diff -ruN a/sql/log.cc b/sql/log.cc
162---- a/sql/log.cc 2010-07-07 03:32:17.588972002 +0400
163-+++ b/sql/log.cc 2010-07-07 03:32:18.108972002 +0400
164+--- a/sql/log.cc 2010-11-24 19:33:02.000000000 +0300
165++++ b/sql/log.cc 2010-11-24 19:36:29.000000000 +0300
166 @@ -2433,6 +2433,11 @@
167 my_b_printf(&log_file,"# No InnoDB statistics available for this query\n") == (uint) -1)
168 tmp_errno=errno;
169@@ -33,9 +99,8 @@
170 if (thd->db && strcmp(thd->db, db))
171 { // Database changed
172 if (my_b_printf(&log_file,"use %s;\n",thd->db) == (uint) -1)
173-diff -ruN a/sql/mysqld.cc b/sql/mysqld.cc
174---- a/sql/mysqld.cc 2010-07-07 03:32:17.598972002 +0400
175-+++ b/sql/mysqld.cc 2010-07-07 03:32:18.108972002 +0400
176+--- a/sql/mysqld.cc 2010-11-24 19:33:02.000000000 +0300
177++++ b/sql/mysqld.cc 2010-11-24 19:36:29.000000000 +0300
178 @@ -5778,6 +5778,8 @@
179 OPT_LOG_OUTPUT,
180 OPT_PORT_OPEN_TIMEOUT,
181@@ -62,9 +127,8 @@
182 #endif
183 {"relay-log", OPT_RELAY_LOG,
184 "The location and name to use for relay logs.",
185-diff -ruN a/sql/set_var.cc b/sql/set_var.cc
186---- a/sql/set_var.cc 2010-07-07 03:32:17.588972002 +0400
187-+++ b/sql/set_var.cc 2010-07-07 03:32:18.118972002 +0400
188+--- a/sql/set_var.cc 2010-11-24 19:33:02.000000000 +0300
189++++ b/sql/set_var.cc 2010-11-24 19:36:29.000000000 +0300
190 @@ -847,6 +847,10 @@
191 ulonglong(OPTION_PROFILING));
192 static sys_var_thd_ulong sys_profiling_history_size(&vars, "profiling_history_size",
193@@ -76,9 +140,8 @@
194 #endif
195
196 /* Local state variables */
197-diff -ruN a/sql/sql_class.h b/sql/sql_class.h
198---- a/sql/sql_class.h 2010-07-07 03:32:17.588972002 +0400
199-+++ b/sql/sql_class.h 2010-07-07 03:32:18.118972002 +0400
200+--- a/sql/sql_class.h 2010-11-24 19:33:02.000000000 +0300
201++++ b/sql/sql_class.h 2010-11-24 19:36:29.000000000 +0300
202 @@ -328,6 +328,8 @@
203 ulong optimizer_switch;
204 ulong preload_buff_size;
205@@ -88,34 +151,33 @@
206 ulong query_cache_type;
207 ulong read_buff_size;
208 ulong read_rnd_buff_size;
209-diff -ruN a/sql/sql_profile.cc b/sql/sql_profile.cc
210---- a/sql/sql_profile.cc 2010-07-07 03:32:17.598972002 +0400
211-+++ b/sql/sql_profile.cc 2010-07-07 03:32:18.118972002 +0400
212-@@ -221,9 +221,22 @@
213- */
214- void PROF_MEASUREMENT::collect()
215+--- a/sql/sql_profile.cc 2010-10-12 00:34:33.000000000 +0400
216++++ b/sql/sql_profile.cc 2010-11-25 16:09:12.000000000 +0300
217+@@ -223,8 +223,22 @@
218 {
219-+ struct timespec tp;
220 time_usecs= (double) my_getsystime() / 10.0; /* 1 sec was 1e7, now is 1e6 */
221 #ifdef HAVE_GETRUSAGE
222 - getrusage(RUSAGE_SELF, &rusage);
223 + if ((profile->get_profiling())->enabled_getrusage())
224 + getrusage(RUSAGE_SELF, &rusage);
225-+#endif
226+ #endif
227 +
228 +#ifdef HAVE_CLOCK_GETTIME
229++ struct timespec tp;
230++
231 + if (!(clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
232 + {
233 + cpu_time_usecs= tp.tv_sec*1000000000.0 + tp.tv_nsec;
234 + }
235 + else
236++#endif
237 + {
238 + cpu_time_usecs= 0;
239 + }
240- #endif
241 }
242
243-@@ -341,7 +354,7 @@
244+
245+@@ -341,7 +355,7 @@
246 finish_current_query();
247 }
248
249@@ -124,7 +186,7 @@
250
251 if (! enabled) DBUG_VOID_RETURN;
252
253-@@ -379,7 +392,8 @@
254+@@ -379,7 +393,8 @@
255 status_change("ending", NULL, NULL, 0);
256
257 if ((enabled) && /* ON at start? */
258@@ -134,7 +196,7 @@
259 (current->query_source != NULL) &&
260 (! current->entries.is_empty()))
261 {
262-@@ -480,6 +494,88 @@
263+@@ -480,6 +495,118 @@
264 DBUG_VOID_RETURN;
265 }
266
267@@ -144,6 +206,41 @@
268 +}
269 +
270 +/**
271++ For a given profile entry specified by a name and 2 time measurements,
272++ print its normalized name (i.e. with all spaces replaced with underscores)
273++ along with its wall clock and CPU time.
274++*/
275++
276++static void my_b_print_status(IO_CACHE *log_file, const char *status,
277++ PROF_MEASUREMENT *start, PROF_MEASUREMENT *stop)
278++{
279++ DBUG_ENTER("my_b_print_status");
280++ DBUG_ASSERT(log_file != NULL && status != NULL);
281++ char query_time_buff[22+7];
282++ const char *tmp;
283++
284++ my_b_printf(log_file, "Profile_");
285++ for (tmp= status; *tmp; tmp++)
286++ my_b_write_byte(log_file, *tmp == ' ' ? '_' : *tmp);
287++
288++ snprintf(query_time_buff, sizeof(query_time_buff), "%.6f",
289++ (stop->time_usecs - start->time_usecs) / (1000.0 * 1000));
290++ my_b_printf(log_file, ": %s ", query_time_buff);
291++
292++ my_b_printf(log_file, "Profile_");
293++ for (tmp= status; *tmp; tmp++)
294++ my_b_write_byte(log_file, *tmp == ' ' ? '_' : *tmp);
295++ my_b_printf(log_file, "_cpu: ");
296++
297++ snprintf(query_time_buff, sizeof(query_time_buff), "%.6f",
298++ (stop->cpu_time_usecs - start->cpu_time_usecs) /
299++ (1000.0 * 1000 * 1000));
300++ my_b_printf(log_file, "%s ", query_time_buff);
301++
302++ DBUG_VOID_RETURN;
303++}
304++
305++/**
306 + Print output for current query to file
307 +*/
308 +
309@@ -151,8 +248,6 @@
310 +{
311 + DBUG_ENTER("PROFILING::print_current");
312 + ulonglong row_number= 0;
313-+ char query_time_buff[22+7];
314-+ char query_cpu_time_buff[22+7];
315 +
316 + QUERY_PROFILE *query;
317 + /* Get current query */
318@@ -163,7 +258,7 @@
319 +
320 + query= current;
321 +
322-+ my_b_printf(log_file, "# PROFILE_VALUES ");
323++ my_b_printf(log_file, "# ");
324 +
325 + void *entry_iterator;
326 + PROF_MEASUREMENT *entry, *previous= NULL, *first= NULL;
327@@ -203,18 +298,15 @@
328 + }
329 + }
330 +
331-+ snprintf(query_time_buff, sizeof(query_time_buff), "%.6f", (entry->time_usecs-previous->time_usecs)/(1000.0*1000));
332-+ snprintf(query_cpu_time_buff, sizeof(query_cpu_time_buff), "%.6f", (entry->cpu_time_usecs-previous->cpu_time_usecs)/(1000.0*1000*1000));
333-+ my_b_printf(log_file, "%s: %s (cpu: %s), ", previous->status, query_time_buff, query_cpu_time_buff);
334-+
335++ my_b_print_status(log_file, previous->status, previous, entry);
336 + }
337 +
338-+ my_b_printf(log_file, "\n");
339++ my_b_write_byte(log_file, '\n');
340 + if ((entry != NULL) && (first != NULL))
341 + {
342-+ snprintf(query_time_buff, sizeof(query_time_buff), "%.6f", (entry->time_usecs-first->time_usecs)/(1000.0*1000));
343-+ snprintf(query_cpu_time_buff, sizeof(query_cpu_time_buff), "%.6f", (entry->cpu_time_usecs-first->cpu_time_usecs)/(1000.0*1000*1000));
344-+ my_b_printf(log_file, "# PROFILE_TOTALS Total: %s (cpu: %s)\n", query_time_buff, query_cpu_time_buff);
345++ my_b_printf(log_file, "# ");
346++ my_b_print_status(log_file, "total", first, entry);
347++ my_b_write_byte(log_file, '\n');
348 + }
349 +
350 + DBUG_RETURN(0);
351@@ -223,18 +315,43 @@
352 /**
353 Fill the information schema table, "query_profile", as defined in show.cc .
354 There are two ways to get to this function: Selecting from the information
355-diff -ruN a/sql/sql_profile.h b/sql/sql_profile.h
356---- a/sql/sql_profile.h 2010-07-07 03:32:17.608972002 +0400
357-+++ b/sql/sql_profile.h 2010-07-07 03:32:18.118972002 +0400
358-@@ -180,6 +180,7 @@
359+--- a/sql/sql_profile.h 2010-10-12 00:34:33.000000000 +0400
360++++ b/sql/sql_profile.h 2010-11-25 15:54:48.000000000 +0300
361+@@ -165,11 +165,15 @@
362+ */
363+ class PROF_MEASUREMENT
364+ {
365+-private:
366+- friend class QUERY_PROFILE;
367+- friend class PROFILING;
368+-
369+ QUERY_PROFILE *profile;
370++
371++ char *allocated_status_memory;
372++
373++ void set_label(const char *status_arg, const char *function_arg,
374++ const char *file_arg, unsigned int line_arg);
375++ void clean_up();
376++
377++public:
378+ char *status;
379+ #ifdef HAVE_GETRUSAGE
380+ struct rusage rusage;
381+@@ -180,12 +184,7 @@
382 unsigned int line;
383
384 double time_usecs;
385+- char *allocated_status_memory;
386+-
387+- void set_label(const char *status_arg, const char *function_arg,
388+- const char *file_arg, unsigned int line_arg);
389+- void clean_up();
390+-
391 + double cpu_time_usecs;
392- char *allocated_status_memory;
393-
394- void set_label(const char *status_arg, const char *function_arg,
395-@@ -230,6 +231,11 @@
396+ PROF_MEASUREMENT();
397+ PROF_MEASUREMENT(QUERY_PROFILE *profile_arg, const char *status_arg);
398+ PROF_MEASUREMENT(QUERY_PROFILE *profile_arg, const char *status_arg,
399+@@ -230,6 +229,11 @@
400
401 /* Show this profile. This is called by PROFILING. */
402 bool show(uint options);
403@@ -246,7 +363,7 @@
404 };
405
406
407-@@ -275,9 +281,11 @@
408+@@ -275,9 +279,11 @@
409
410 /* SHOW PROFILES */
411 bool show_profiles();

Subscribers

People subscribed via source and target branches

to all changes: