Commit 47fcca0f authored by Nirbhay Choubey's avatar Nirbhay Choubey

MDEV-6667 : Improved handling of wsrep-new-cluster option

Code refactoring. Using mysql option handling system to
handle 'wsrep-new-cluster' option.
parent c0483b00
...@@ -1091,6 +1091,10 @@ The following options may be given as the first argument: ...@@ -1091,6 +1091,10 @@ The following options may be given as the first argument:
Max write set size (bytes) Max write set size (bytes)
--wsrep-mysql-replication-bundle=# --wsrep-mysql-replication-bundle=#
mysql replication group commit mysql replication group commit
--wsrep-new-cluster 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-node-address=name --wsrep-node-address=name
Node address Node address
--wsrep-node-incoming-address=name --wsrep-node-incoming-address=name
...@@ -1454,6 +1458,7 @@ wsrep-log-conflicts FALSE ...@@ -1454,6 +1458,7 @@ wsrep-log-conflicts FALSE
wsrep-max-ws-rows 131072 wsrep-max-ws-rows 131072
wsrep-max-ws-size 1073741824 wsrep-max-ws-size 1073741824
wsrep-mysql-replication-bundle 0 wsrep-mysql-replication-bundle 0
wsrep-new-cluster FALSE
wsrep-node-address wsrep-node-address
wsrep-node-incoming-address AUTO wsrep-node-incoming-address AUTO
wsrep-notify-cmd wsrep-notify-cmd
......
...@@ -386,6 +386,7 @@ static DYNAMIC_ARRAY all_options; ...@@ -386,6 +386,7 @@ static DYNAMIC_ARRAY all_options;
#ifdef WITH_WSREP #ifdef WITH_WSREP
ulong my_bind_addr; ulong my_bind_addr;
bool wsrep_new_cluster= false;
#endif /* WITH_WSREP */ #endif /* WITH_WSREP */
bool opt_bin_log, opt_bin_log_used=0, opt_ignore_builtin_innodb= 0; 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; 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) ...@@ -5899,9 +5900,6 @@ int mysqld_main(int argc, char **argv)
return 1; return 1;
} }
#endif #endif
#ifdef WITH_WSREP
wsrep_filter_new_cluster (&argc, argv);
#endif /* WITH_WSREP */
orig_argc= argc; orig_argc= argc;
orig_argv= argv; orig_argv= argv;
...@@ -7884,6 +7882,13 @@ struct my_option my_long_options[]= ...@@ -7884,6 +7882,13 @@ struct my_option my_long_options[]=
{"table_cache", 0, "Deprecated; use --table-open-cache instead.", {"table_cache", 0, "Deprecated; use --table-open-cache instead.",
&tc_size, &tc_size, 0, GET_ULONG, &tc_size, &tc_size, 0, GET_ULONG,
REQUIRED_ARG, TABLE_OPEN_CACHE_DEFAULT, 1, 512*1024L, 0, 1, 0}, 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 */ /* The following options exist in 5.6 but not in 10.0 */
MYSQL_TO_BE_IMPLEMENTED_OPTION("default-tmp-storage-engine"), MYSQL_TO_BE_IMPLEMENTED_OPTION("default-tmp-storage-engine"),
......
...@@ -781,36 +781,6 @@ void wsrep_stop_replication(THD *thd) ...@@ -781,36 +781,6 @@ void wsrep_stop_replication(THD *thd)
return; 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() bool wsrep_start_replication()
{ {
...@@ -834,11 +804,16 @@ bool wsrep_start_replication() ...@@ -834,11 +804,16 @@ bool wsrep_start_replication()
return true; return true;
} }
bool const bootstrap(TRUE == wsrep_new_cluster); bool const bootstrap= wsrep_new_cluster;
wsrep_new_cluster= FALSE;
WSREP_INFO("Start replication"); 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, if ((rcode = wsrep->connect(wsrep,
wsrep_cluster_name, wsrep_cluster_name,
wsrep_cluster_address, wsrep_cluster_address,
......
...@@ -100,6 +100,7 @@ extern my_bool wsrep_restart_slave; ...@@ -100,6 +100,7 @@ extern my_bool wsrep_restart_slave;
extern my_bool wsrep_restart_slave_activated; extern my_bool wsrep_restart_slave_activated;
extern my_bool wsrep_slave_FK_checks; extern my_bool wsrep_slave_FK_checks;
extern my_bool wsrep_slave_UK_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_OSU_method { WSREP_OSU_TOI, WSREP_OSU_RSU };
enum enum_wsrep_sync_wait { enum enum_wsrep_sync_wait {
...@@ -127,10 +128,6 @@ extern const char* wsrep_provider_vendor; ...@@ -127,10 +128,6 @@ extern const char* wsrep_provider_vendor;
int wsrep_show_status(THD *thd, SHOW_VAR *var, char *buff); int wsrep_show_status(THD *thd, SHOW_VAR *var, char *buff);
void wsrep_free_status(THD *thd); 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(); int wsrep_init();
void wsrep_deinit(bool free_options); void wsrep_deinit(bool free_options);
void wsrep_recover(); void wsrep_recover();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment