diff options
author | Nirbhay Choubey <nirbhay@skysql.com> | 2014-09-08 21:21:37 -0400 |
---|---|---|
committer | Nirbhay Choubey <nirbhay@skysql.com> | 2014-09-08 21:21:37 -0400 |
commit | 47fcca0ffcc09623731f3e36d61ccc8da6b0f493 (patch) | |
tree | edfe9229531d2c035a8547b2c20e7caaee4ccd0a /sql | |
parent | c0483b00295612372af6b33c6613a1a8bd839096 (diff) | |
download | mariadb-git-47fcca0ffcc09623731f3e36d61ccc8da6b0f493.tar.gz |
MDEV-6667 : Improved handling of wsrep-new-cluster option
Code refactoring. Using mysql option handling system to
handle 'wsrep-new-cluster' option.
Diffstat (limited to 'sql')
-rw-r--r-- | sql/mysqld.cc | 11 | ||||
-rw-r--r-- | sql/wsrep_mysqld.cc | 39 | ||||
-rw-r--r-- | sql/wsrep_mysqld.h | 5 |
3 files changed, 16 insertions, 39 deletions
diff --git a/sql/mysqld.cc b/sql/mysqld.cc index b2b22c1968d..bd2447cad58 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -386,6 +386,7 @@ static DYNAMIC_ARRAY all_options; #ifdef WITH_WSREP ulong my_bind_addr; +bool wsrep_new_cluster= false; #endif /* WITH_WSREP */ bool opt_bin_log, opt_bin_log_used=0, opt_ignore_builtin_innodb= 0; my_bool opt_log, opt_slow_log, debug_assert_if_crashed_table= 0, opt_help= 0; @@ -5899,9 +5900,6 @@ int mysqld_main(int argc, char **argv) return 1; } #endif -#ifdef WITH_WSREP - wsrep_filter_new_cluster (&argc, argv); -#endif /* WITH_WSREP */ orig_argc= argc; orig_argv= argv; @@ -7884,6 +7882,13 @@ struct my_option my_long_options[]= {"table_cache", 0, "Deprecated; use --table-open-cache instead.", &tc_size, &tc_size, 0, GET_ULONG, REQUIRED_ARG, TABLE_OPEN_CACHE_DEFAULT, 1, 512*1024L, 0, 1, 0}, +#ifdef WITH_WSREP + {"wsrep-new-cluster", 0, "Bootstrap a cluster. It works by overriding the " + "current value of wsrep_cluster_address. It is recommended not to add this " + "option to the config file as this will trigger bootstrap on every server " + "start.", &wsrep_new_cluster, &wsrep_new_cluster, 0, GET_BOOL, NO_ARG, + 0, 0, 0, 0, 0, 0}, +#endif /* The following options exist in 5.6 but not in 10.0 */ MYSQL_TO_BE_IMPLEMENTED_OPTION("default-tmp-storage-engine"), diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc index 38b6f4dfe59..7bf2cdda34f 100644 --- a/sql/wsrep_mysqld.cc +++ b/sql/wsrep_mysqld.cc @@ -781,36 +781,6 @@ void wsrep_stop_replication(THD *thd) return; } -/* This one is set to true when --wsrep-new-cluster is found in the command - * line arguments */ -static my_bool wsrep_new_cluster= FALSE; -#define WSREP_NEW_CLUSTER "--wsrep-new-cluster" -/* Finds and hides --wsrep-new-cluster from the arguments list - * by moving it to the end of the list and decrementing argument count */ -void wsrep_filter_new_cluster (int* argc, char* argv[]) -{ - int i; - for (i= *argc - 1; i > 0; i--) - { - /* make a copy of the argument to convert possible underscores to hyphens. - * the copy need not to be longer than WSREP_NEW_CLUSTER option */ - char arg[sizeof(WSREP_NEW_CLUSTER) + 1]= { 0, }; - strncpy(arg, argv[i], sizeof(arg) - 1); - char* underscore(arg); - while (NULL != (underscore= strchr(underscore, '_'))) *underscore= '-'; - - if (!strcmp(arg, WSREP_NEW_CLUSTER)) - { - wsrep_new_cluster= TRUE; - *argc -= 1; - /* preserve the order of remaining arguments AND - * preserve the original argument pointers - just in case */ - char* wnc= argv[i]; - memmove(&argv[i], &argv[i + 1], (*argc - i)*sizeof(argv[i])); - argv[*argc]= wnc; /* this will be invisible to the rest of the program */ - } - } -} bool wsrep_start_replication() { @@ -834,11 +804,16 @@ bool wsrep_start_replication() return true; } - bool const bootstrap(TRUE == wsrep_new_cluster); - wsrep_new_cluster= FALSE; + bool const bootstrap= wsrep_new_cluster; WSREP_INFO("Start replication"); + if (wsrep_new_cluster) + { + WSREP_INFO("'wsrep-new-cluster' option used, bootstrapping the cluster"); + wsrep_new_cluster= false; + } + if ((rcode = wsrep->connect(wsrep, wsrep_cluster_name, wsrep_cluster_address, diff --git a/sql/wsrep_mysqld.h b/sql/wsrep_mysqld.h index 2e226be0318..a42f69276d7 100644 --- a/sql/wsrep_mysqld.h +++ b/sql/wsrep_mysqld.h @@ -100,6 +100,7 @@ extern my_bool wsrep_restart_slave; extern my_bool wsrep_restart_slave_activated; extern my_bool wsrep_slave_FK_checks; extern my_bool wsrep_slave_UK_checks; +extern bool wsrep_new_cluster; // bootstrap the cluster ? enum enum_wsrep_OSU_method { WSREP_OSU_TOI, WSREP_OSU_RSU }; enum enum_wsrep_sync_wait { @@ -127,10 +128,6 @@ extern const char* wsrep_provider_vendor; int wsrep_show_status(THD *thd, SHOW_VAR *var, char *buff); void wsrep_free_status(THD *thd); -/* Filters out --wsrep-new-cluster oprtion from argv[] - * should be called in the very beginning of main() */ -void wsrep_filter_new_cluster (int* argc, char* argv[]); - int wsrep_init(); void wsrep_deinit(bool free_options); void wsrep_recover(); |