Merge lp:~sergei.glushchenko/percona-server/disable-flashcache into lp:percona-server/5.1

Proposed by Sergei Glushchenko
Status: Merged
Approved by: Alexey Kopytov
Approved revision: no longer in the source branch.
Merged at revision: 480
Proposed branch: lp:~sergei.glushchenko/percona-server/disable-flashcache
Merge into: lp:percona-server/5.1
Diff against target: 227 lines (+71/-15)
9 files modified
Percona-Server/mysql-test/include/have_flashcache.inc (+7/-0)
Percona-Server/mysql-test/r/have_flashcache.require (+2/-0)
Percona-Server/mysql-test/r/percona_bug747032.result (+1/-0)
Percona-Server/mysql-test/r/percona_server_variables_debug.result (+1/-0)
Percona-Server/mysql-test/r/percona_server_variables_release.result (+1/-0)
Percona-Server/mysql-test/t/percona_bug747032.test (+32/-0)
Percona-Server/sql/mysql_priv.h (+1/-0)
Percona-Server/sql/mysqld.cc (+25/-15)
Percona-Server/sql/set_var.cc (+1/-0)
To merge this branch: bzr merge lp:~sergei.glushchenko/percona-server/disable-flashcache
Reviewer Review Type Date Requested Status
Alexey Kopytov (community) Approve
Review via email: mp+121389@code.launchpad.net

Description of the change

Bug #747032: Flashcache throws an error on startup when flashcache is not used
New boolean option --flashcache was introduced. When set to 0, flashcache
checks are disabled. Default is to disable checks.
Also error message been made more verbose including errno and system error
message.

http://jenkins.percona.com/view/PS%205.1/job/percona-server-5.1-param/393/

To post a comment you must log in.
Revision history for this message
Alexey Kopytov (akopytov) wrote :

Sergei,

   - since after this fix flashcache is disabled by default, failure to
     set it up when it's _explicitly_ enabled should be a fatal error
   - the above also means the error should be printed with
     sql_print_error() rather than sql_print_information()
   - that also means the code printing the "Flashcache bypass" message
     does not have to check if initialization was successful (it should
     just say "flashcache support initialized successfully")
   - strerror() is not portable. which is not that important in this
     case, of course, but I would use sql_perror() for consistency.
   - the command line option is available only on Linux, whereas the
     test case includes "not_windows.inc". Which is not the same set of
     platforms, it will fail on all non-Windows platforms except Linux
   - the test case dependency on external utilities like grep and sed is
     redundant, even though it might work in most cases (since this is a
     Linux-specific test).

   I think a clean way to implement the test case would be to add
   'include/have_flashcache.inc' (which would also require a separate
   status variable). So you can easily check if the code you are going
   to test is present in the binary. You should also test only the
   --flashcache=0 case (i.e. the default) and make sure the
   initialization message is not present in the error log. Then you only
   need a few lines in Perl to implement that (see
   percona_log_warnings_suppress.test for an example).

review: Needs Fixing
Revision history for this message
Sergei Glushchenko (sergei.glushchenko) wrote :

Alexey,

> I think a clean way to implement the test case would be to add
> 'include/have_flashcache.inc' (which would also require a separate
> status variable). So you can easily check if the code you are going
> to test is present in the binary. You should also test only the
> --flashcache=0 case (i.e. the default) and make sure the
> initialization message is not present in the error log. Then you only
> need a few lines in Perl to implement that (see
> percona_log_warnings_suppress.test for an example).

There is already status variable Flashcache_enabled, which can be used to check flashcache presence. I'm thinking of having include/not_flashcache.inc.

Testcase will look like:

--include not_flashcache.inc

# Some perl code to check the 'Flashcache bypass ...' message absence

Revision history for this message
Sergei Glushchenko (sergei.glushchenko) wrote :

Testcase been reworked as described above.
Other comments been also taken into account.

Revision history for this message
Alexey Kopytov (akopytov) wrote :

On 27.08.12 16:03, Sergei Glushchenko wrote:
> Alexey,
>
>> I think a clean way to implement the test case would be to add
>> 'include/have_flashcache.inc' (which would also require a separate
>> status variable). So you can easily check if the code you are going
>> to test is present in the binary. You should also test only the
>> --flashcache=0 case (i.e. the default) and make sure the
>> initialization message is not present in the error log. Then you only
>> need a few lines in Perl to implement that (see
>> percona_log_warnings_suppress.test for an example).
>
> There is already status variable Flashcache_enabled, which can be used to check flashcache presence. I'm thinking of having include/not_flashcache.inc.
>

No, Flashcache_enabled is present on all platforms, even on Windows. And
it will always be OFF on all platforms, since the test case does not
enable it explicitly. So not_flashcache.inc does not really check
anything, all platforms and binaries will pass it. Besides, the name of
that check is weird: we actually want to run this test when the
flashcache support is ON, so "include/not_flashcache.inc" is confusing.

I was talking about a separate system variable (not a status one, sorry)
similar to have_query_cache, have_partitioning, etc. that would only be
TRUE if the binary has flashcache code compiled in (i.e. is a Linux binary).

Revision history for this message
Sergei Glushchenko (sergei.glushchenko) wrote :

I got it. I added system variable have_flashcache, which indicates presence of flashcache code, which means it is always YES on Linux, and always NO on other platforms. Testcase been reworked to use this variable.

Revision history for this message
Alexey Kopytov (akopytov) wrote :

Looks good, thanks. Please don't forget to submit a 5.5 MP.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added file 'Percona-Server/mysql-test/include/have_flashcache.inc'
--- Percona-Server/mysql-test/include/have_flashcache.inc 1970-01-01 00:00:00 +0000
+++ Percona-Server/mysql-test/include/have_flashcache.inc 2012-08-27 15:37:32 +0000
@@ -0,0 +1,7 @@
1# check if binary compiled with flashcache support
2
3-- require r/have_flashcache.require
4
5disable_query_log;
6show variables like 'have_flashcache';
7enable_query_log;
08
=== added file 'Percona-Server/mysql-test/r/have_flashcache.require'
--- Percona-Server/mysql-test/r/have_flashcache.require 1970-01-01 00:00:00 +0000
+++ Percona-Server/mysql-test/r/have_flashcache.require 2012-08-27 15:37:32 +0000
@@ -0,0 +1,2 @@
1Variable_name Value
2have_flashcache YES
03
=== added file 'Percona-Server/mysql-test/r/percona_bug747032.result'
--- Percona-Server/mysql-test/r/percona_bug747032.result 1970-01-01 00:00:00 +0000
+++ Percona-Server/mysql-test/r/percona_bug747032.result 2012-08-27 15:37:32 +0000
@@ -0,0 +1,1 @@
1Occurrences: 0
02
=== modified file 'Percona-Server/mysql-test/r/percona_server_variables_debug.result'
--- Percona-Server/mysql-test/r/percona_server_variables_debug.result 2012-08-20 05:07:28 +0000
+++ Percona-Server/mysql-test/r/percona_server_variables_debug.result 2012-08-27 15:37:32 +0000
@@ -59,6 +59,7 @@
59HAVE_CRYPT59HAVE_CRYPT
60HAVE_CSV60HAVE_CSV
61HAVE_DYNAMIC_LOADING61HAVE_DYNAMIC_LOADING
62HAVE_FLASHCACHE
62HAVE_GEOMETRY63HAVE_GEOMETRY
63HAVE_INNODB64HAVE_INNODB
64HAVE_NDBCLUSTER65HAVE_NDBCLUSTER
6566
=== modified file 'Percona-Server/mysql-test/r/percona_server_variables_release.result'
--- Percona-Server/mysql-test/r/percona_server_variables_release.result 2012-08-20 03:14:02 +0000
+++ Percona-Server/mysql-test/r/percona_server_variables_release.result 2012-08-27 15:37:32 +0000
@@ -57,6 +57,7 @@
57HAVE_CRYPT57HAVE_CRYPT
58HAVE_CSV58HAVE_CSV
59HAVE_DYNAMIC_LOADING59HAVE_DYNAMIC_LOADING
60HAVE_FLASHCACHE
60HAVE_GEOMETRY61HAVE_GEOMETRY
61HAVE_INNODB62HAVE_INNODB
62HAVE_NDBCLUSTER63HAVE_NDBCLUSTER
6364
=== added file 'Percona-Server/mysql-test/t/percona_bug747032.test'
--- Percona-Server/mysql-test/t/percona_bug747032.test 1970-01-01 00:00:00 +0000
+++ Percona-Server/mysql-test/t/percona_bug747032.test 2012-08-27 15:37:32 +0000
@@ -0,0 +1,32 @@
1###################### percona_bug747032.test ########################
2# Bug #747032: Flashcache throws an error on startup when flashcache #
3# is not used #
4# #
5# Test is designed to verify that --flashcache option work properly #
6# to disable flashcache checks at startup #
7######################################################################
8
9--source include/not_embedded.inc
10--source include/have_flashcache.inc
11
12let $log_error_= `SELECT @@GLOBAL.log_error`;
13if(!`select LENGTH('$log_error_')`)
14{
15 # MySQL Server on windows is started with --console and thus
16 # does not know the location of its .err log, use default location
17 let $log_error_ = $MYSQLTEST_VARDIR/log/mysqld.1.err;
18}
19# Assign env variable LOG_ERROR
20let LOG_ERROR=$log_error_;
21
22perl;
23 use strict;
24 my $log_error= $ENV{'LOG_ERROR'} or die "LOG_ERROR not set";
25 open(FILE, "$log_error") or die("Unable to open $log_error: $!\n");
26 my $count = grep(/Flashcache bypass support initialized successfully/g,<FILE>);
27 print "Occurrences: $count\n";
28 close(FILE);
29 # Clean error log file
30 open(FILE, '>', "$log_error");
31 close(FILE);
32EOF
033
=== modified file 'Percona-Server/sql/mysql_priv.h'
--- Percona-Server/sql/mysql_priv.h 2012-08-20 03:14:02 +0000
+++ Percona-Server/sql/mysql_priv.h 2012-08-27 15:37:32 +0000
@@ -2229,6 +2229,7 @@
2229extern SHOW_COMP_OPTION have_geometry, have_rtree_keys;2229extern SHOW_COMP_OPTION have_geometry, have_rtree_keys;
2230extern SHOW_COMP_OPTION have_crypt;2230extern SHOW_COMP_OPTION have_crypt;
2231extern SHOW_COMP_OPTION have_compress;2231extern SHOW_COMP_OPTION have_compress;
2232extern SHOW_COMP_OPTION have_flashcache;
22322233
2233extern int orig_argc;2234extern int orig_argc;
2234extern char **orig_argv;2235extern char **orig_argv;
22352236
=== modified file 'Percona-Server/sql/mysqld.cc'
--- Percona-Server/sql/mysqld.cc 2012-08-20 03:14:02 +0000
+++ Percona-Server/sql/mysqld.cc 2012-08-27 15:37:32 +0000
@@ -714,6 +714,7 @@
714SHOW_COMP_OPTION have_geometry, have_rtree_keys;714SHOW_COMP_OPTION have_geometry, have_rtree_keys;
715SHOW_COMP_OPTION have_crypt, have_compress;715SHOW_COMP_OPTION have_crypt, have_compress;
716SHOW_COMP_OPTION have_community_features;716SHOW_COMP_OPTION have_community_features;
717SHOW_COMP_OPTION have_flashcache;
717718
718/* Thread specific variables */719/* Thread specific variables */
719720
@@ -4288,24 +4289,23 @@
42884289
4289 // disabled by default4290 // disabled by default
4290 cachedev_fd = -1;4291 cachedev_fd = -1;
4291 cachedev_enabled= FALSE;
42924292
4293 if (!mysql_data_home)4293 if (!mysql_data_home)
4294 {4294 {
4295 error_message= "mysql_data_home not set";4295 error_message= "Flashcache setup error (mysql_data_home not set)";
4296 goto epilogue;4296 goto epilogue;
4297 }4297 }
42984298
4299 if (statfs(mysql_data_home, &stfs_data_home_dir) < 0)4299 if (statfs(mysql_data_home, &stfs_data_home_dir) < 0)
4300 {4300 {
4301 error_message= "statfs failed";4301 error_message= "Flashcache setup error (statfs)";
4302 goto epilogue;4302 goto epilogue;
4303 }4303 }
43044304
4305 mounts = setmntent("/etc/mtab", "r");4305 mounts = setmntent("/etc/mtab", "r");
4306 if (mounts == NULL)4306 if (mounts == NULL)
4307 {4307 {
4308 error_message= "setmntent failed";4308 error_message= "Flashcache setup error (setmntent)";
4309 goto epilogue;4309 goto epilogue;
4310 }4310 }
43114311
@@ -4320,14 +4320,14 @@
43204320
4321 if (ent == NULL)4321 if (ent == NULL)
4322 {4322 {
4323 error_message= "getmntent loop failed";4323 error_message= "Flashcache setup error (getmntent loop)";
4324 goto epilogue;4324 goto epilogue;
4325 }4325 }
43264326
4327 cachedev_fd = open(ent->mnt_fsname, O_RDONLY);4327 cachedev_fd = open(ent->mnt_fsname, O_RDONLY);
4328 if (cachedev_fd < 0)4328 if (cachedev_fd < 0)
4329 {4329 {
4330 error_message= "open flash device failed";4330 error_message= "Flashcache setup error (open flash device)";
4331 goto epilogue;4331 goto epilogue;
4332 }4332 }
43334333
@@ -4336,18 +4336,17 @@
4336 {4336 {
4337 close(cachedev_fd);4337 close(cachedev_fd);
4338 cachedev_fd = -1;4338 cachedev_fd = -1;
4339 error_message= "ioctl failed";4339 error_message= "Flashcache setup error (ioctl)";
4340 } else {4340 } else {
4341 ioctl(cachedev_fd, FLASHCACHEADDWHITELIST, &pid);4341 ioctl(cachedev_fd, FLASHCACHEADDWHITELIST, &pid);
4342 }4342 }
43434343
4344epilogue:4344epilogue:
4345 sql_print_information("Flashcache bypass: %s",4345 if (error_message) {
4346 (cachedev_fd > 0) ? "enabled" : "disabled");4346 sql_perror(error_message);
4347 if (error_message)4347 unireg_abort(1);
4348 sql_print_information("Flashcache setup error is : %s\n", error_message);4348 }
4349 else4349 sql_print_information("Flashcache bypass support initialized successfully");
4350 cachedev_enabled= TRUE;
43514350
4352}4351}
43534352
@@ -4471,7 +4470,11 @@
4471#endif4470#endif
44724471
4473#if defined(__linux__)4472#if defined(__linux__)
4474 init_cachedev();4473 have_flashcache= SHOW_OPTION_YES;
4474 if (cachedev_enabled)
4475 init_cachedev();
4476#else
4477 have_flashcache= SHOW_OPTION_NO;
4475#endif//__linux__4478#endif//__linux__
44764479
4477 /*4480 /*
@@ -5925,7 +5928,8 @@
5925 OPT_BINLOG_DIRECT_NON_TRANS_UPDATE,5928 OPT_BINLOG_DIRECT_NON_TRANS_UPDATE,
5926 OPT_DEFAULT_CHARACTER_SET_OLD,5929 OPT_DEFAULT_CHARACTER_SET_OLD,
5927 OPT_MAX_LONG_DATA_SIZE,5930 OPT_MAX_LONG_DATA_SIZE,
5928 OPT_EXPAND_FAST_INDEX_CREATION5931 OPT_EXPAND_FAST_INDEX_CREATION,
5932 OPT_FLASHCACHE
5929};5933};
59305934
59315935
@@ -7504,6 +7508,12 @@
7504 &global_system_variables.binlog_direct_non_trans_update,7508 &global_system_variables.binlog_direct_non_trans_update,
7505 &max_system_variables.binlog_direct_non_trans_update,7509 &max_system_variables.binlog_direct_non_trans_update,
7506 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},7510 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
7511 {"flashcache",
7512 OPT_FLASHCACHE,
7513 "Enable flashcache detection.",
7514 &cachedev_enabled,
7515 &cachedev_enabled,
7516 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0},
7507 {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}7517 {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
7508};7518};
75097519
75107520
=== modified file 'Percona-Server/sql/set_var.cc'
--- Percona-Server/sql/set_var.cc 2012-08-20 03:14:02 +0000
+++ Percona-Server/sql/set_var.cc 2012-08-27 15:37:32 +0000
@@ -987,6 +987,7 @@
987static sys_var_have_variable sys_have_community_features(&vars, "have_community_features", &have_community_features);987static sys_var_have_variable sys_have_community_features(&vars, "have_community_features", &have_community_features);
988static sys_var_have_variable sys_have_rtree_keys(&vars, "have_rtree_keys", &have_rtree_keys);988static sys_var_have_variable sys_have_rtree_keys(&vars, "have_rtree_keys", &have_rtree_keys);
989static sys_var_have_variable sys_have_symlink(&vars, "have_symlink", &have_symlink);989static sys_var_have_variable sys_have_symlink(&vars, "have_symlink", &have_symlink);
990static sys_var_have_variable sys_have_flashcache(&vars, "have_flashcache", &have_flashcache);
990/* Global read-only variable describing server license */991/* Global read-only variable describing server license */
991static sys_var_const_str sys_license(&vars, "license", STRINGIFY_ARG(LICENSE));992static sys_var_const_str sys_license(&vars, "license", STRINGIFY_ARG(LICENSE));
992/* Global variables which enable|disable logging */993/* Global variables which enable|disable logging */

Subscribers

People subscribed via source and target branches