Merge lp:~dingqi-lxb/percona-server/5.5_log_queries_in_memory into lp:percona-server/5.5
- 5.5_log_queries_in_memory
- Merge into 5.5
Status: | Superseded |
---|---|
Proposed branch: | lp:~dingqi-lxb/percona-server/5.5_log_queries_in_memory |
Merge into: | lp:percona-server/5.5 |
Diff against target: |
902 lines (+883/-2) (has conflicts) 3 files modified
doc/source/diagnostics/slow_log_in_memory.rst (+74/-0) patches/series (+8/-2) patches/slowlog_in_memory.patch (+801/-0) Text conflict in patches/series |
To merge this branch: | bzr merge lp:~dingqi-lxb/percona-server/5.5_log_queries_in_memory |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Oleg Tsarev | Pending | ||
Review via email: mp+86381@code.launchpad.net |
This proposal supersedes a proposal from 2011-12-11.
This proposal has been superseded by a proposal from 2011-12-20.
Commit message
Description of the change
patch for https:/
add a variable 'slowlog_
If the current_memory grows larger than max_memory, the eldest ones will be wash out.
Same action happens when max_mamory are set to a new value that is less than current_memory.
Oleg Tsarev (tsarev) wrote : Posted in a previous version of this proposal | # |
Oleg Tsarev (tsarev) wrote : Posted in a previous version of this proposal | # |
8.
+ ulonglong utime_of_query= thd->current_
+ if (utime_of_query <= thd->variables.
+ return;
Please look into the slow_extended.
static inline ulonglong get_query_
...
thd->server_
Please better use this status variable, instead of calculate query execution time directly.
林晓斌 (dingqi-lxb) wrote : Posted in a previous version of this proposal | # |
Thank you. Oleg, I have some items to discuss.
2. About innodb_trx_id. Please look to two following cases
In these two cases, the variable thd->innodb_trx_id is set to 0. It seems that I have to show it in the result table as 0, is there other result even use innodb_was_used ?
8.About calculating query execution time directly, it is because that I have to get the query_time, the status is not enough.
* Why plugin doesn't uninstall in test?
You mean that it shows " Plugin is busy and will be uninstalled on shutdown" in result-file? It is the same with the demo for audit plugin "null_audit", the strategy decided by mysqld
Oleg Tsarev (tsarev) wrote : Posted in a previous version of this proposal | # |
On Mon, Dec 12, 2011 at 12:05 PM, 林晓斌 <email address hidden> wrote:
> Thank you. Oleg, I have some items to discuss.
>
> 2. About innodb_trx_id. Please look to two following cases
> In these two cases, the variable thd->innodb_trx_id is set to 0. It seems that I have to show it in the result table as 0, is there other result even use innodb_was_used ?
I think right decision is "NULL" value instead of 0.
>
> 8.About calculating query execution time directly, it is because that I have to get the query_time, the status is not enough.
>
> * Why plugin doesn't uninstall in test?
> You mean that it shows " Plugin is busy and will be uninstalled on shutdown" in result-file? It is the same with the demo for audit plugin "null_audit", the strategy decided by mysqld
Ok
> --
> https:/
> You are reviewing the proposed merge of lp:~dingqi-lxb/percona-server/5.5_log_queries_in_memory into lp:percona-server.
--
Oleg Tsarev, Software Engineer, Percona Inc.
林晓斌 (dingqi-lxb) wrote : Posted in a previous version of this proposal | # |
2. About innodb_trx_id. Generally, when the thd->innodb_trx_id is 0, the value of "INNODB_TRX_ID" should show NULL, so the thd->innodb_
7. Please add tests to sys_vars suite for the all added variables.
The variable add in this plugin will not be seen in other test-case, it can only be seen the plugin is installed. So, is test-case in sys_vars suits necessary?
Preview Diff
1 | === added file 'doc/source/diagnostics/slow_log_in_memory.rst' |
2 | --- doc/source/diagnostics/slow_log_in_memory.rst 1970-01-01 00:00:00 +0000 |
3 | +++ doc/source/diagnostics/slow_log_in_memory.rst 2011-12-20 12:37:37 +0000 |
4 | @@ -0,0 +1,74 @@ |
5 | +.. _slow_log_in_memory: |
6 | + |
7 | +================= |
8 | + Slow Log In Memory |
9 | +================= |
10 | + |
11 | +The feature is used to save slow queries in memory. This feature adds an ``INFORMATION_SCHEMA.SLOW_LOG`` table to show the latest queries, a variable to limit the max memory used, and status to show the status of memory used. |
12 | + |
13 | +There are two plugins in the feature. They can be installed by command ``"install plugin SLOWLOG_IN_MEMORY_AUDIT soname 'slowlog_in_memory.so'"`` and ``"install plugin SLOW_LOG soname 'slowlog_in_memory.so'"``, they work by keeping one list in memory. |
14 | + |
15 | + |
16 | +Other Information |
17 | +================= |
18 | + |
19 | + * Author/Origin: |
20 | + *Percona*; *Percona* added an ``INFORMATION_SCHEMA`` table and the :variable:`slowlog_in_memory_audit_max_memory` and the :status:`slow_log_current_memory`. |
21 | + |
22 | +System Variables |
23 | +================ |
24 | + |
25 | +.. variable:: slowlog_in_memory_audit_max_memory |
26 | + |
27 | + :cli: Yes |
28 | + :conf: Yes |
29 | + :scope: Global |
30 | + :dyn: Yes |
31 | + :vartype: ULONG |
32 | + :default: 1M |
33 | + :range: 0 - 1G |
34 | + |
35 | +The variable is used to limit the max-memory used for slow log. If a new slow query will make the `current_memory` bigger than this value, the most eldest items will be discarded, until there is enough memory for new item. When the value is decrease dynamically, it behaves the same. |
36 | + |
37 | +Status Variables |
38 | +================ |
39 | + |
40 | +One new status variable was introduced by this feature. |
41 | + |
42 | +.. variable:: slow_log_current_memory |
43 | + |
44 | + :vartype: ULONG |
45 | + :scope: Global |
46 | + |
47 | +The variable showes the current memory used for the slow queries. It can never be bigger than the `slowlog_in_memory_audit_max_memory` variable. |
48 | + |
49 | + |
50 | +INFORMATION_SCHEMA Tables |
51 | +========================= |
52 | + |
53 | +.. table:: INFORMATION_SCHEMA.SLOW_LOG |
54 | + |
55 | + :column EVENT_ID: A global increment id for every record in the table, can be used to identify every one. |
56 | + :column TIMESTAMP: The timestamp when the query stop. |
57 | + :column THREAD_ID: The thread_id of the query. |
58 | + :column DB: The current database() of the query, may be NULL. |
59 | + :column INNODB_TRX_ID: The Innodb_trx_id if InnoDB is used, may be NULL. |
60 | + :column ERROR: The errno of the query, 0 means no error. |
61 | + :column MS_QUERY_TIME: The query_exec_time of the query, in millisecond. |
62 | + :column QUERY: The query statement. |
63 | + |
64 | +This table holds the lastest slow queries. |
65 | + |
66 | +Example: :: |
67 | + |
68 | + mysql> select * from information_schema.slow_log \G |
69 | + *************************** 1. row *************************** |
70 | + EVENT_ID: 1 |
71 | + TIMESTAMP: 1323753896 |
72 | + THREAD_ID: 2 |
73 | + DB: test |
74 | + INNODB_TRX_ID: NULL |
75 | + ERRNO: 0 |
76 | + MS_QUERY_TIME: 3001 |
77 | + QUERY: select sleep(3) |
78 | + |
79 | |
80 | === modified file 'patches/series' |
81 | --- patches/series 2011-12-16 09:37:26 +0000 |
82 | +++ patches/series 2011-12-20 12:37:37 +0000 |
83 | @@ -60,5 +60,11 @@ |
84 | subunit.patch |
85 | bug860910.patch |
86 | bug45702.patch |
87 | -group_commit.patch |
88 | -warning_fixes.patch |
89 | +<<<<<<< TREE |
90 | +group_commit.patch |
91 | +warning_fixes.patch |
92 | +======= |
93 | +group_commit.patch |
94 | +warning_fixes.patch |
95 | +slowlog_in_memory.patch |
96 | +>>>>>>> MERGE-SOURCE |
97 | |
98 | === added file 'patches/slowlog_in_memory.patch' |
99 | --- patches/slowlog_in_memory.patch 1970-01-01 00:00:00 +0000 |
100 | +++ patches/slowlog_in_memory.patch 2011-12-20 12:37:37 +0000 |
101 | @@ -0,0 +1,801 @@ |
102 | +--- a/plugin/slowlog_in_memory/CMakeLists.txt 1970-01-01 08:00:00.000000000 +0800 |
103 | ++++ b/plugin/slowlog_in_memory/CMakeLists.txt 2011-12-19 14:45:40.000000000 +0800 |
104 | +@@ -0,0 +1,17 @@ |
105 | ++# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. |
106 | ++# |
107 | ++# This program is free software; you can redistribute it and/or modify |
108 | ++# it under the terms of the GNU General Public License as published by |
109 | ++# the Free Software Foundation; version 2 of the License. |
110 | ++# |
111 | ++# This program is distributed in the hope that it will be useful, |
112 | ++# but WITHOUT ANY WARRANTY; without even the implied warranty of |
113 | ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
114 | ++# GNU General Public License for more details. |
115 | ++# |
116 | ++# You should have received a copy of the GNU General Public License |
117 | ++# along with this program; if not, write to the Free Software |
118 | ++# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
119 | ++ |
120 | ++MYSQL_ADD_PLUGIN(slowlog_in_memory slowlog_in_memory.cc |
121 | ++ MODULE_ONLY MODULE_OUTPUT_NAME "slowlog_in_memory") |
122 | +--- a/plugin/slowlog_in_memory/slowlog_in_memory.cc 1970-01-01 08:00:00.000000000 +0800 |
123 | ++++ b/plugin/slowlog_in_memory/slowlog_in_memory.cc 2011-12-19 14:45:40.000000000 +0800 |
124 | +@@ -0,0 +1,295 @@ |
125 | ++/* Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved. |
126 | ++ |
127 | ++ This program is free software; you can redistribute it and/or |
128 | ++ modify it under the terms of the GNU General Public License |
129 | ++ as published by the Free Software Foundation; version 2 of |
130 | ++ the License. |
131 | ++ |
132 | ++ This program is distributed in the hope that it will be useful, |
133 | ++ but WITHOUT ANY WARRANTY; without even the implied warranty of |
134 | ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
135 | ++ GNU General Public License for more details. |
136 | ++ |
137 | ++ You should have received a copy of the GNU General Public License |
138 | ++ along with this program; if not, write to the Free Software |
139 | ++ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ |
140 | ++ |
141 | ++#include "ut_slow_log_list.h" |
142 | ++ |
143 | ++#if !defined(__attribute__) && (defined(__cplusplus) || !defined(__GNUC__) || __GNUC__ == 2 && __GNUC_MINOR__ < 8) |
144 | ++#define __attribute__(A) |
145 | ++#endif |
146 | ++typedef struct st_mysql_sys_var SYS_VAR; |
147 | ++uint max_memory_for_slowlog; |
148 | ++ |
149 | ++/* lock management */ |
150 | ++ |
151 | ++slow_log_list *global_slow_log_list= NULL; |
152 | ++ |
153 | ++/* |
154 | ++ Initialize the plugin at server start or plugin installation. |
155 | ++ |
156 | ++ SYNOPSIS |
157 | ++ slowlog_in_memory_plugin_init() |
158 | ++ |
159 | ++ DESCRIPTION |
160 | ++ Does nothing. |
161 | ++ |
162 | ++ RETURN VALUE |
163 | ++ 0 success |
164 | ++ 1 failure (cannot happen) |
165 | ++*/ |
166 | ++ |
167 | ++static int slowlog_in_memory_plugin_init(void *arg __attribute__((unused))) |
168 | ++{ |
169 | ++#ifdef HAVE_PSI_INTERFACE |
170 | ++ init_semisync_psi_keys(); |
171 | ++#endif |
172 | ++ |
173 | ++ mysql_mutex_init(key_ss_mutex_LOCK_slow_event_id_, |
174 | ++ &LOCK_slow_event_id_, MY_MUTEX_INIT_FAST); |
175 | ++ global_slow_log_list= new slow_log_list(max_memory_for_slowlog); |
176 | ++ |
177 | ++ return 0; |
178 | ++} |
179 | ++ |
180 | ++ |
181 | ++/* |
182 | ++ Terminate the plugin at server shutdown or plugin deinstallation. |
183 | ++ |
184 | ++ SYNOPSIS |
185 | ++ slowlog_in_memory_plugin_deinit() |
186 | ++ Does nothing. |
187 | ++ |
188 | ++ RETURN VALUE |
189 | ++ 0 success |
190 | ++ 1 failure (cannot happen) |
191 | ++*/ |
192 | ++ |
193 | ++static int slowlog_in_memory_plugin_deinit(void *arg __attribute__((unused))) |
194 | ++{ |
195 | ++ if (global_slow_log_list) |
196 | ++ { |
197 | ++ delete global_slow_log_list; |
198 | ++ global_slow_log_list= NULL; |
199 | ++ } |
200 | ++ |
201 | ++ mysql_mutex_destroy(&LOCK_slow_event_id_); |
202 | ++ return 0; |
203 | ++} |
204 | ++ |
205 | ++/* |
206 | ++ Foo |
207 | ++ |
208 | ++ SYNOPSIS |
209 | ++ slowlog_in_memory_notify() |
210 | ++ thd connection context |
211 | ++ |
212 | ++ DESCRIPTION |
213 | ++*/ |
214 | ++ |
215 | ++static void slowlog_in_memory_notify(MYSQL_THD thd __attribute__((unused)), |
216 | ++ unsigned int event_class, |
217 | ++ const void *event) |
218 | ++{ |
219 | ++ if (max_memory_for_slowlog == 0) return; |
220 | ++ |
221 | ++ if (event_class == MYSQL_AUDIT_GENERAL_CLASS) |
222 | ++ { |
223 | ++ const struct mysql_event_general *event_general= |
224 | ++ (const struct mysql_event_general *) event; |
225 | ++ if (event_general->event_subclass != MYSQL_AUDIT_GENERAL_STATUS) |
226 | ++ return; |
227 | ++ |
228 | ++ ulonglong utime_of_query= thd->current_utime() - thd->utime_after_lock; |
229 | ++ |
230 | ++#ifndef DBUG_OFF |
231 | ++ if (thd->variables.query_exec_time != 0) |
232 | ++ utime_of_query= thd->lex->sql_command != SQLCOM_SET_OPTION ? thd->variables.query_exec_time : 0; |
233 | ++#endif |
234 | ++ |
235 | ++ if (utime_of_query <= thd->variables.long_query_time) |
236 | ++ return; |
237 | ++ |
238 | ++ slow_log_t *tmp= new slow_log_t(event_general->general_time, event_general->general_thread_id, thd->db, thd->innodb_trx_id, event_general->general_error_code, utime_of_query/1000, event_general->general_query); |
239 | ++ global_slow_log_list->push_back(tmp); |
240 | ++ } |
241 | ++} |
242 | ++ |
243 | ++ |
244 | ++/* |
245 | ++ Plugin type-specific descriptor |
246 | ++*/ |
247 | ++ |
248 | ++static struct st_mysql_audit slowlog_in_memory_descriptor= |
249 | ++{ |
250 | ++ MYSQL_AUDIT_INTERFACE_VERSION, /* interface version */ |
251 | ++ NULL, /* release_thd function */ |
252 | ++ slowlog_in_memory_notify, /* notify function */ |
253 | ++ { (unsigned long) MYSQL_AUDIT_GENERAL_CLASSMASK } /* class mask */ |
254 | ++}; |
255 | ++ |
256 | ++static void change_max_memory_for_slowlog(MYSQL_THD thd, |
257 | ++ SYS_VAR *var, |
258 | ++ void *ptr, |
259 | ++ const void *val) |
260 | ++{ |
261 | ++ uint new_len= *(uint *)val; |
262 | ++ *(uint *)ptr= new_len; |
263 | ++ |
264 | ++ global_slow_log_list->change_max_memory(new_len); |
265 | ++ return; |
266 | ++} |
267 | ++ |
268 | ++static MYSQL_SYSVAR_UINT(max_memory, max_memory_for_slowlog, |
269 | ++ PLUGIN_VAR_OPCMDARG, |
270 | ++ "The max memory that can be allocated for slow log.", |
271 | ++ NULL, // check |
272 | ++ &change_max_memory_for_slowlog, // update |
273 | ++ 1024*1024, 0, 1024*1024*1024, 1); |
274 | ++ |
275 | ++static SYS_VAR* slowlog_in_memory_system_vars[]= { |
276 | ++ MYSQL_SYSVAR(max_memory), |
277 | ++ NULL, |
278 | ++}; |
279 | ++ |
280 | ++static uint slow_log_current_memory(MYSQL_THD thd, SHOW_VAR *var, char *buff) |
281 | ++{ |
282 | ++ var->type= SHOW_INT; |
283 | ++ var->value= (char*)&global_slow_log_list->current_memory; |
284 | ++ return 0; |
285 | ++} |
286 | ++ |
287 | ++/* plugin status variables */ |
288 | ++static SHOW_VAR slowlog_in_memory_status_vars[]= { |
289 | ++ {"slow_log_current_memory", |
290 | ++ (char*) &slow_log_current_memory, |
291 | ++ SHOW_FUNC}, |
292 | ++ {NULL, NULL, SHOW_LONG}, |
293 | ++}; |
294 | ++ |
295 | ++ |
296 | ++/* |
297 | ++ I_S_SLOW_LOG |
298 | ++*/ |
299 | ++static struct st_mysql_information_schema i_s_slow_log= |
300 | ++{ |
301 | ++ MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION |
302 | ++}; |
303 | ++ |
304 | ++static ST_FIELD_INFO i_s_slow_log_fields[] = |
305 | ++{ |
306 | ++ {"EVENT_ID", 11, MYSQL_TYPE_LONGLONG, 0, 0, 0, SKIP_OPEN_TABLE}, |
307 | ++ {"TIMESTAMP", 11, MYSQL_TYPE_LONGLONG, 0, 0, 0, SKIP_OPEN_TABLE}, |
308 | ++ {"THREAD_ID", 11, MYSQL_TYPE_LONG, 0, 0, 0, SKIP_OPEN_TABLE}, |
309 | ++ {"DB", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, 0, SKIP_OPEN_TABLE}, |
310 | ++ {"INNODB_TRX_ID", 11, MYSQL_TYPE_LONGLONG, 0, 1, 0, SKIP_OPEN_TABLE}, |
311 | ++ {"ERRNO", 11, MYSQL_TYPE_LONG, 0, 0, 0, SKIP_OPEN_TABLE}, |
312 | ++ {"MS_QUERY_TIME", 11, MYSQL_TYPE_LONGLONG, 0, 0, 0, SKIP_OPEN_TABLE}, |
313 | ++ |
314 | ++ {"QUERY", 255, MYSQL_TYPE_STRING, 0, 1, 0, SKIP_OPEN_TABLE}, |
315 | ++ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE} |
316 | ++}; |
317 | ++ |
318 | ++ |
319 | ++int i_s_fill_table_slow_log(THD* thd, TABLE_LIST* tables, COND* cond) |
320 | ++{ |
321 | ++ if (!global_slow_log_list) return 0; |
322 | ++ |
323 | ++ TABLE *table= tables->table; |
324 | ++ |
325 | ++ mysql_mutex_lock(&global_slow_log_list->LOCK_slowlog_); |
326 | ++ |
327 | ++ slow_log_t *item= global_slow_log_list->first; |
328 | ++ while (item) |
329 | ++ { |
330 | ++ restore_record(table, s->default_values); |
331 | ++ |
332 | ++ table->field[0]->store(item->event_id, TRUE); |
333 | ++ table->field[1]->store(item->timestamp, TRUE); |
334 | ++ table->field[2]->store(item->thread_id, TRUE); |
335 | ++ |
336 | ++ if (item->schema) |
337 | ++ { |
338 | ++ table->field[3]->store(item->schema, item->schema_len-1, system_charset_info); |
339 | ++ table->field[3]->set_notnull(); |
340 | ++ } |
341 | ++ |
342 | ++ if (item->innodb_trx_id) |
343 | ++ { |
344 | ++ table->field[4]->store(item->innodb_trx_id, TRUE); |
345 | ++ table->field[4]->set_notnull(); |
346 | ++ } |
347 | ++ |
348 | ++ table->field[5]->store(item->cmd_errno, TRUE); |
349 | ++ table->field[6]->store(item->mstime_of_query, TRUE); |
350 | ++ |
351 | ++ if (item->general_query) |
352 | ++ { |
353 | ++ table->field[7]->store(item->general_query, item->general_query_len-1, system_charset_info); |
354 | ++ table->field[7]->set_notnull(); |
355 | ++ } |
356 | ++ |
357 | ++ schema_table_store_record(thd, table); |
358 | ++ item= item->next; |
359 | ++ } |
360 | ++ |
361 | ++ mysql_mutex_unlock(&global_slow_log_list->LOCK_slowlog_); |
362 | ++ return 0; |
363 | ++} |
364 | ++ |
365 | ++ |
366 | ++static int i_s_slow_log_plugin_init(void *arg __attribute__((unused))) |
367 | ++{ |
368 | ++ ST_SCHEMA_TABLE* schema; |
369 | ++ |
370 | ++ schema = (ST_SCHEMA_TABLE*) arg; |
371 | ++ |
372 | ++ schema->fields_info = i_s_slow_log_fields; |
373 | ++ schema->fill_table = i_s_fill_table_slow_log; |
374 | ++ return 0; |
375 | ++} |
376 | ++ |
377 | ++ |
378 | ++static int i_s_slow_log_plugin_deinit(void *arg __attribute__((unused))) |
379 | ++{ |
380 | ++ return(0); |
381 | ++} |
382 | ++ |
383 | ++/* |
384 | ++ Plugin library descriptor |
385 | ++*/ |
386 | ++ |
387 | ++mysql_declare_plugin(slowlog_in_memory) |
388 | ++{ |
389 | ++ MYSQL_AUDIT_PLUGIN, /* type */ |
390 | ++ &slowlog_in_memory_descriptor, /* descriptor */ |
391 | ++ "SLOWLOG_IN_MEMORY_AUDIT", /* name */ |
392 | ++ "Percona", /* author */ |
393 | ++ "Error code histogram Audit", /* description */ |
394 | ++ PLUGIN_LICENSE_GPL, |
395 | ++ slowlog_in_memory_plugin_init, /* init function (when loaded) */ |
396 | ++ slowlog_in_memory_plugin_deinit, /* deinit function (when unloaded) */ |
397 | ++ 0x0001, /* version */ |
398 | ++ slowlog_in_memory_status_vars, /* status variables */ |
399 | ++ slowlog_in_memory_system_vars, /* system variables */ |
400 | ++ NULL, |
401 | ++ 0, |
402 | ++}, |
403 | ++{ |
404 | ++ MYSQL_INFORMATION_SCHEMA_PLUGIN, /* type */ |
405 | ++ &i_s_slow_log, /* descriptor */ |
406 | ++ "SLOW_LOG", /* name */ |
407 | ++ "Percona", /* author */ |
408 | ++ "latest slow log in memory", /* description */ |
409 | ++ PLUGIN_LICENSE_GPL, |
410 | ++ i_s_slow_log_plugin_init, /* init function (when loaded) */ |
411 | ++ i_s_slow_log_plugin_deinit, /* deinit function (when unloaded) */ |
412 | ++ 0x0001, /* version */ |
413 | ++ NULL, /* status variables */ |
414 | ++ NULL, /* system variables */ |
415 | ++ NULL, |
416 | ++ 0, |
417 | ++} |
418 | ++mysql_declare_plugin_end; |
419 | ++ |
420 | +--- a/plugin/slowlog_in_memory/ut_slow_log_list.h 1970-01-01 08:00:00.000000000 +0800 |
421 | ++++ b/plugin/slowlog_in_memory/ut_slow_log_list.h 2011-12-19 14:45:40.000000000 +0800 |
422 | +@@ -0,0 +1,230 @@ |
423 | ++#ifndef UT_SLOW_LOG_LIST_H |
424 | ++#define UT_SLOW_LOG_LIST_H |
425 | ++ |
426 | ++#define MYSQL_SERVER |
427 | ++#include <mysql/plugin_audit.h> |
428 | ++#include "unireg.h" |
429 | ++#include "sql_show.h" |
430 | ++#include "sql_class.h" |
431 | ++ |
432 | ++mysql_mutex_t LOCK_slow_event_id_; |
433 | ++ |
434 | ++#ifdef HAVE_PSI_INTERFACE |
435 | ++PSI_mutex_key key_ss_mutex_LOCK_slowlog_; |
436 | ++PSI_mutex_key key_ss_mutex_LOCK_slow_event_id_; |
437 | ++ |
438 | ++static PSI_mutex_info all_semisync_mutexes[]= |
439 | ++{ |
440 | ++ {&key_ss_mutex_LOCK_slowlog_, "LOCK_slowlog_", 0}, |
441 | ++ {&key_ss_mutex_LOCK_slow_event_id_, "LOCK_slow_event_id_", 0} |
442 | ++}; |
443 | ++ |
444 | ++static void init_semisync_psi_keys(void) |
445 | ++{ |
446 | ++ const char* category= "semisync"; |
447 | ++ int count; |
448 | ++ |
449 | ++ if (PSI_server == NULL) |
450 | ++ return; |
451 | ++ |
452 | ++ count= array_elements(all_semisync_mutexes); |
453 | ++ PSI_server->register_mutex(category, all_semisync_mutexes, count); |
454 | ++ |
455 | ++} |
456 | ++#endif /* HAVE_PSI_INTERFACE */ |
457 | ++ |
458 | ++/* unique event id for each slow query */ |
459 | ++ulonglong global_event_id= 0; |
460 | ++ |
461 | ++const uint MAX_QUERY_LEN= 255; |
462 | ++ |
463 | ++class slow_log_t |
464 | ++{ |
465 | ++public: |
466 | ++ ulonglong event_id; |
467 | ++ ulonglong timestamp; |
468 | ++ ulong thread_id; |
469 | ++ char *schema; |
470 | ++ ulonglong innodb_trx_id; |
471 | ++ int cmd_errno; |
472 | ++ ulonglong mstime_of_query; |
473 | ++ char *general_query; |
474 | ++ |
475 | ++ uint schema_len; |
476 | ++ uint general_query_len; |
477 | ++ |
478 | ++ slow_log_t *next; |
479 | ++ |
480 | ++ slow_log_t(ulonglong timestamp, ulong thread_id, const char *schema, |
481 | ++ ulonglong innodb_trx_id, int cmd_errno, ulonglong mstime_of_query, const char *general_query):next(NULL) |
482 | ++ { |
483 | ++ this->timestamp= timestamp; |
484 | ++ this->thread_id= thread_id; |
485 | ++ |
486 | ++ if (schema) |
487 | ++ { |
488 | ++ this->schema_len= strlen(schema) + 1; |
489 | ++ this->schema= strndup(schema, this->schema_len); |
490 | ++ } |
491 | ++ else |
492 | ++ { |
493 | ++ this->schema= NULL; |
494 | ++ this->schema_len= 0; |
495 | ++ } |
496 | ++ |
497 | ++ this->innodb_trx_id= innodb_trx_id; |
498 | ++ this->cmd_errno= cmd_errno; |
499 | ++ this->mstime_of_query= mstime_of_query; |
500 | ++ |
501 | ++ if (general_query) |
502 | ++ { |
503 | ++ this->general_query_len= strlen(general_query) + 1; |
504 | ++ |
505 | ++ if (this->general_query_len > MAX_QUERY_LEN) |
506 | ++ { |
507 | ++ this->general_query_len= MAX_QUERY_LEN; |
508 | ++ } |
509 | ++ |
510 | ++ this->general_query= strndup(general_query, this->general_query_len); |
511 | ++ this->general_query[this->general_query_len-1]= '\0'; |
512 | ++ } |
513 | ++ else |
514 | ++ { |
515 | ++ this->general_query= NULL; |
516 | ++ this->general_query_len= 0; |
517 | ++ } |
518 | ++ |
519 | ++ this->real_size= sizeof(slow_log_t) + this->schema_len + this->general_query_len; |
520 | ++ |
521 | ++ mysql_mutex_lock(&LOCK_slow_event_id_); |
522 | ++ this->event_id= ++global_event_id; |
523 | ++ mysql_mutex_unlock(&LOCK_slow_event_id_); |
524 | ++ } |
525 | ++ |
526 | ++ ~slow_log_t() |
527 | ++ { |
528 | ++ if (schema) |
529 | ++ { |
530 | ++ free(schema); |
531 | ++ schema= NULL; |
532 | ++ } |
533 | ++ |
534 | ++ if (general_query) |
535 | ++ { |
536 | ++ free(general_query); |
537 | ++ general_query= NULL; |
538 | ++ } |
539 | ++ } |
540 | ++ |
541 | ++ uint size_of_instance() |
542 | ++ { |
543 | ++ return real_size; |
544 | ++ } |
545 | ++ |
546 | ++ uint real_size; |
547 | ++}; |
548 | ++ |
549 | ++class slow_log_list |
550 | ++{ |
551 | ++public: |
552 | ++ slow_log_t *first, *last; |
553 | ++ mysql_mutex_t LOCK_slowlog_; |
554 | ++ |
555 | ++ uint current_memory; |
556 | ++ |
557 | ++ void change_max_memory(uint new_len) |
558 | ++ { |
559 | ++ mysql_mutex_lock(&LOCK_slowlog_); |
560 | ++ |
561 | ++ max_memory= new_len; |
562 | ++ |
563 | ++ /* if the size is larger than current size, just change the value*/ |
564 | ++ if (max_memory >= current_memory) |
565 | ++ { |
566 | ++ mysql_mutex_unlock(&LOCK_slowlog_); |
567 | ++ return; |
568 | ++ } |
569 | ++ |
570 | ++ while (current_memory > max_memory) |
571 | ++ { |
572 | ++ pop_front(); |
573 | ++ } |
574 | ++ |
575 | ++ mysql_mutex_unlock(&LOCK_slowlog_); |
576 | ++ } |
577 | ++ |
578 | ++ slow_log_list(uint max_memory) |
579 | ++ { |
580 | ++ first= NULL; |
581 | ++ last= NULL; |
582 | ++ current_memory= 0; |
583 | ++ this->max_memory= max_memory; |
584 | ++ |
585 | ++ mysql_mutex_init(key_ss_mutex_LOCK_slowlog_, |
586 | ++ &LOCK_slowlog_, MY_MUTEX_INIT_FAST); |
587 | ++ } |
588 | ++ |
589 | ++ ~slow_log_list() |
590 | ++ { |
591 | ++ mysql_mutex_lock(&LOCK_slowlog_); |
592 | ++ while (first) |
593 | ++ { |
594 | ++ pop_front(); |
595 | ++ } |
596 | ++ mysql_mutex_unlock(&LOCK_slowlog_); |
597 | ++ |
598 | ++ mysql_mutex_destroy(&LOCK_slowlog_); |
599 | ++ } |
600 | ++ |
601 | ++ void push_back(slow_log_t * item) |
602 | ++ { |
603 | ++ mysql_mutex_lock(&LOCK_slowlog_); |
604 | ++ |
605 | ++ uint size= item->size_of_instance(); |
606 | ++ |
607 | ++ if (size > max_memory) |
608 | ++ { |
609 | ++ sql_print_warning("the insert item size %u > %u discarded", size, max_memory); |
610 | ++ mysql_mutex_unlock(&LOCK_slowlog_); |
611 | ++ return; |
612 | ++ } |
613 | ++ |
614 | ++ while (current_memory + size > max_memory) |
615 | ++ { |
616 | ++ pop_front(); |
617 | ++ } |
618 | ++ |
619 | ++ if (!first) |
620 | ++ { |
621 | ++ first= item; |
622 | ++ last= item; |
623 | ++ } |
624 | ++ else |
625 | ++ { |
626 | ++ last->next= item; |
627 | ++ last= item; |
628 | ++ } |
629 | ++ |
630 | ++ current_memory+= size; |
631 | ++ mysql_mutex_unlock(&LOCK_slowlog_); |
632 | ++ } |
633 | ++ |
634 | ++ /*functions call pop_front should have hold LOCK_slowlog_*/ |
635 | ++ void pop_front() |
636 | ++ { |
637 | ++ if (!first) return; |
638 | ++ |
639 | ++ slow_log_t *item= first; |
640 | ++ first= first->next; |
641 | ++ |
642 | ++ if (!first) last= NULL; |
643 | ++ |
644 | ++ current_memory-= item->size_of_instance(); |
645 | ++ delete item; |
646 | ++ } |
647 | ++ |
648 | ++private: |
649 | ++ uint max_memory; |
650 | ++}; |
651 | ++#endif |
652 | ++ |
653 | +--- a/mysql-test/include/have_slog_log_in_memory_audit_plugin.inc 1970-01-01 08:00:00.000000000 +0800 |
654 | ++++ b/mysql-test/include/have_slog_log_in_memory_audit_plugin.inc 2011-12-19 19:13:34.000000000 +0800 |
655 | +@@ -0,0 +1,21 @@ |
656 | ++# |
657 | ++# Check if server has support for loading plugins |
658 | ++# |
659 | ++if (`SELECT @@have_dynamic_loading != 'YES'`) { |
660 | ++ --skip Requires dynamic loading |
661 | ++} |
662 | ++ |
663 | ++# |
664 | ++# Check if the variable SLOW_LOG_IN_MEMORY_AUDIT is set |
665 | ++# |
666 | ++if (!$SLOW_LOG_IN_MEMORY_AUDIT) |
667 | ++{ |
668 | ++ skip Need slow_log_in_memory plugins; |
669 | ++} |
670 | ++ |
671 | ++# |
672 | ++# Check if --plugin-dir was setup for slow_log_in_memory |
673 | ++# |
674 | ++if (`SELECT CONCAT('--plugin-dir=', @@plugin_dir) != '$SLOW_LOG_IN_MEMORY_AUDIT_OPT'`) { |
675 | ++ --skip SLOW_LOG plugin requires that --plugin-dir is set to the slow_log_in_memory plugin dir (either the .opt file does not contain \$SLOW_LOG_IN_MEMORY_AUDIT_OPT or another plugin is in use) |
676 | ++} |
677 | +--- a/mysql-test/include/plugin.defs 2011-12-19 14:44:49.000000000 +0800 |
678 | ++++ b/mysql-test/include/plugin.defs 2011-12-19 19:15:18.000000000 +0800 |
679 | +@@ -40,3 +40,5 @@ |
680 | + ha_federated storage/federated FEDERATED_PLUGIN |
681 | + mypluglib plugin/fulltext SIMPLE_PARSER |
682 | + libdaemon_example plugin/daemon_example DAEMONEXAMPLE |
683 | ++slowlog_in_memory plugin/slowlog_in_memory SLOW_LOG |
684 | ++slowlog_in_memory plugin/slowlog_in_memory SLOW_LOG_IN_MEMORY_AUDIT |
685 | +--- a/mysql-test/r/slow_log_in_memory.result 1970-01-01 08:00:00.000000000 +0800 |
686 | ++++ b/mysql-test/r/slow_log_in_memory.result 2011-12-19 19:10:14.000000000 +0800 |
687 | +@@ -0,0 +1,67 @@ |
688 | ++# |
689 | ++# feature: slow log show in information_schema.slow_log |
690 | ++# |
691 | ++install plugin SLOWLOG_IN_MEMORY_AUDIT soname 'slowlog_in_memory.so'; |
692 | ++install plugin SLOW_LOG soname 'slowlog_in_memory.so'; |
693 | ++show variables like 'slowlog_in_memory_audit_max_memory'; |
694 | ++Variable_name Value |
695 | ++slowlog_in_memory_audit_max_memory 1048576 |
696 | ++SET long_query_time=2; |
697 | ++SET query_exec_time=2.1; |
698 | ++select 1; |
699 | ++1 |
700 | ++1 |
701 | ++SET query_exec_time=0; |
702 | ++SET long_query_time=2; |
703 | ++SET query_exec_time=2.1; |
704 | ++select 1; |
705 | ++1 |
706 | ++1 |
707 | ++SET query_exec_time=0; |
708 | ++SET long_query_time=2; |
709 | ++SET query_exec_time=2.1; |
710 | ++select 1; |
711 | ++1 |
712 | ++1 |
713 | ++SET query_exec_time=0; |
714 | ++show global status like 'slow_log_current_memory'; |
715 | ++Variable_name Value |
716 | ++slow_log_current_memory XX |
717 | ++select * from information_schema.slow_log; |
718 | ++EVENT_ID TIMESTAMP THREAD_ID DB INNODB_TRX_ID ERRNO MS_QUERY_TIME QUERY |
719 | ++1 XX 1 test XX 0 2100 select 1 |
720 | ++2 XX 2 test XX 0 2100 select 1 |
721 | ++3 XX 3 test XX 0 2100 select 1 |
722 | ++# decrease max_memory and wash eldest |
723 | ++set global slowlog_in_memory_audit_max_memory=240; |
724 | ++use information_schema; |
725 | ++SET long_query_time=2; |
726 | ++SET query_exec_time=2.1; |
727 | ++select 1; |
728 | ++1 |
729 | ++1 |
730 | ++SET query_exec_time=0; |
731 | ++show global status like 'slow_log_current_memory'; |
732 | ++Variable_name Value |
733 | ++slow_log_current_memory XX |
734 | ++select * from information_schema.slow_log; |
735 | ++EVENT_ID TIMESTAMP THREAD_ID DB INNODB_TRX_ID ERRNO MS_QUERY_TIME QUERY |
736 | ++3 XX 3 test XX 0 2100 select 1 |
737 | ++4 XX 2 information_schema XX 0 2100 select 1 |
738 | ++# set to zero to disable audit |
739 | ++set global slowlog_in_memory_audit_max_memory=0; |
740 | ++SET long_query_time=2; |
741 | ++SET query_exec_time=2.1; |
742 | ++select 1; |
743 | ++1 |
744 | ++1 |
745 | ++SET query_exec_time=0; |
746 | ++show global status like 'slow_log_current_memory'; |
747 | ++Variable_name Value |
748 | ++slow_log_current_memory 0 |
749 | ++select * from information_schema.slow_log; |
750 | ++EVENT_ID TIMESTAMP THREAD_ID DB INNODB_TRX_ID ERRNO MS_QUERY_TIME QUERY |
751 | ++uninstall plugin SLOW_LOG; |
752 | ++uninstall plugin SLOWLOG_IN_MEMORY_AUDIT; |
753 | ++Warnings: |
754 | ++Warning 1620 Plugin is busy and will be uninstalled on shutdown |
755 | +--- a/mysql-test/suite/sys_vars/r/slow_log_in_memory_audit.result 1970-01-01 08:00:00.000000000 +0800 |
756 | ++++ b/mysql-test/suite/sys_vars/r/slow_log_in_memory_audit.result 2011-12-19 19:12:14.000000000 +0800 |
757 | +@@ -0,0 +1,31 @@ |
758 | ++install plugin SLOWLOG_IN_MEMORY_AUDIT soname 'slowlog_in_memory.so'; |
759 | ++install plugin SLOW_LOG soname 'slowlog_in_memory.so'; |
760 | ++select @@global.slowlog_in_memory_audit_max_memory; |
761 | ++@@global.slowlog_in_memory_audit_max_memory |
762 | ++1048576 |
763 | ++show global variables like 'slowlog_in_memory_audit_max_memory'; |
764 | ++Variable_name Value |
765 | ++slowlog_in_memory_audit_max_memory 1048576 |
766 | ++select * from information_schema.global_variables where variable_name='slowlog_in_memory_audit_max_memory'; |
767 | ++VARIABLE_NAME VARIABLE_VALUE |
768 | ++SLOWLOG_IN_MEMORY_AUDIT_MAX_MEMORY 1048576 |
769 | ++set global slowlog_in_memory_audit_max_memory=2097152; |
770 | ++select @@global.slowlog_in_memory_audit_max_memory; |
771 | ++@@global.slowlog_in_memory_audit_max_memory |
772 | ++2097152 |
773 | ++show global variables like 'slowlog_in_memory_audit_max_memory'; |
774 | ++Variable_name Value |
775 | ++slowlog_in_memory_audit_max_memory 2097152 |
776 | ++set global slowlog_in_memory_audit_max_memory=1.1; |
777 | ++ERROR 42000: Incorrect argument type to variable 'slowlog_in_memory_audit_max_memory' |
778 | ++set global slowlog_in_memory_audit_max_memory=1e1; |
779 | ++ERROR 42000: Incorrect argument type to variable 'slowlog_in_memory_audit_max_memory' |
780 | ++set global slowlog_in_memory_audit_max_memory="some text"; |
781 | ++ERROR 42000: Incorrect argument type to variable 'slowlog_in_memory_audit_max_memory' |
782 | ++select @@global.slowlog_in_memory_audit_max_memory; |
783 | ++@@global.slowlog_in_memory_audit_max_memory |
784 | ++2097152 |
785 | ++UNINSTALL PLUGIN SLOW_LOG; |
786 | ++UNINSTALL PLUGIN SLOWLOG_IN_MEMORY_AUDIT; |
787 | ++Warnings: |
788 | ++Warning 1620 Plugin is busy and will be uninstalled on shutdown |
789 | +--- a/mysql-test/suite/sys_vars/t/slow_log_in_memory_audit-master.opt 1970-01-01 08:00:00.000000000 +0800 |
790 | ++++ b/mysql-test/suite/sys_vars/t/slow_log_in_memory_audit-master.opt 2011-12-19 19:12:02.000000000 +0800 |
791 | +@@ -0,0 +1 @@ |
792 | ++$SLOW_LOG_IN_MEMORY_AUDIT_OPT |
793 | +--- a/mysql-test/suite/sys_vars/t/slow_log_in_memory_audit.test 1970-01-01 08:00:00.000000000 +0800 |
794 | ++++ b/mysql-test/suite/sys_vars/t/slow_log_in_memory_audit.test 2011-12-19 19:12:02.000000000 +0800 |
795 | +@@ -0,0 +1,40 @@ |
796 | ++ |
797 | ++# |
798 | ++# exists as a global only |
799 | ++# |
800 | ++source include/not_embedded.inc; |
801 | ++source include/have_slog_log_in_memory_audit_plugin.inc; |
802 | ++# The following is to prevent a mis-match on windows that has the name of of the lib ending with 'dll' |
803 | ++--replace_regex /\.dll/.so/ |
804 | ++install plugin SLOWLOG_IN_MEMORY_AUDIT soname 'slowlog_in_memory.so'; |
805 | ++install plugin SLOW_LOG soname 'slowlog_in_memory.so'; |
806 | ++select @@global.slowlog_in_memory_audit_max_memory; |
807 | ++ |
808 | ++show global variables like 'slowlog_in_memory_audit_max_memory'; |
809 | ++select * from information_schema.global_variables where variable_name='slowlog_in_memory_audit_max_memory'; |
810 | ++ |
811 | ++# |
812 | ++# show that it's writable |
813 | ++# |
814 | ++set global slowlog_in_memory_audit_max_memory=2097152; |
815 | ++select @@global.slowlog_in_memory_audit_max_memory; |
816 | ++show global variables like 'slowlog_in_memory_audit_max_memory'; |
817 | ++ |
818 | ++# |
819 | ++# incorrect types |
820 | ++# |
821 | ++--error ER_WRONG_TYPE_FOR_VAR |
822 | ++set global slowlog_in_memory_audit_max_memory=1.1; |
823 | ++--error ER_WRONG_TYPE_FOR_VAR |
824 | ++set global slowlog_in_memory_audit_max_memory=1e1; |
825 | ++--error ER_WRONG_TYPE_FOR_VAR |
826 | ++set global slowlog_in_memory_audit_max_memory="some text"; |
827 | ++ |
828 | ++ |
829 | ++# |
830 | ++# Cleanup |
831 | ++# |
832 | ++select @@global.slowlog_in_memory_audit_max_memory; |
833 | ++UNINSTALL PLUGIN SLOW_LOG; |
834 | ++UNINSTALL PLUGIN SLOWLOG_IN_MEMORY_AUDIT; |
835 | ++ |
836 | +--- a/mysql-test/t/slow_log_in_memory-master.opt 1970-01-01 08:00:00.000000000 +0800 |
837 | ++++ b/mysql-test/t/slow_log_in_memory-master.opt 2011-12-19 19:10:07.000000000 +0800 |
838 | +@@ -0,0 +1 @@ |
839 | ++$SLOW_LOG_IN_MEMORY_AUDIT_OPT |
840 | +--- a/mysql-test/t/slow_log_in_memory.test 1970-01-01 08:00:00.000000000 +0800 |
841 | ++++ b/mysql-test/t/slow_log_in_memory.test 2011-12-19 19:10:07.000000000 +0800 |
842 | +@@ -0,0 +1,60 @@ |
843 | ++--source include/have_debug.inc |
844 | ++--source include/have_slog_log_in_memory_audit_plugin.inc |
845 | ++ |
846 | ++--echo # |
847 | ++--echo # feature: slow log show in information_schema.slow_log |
848 | ++--echo # |
849 | ++ |
850 | ++-- source include/restart_mysqld.inc |
851 | ++install plugin SLOWLOG_IN_MEMORY_AUDIT soname 'slowlog_in_memory.so'; |
852 | ++install plugin SLOW_LOG soname 'slowlog_in_memory.so'; |
853 | ++show variables like 'slowlog_in_memory_audit_max_memory'; |
854 | ++ |
855 | ++SET long_query_time=2; |
856 | ++SET query_exec_time=2.1; |
857 | ++select 1; |
858 | ++SET query_exec_time=0; |
859 | ++ |
860 | ++connect (con1,localhost,root,,); |
861 | ++ |
862 | ++SET long_query_time=2; |
863 | ++SET query_exec_time=2.1; |
864 | ++select 1; |
865 | ++SET query_exec_time=0; |
866 | ++ |
867 | ++connect (con2,localhost,root,,); |
868 | ++ |
869 | ++SET long_query_time=2; |
870 | ++SET query_exec_time=2.1; |
871 | ++select 1; |
872 | ++SET query_exec_time=0; |
873 | ++--replace_column 2 XX |
874 | ++show global status like 'slow_log_current_memory'; |
875 | ++--replace_column 2 XX 5 XX |
876 | ++select * from information_schema.slow_log; |
877 | ++ |
878 | ++--echo # decrease max_memory and wash eldest |
879 | ++set global slowlog_in_memory_audit_max_memory=240; |
880 | ++connection con1; |
881 | ++use information_schema; |
882 | ++SET long_query_time=2; |
883 | ++SET query_exec_time=2.1; |
884 | ++select 1; |
885 | ++SET query_exec_time=0; |
886 | ++--replace_column 2 XX |
887 | ++show global status like 'slow_log_current_memory'; |
888 | ++--replace_column 2 XX 5 XX |
889 | ++select * from information_schema.slow_log; |
890 | ++ |
891 | ++--echo # set to zero to disable audit |
892 | ++connection con1; |
893 | ++set global slowlog_in_memory_audit_max_memory=0; |
894 | ++SET long_query_time=2; |
895 | ++SET query_exec_time=2.1; |
896 | ++select 1; |
897 | ++SET query_exec_time=0; |
898 | ++show global status like 'slow_log_current_memory'; |
899 | ++select * from information_schema.slow_log; |
900 | ++ |
901 | ++uninstall plugin SLOW_LOG; |
902 | ++uninstall plugin SLOWLOG_IN_MEMORY_AUDIT; |
1. Please add patch name to the "patches/series" file
2. About innodb_trx_id. Please look to two following cases:
* log_slow_verbosity doesn't set "innodb"
* query doesn't use the InnoDB
In first case slow query log will has no information about InnoDB
In second case slow query will have line "# No InnoDB statistics available for this query\n"
In this two cases innodb_trx_id will be incorrect, and you can't use and setup it.
Please handle variable innodb_was_used correctly (at least for innodb_trx_id)
3. Following is very, very bad: query= "NULL"; query_len= 5; SCHEMA. I_S_SLOW_ LOG WHERE QUERY IS NULL
+ if (general_query)
+ {
....
+ }
+ else
+ {
+ this->general_
+ this->general_
+ }
You are break SQL semantic. For example query:
SELECT * FROM INSFORMATION_
or any join will not work correctly.
You are break SQL language semantic by string "NULL" instead of NULL
Same for Schema.
4. I_S_SLOW_LOG not very good name. Why SLOW_LOG bad?
5. Please add documentation to the doc/
6. Sleep in the test file - bad idea. Please replace this by debug variable query_exec_time.
7. Please add tests to sys_vars suite for the all added variables.
Please fix this, and I will review again.