Commit 903cfde1 authored by Nirbhay Choubey's avatar Nirbhay Choubey

MDEV-7067: Server outputs Galera (WSREP) information, even if Galera is disabled

* mysqld_safe: Since wsrep_on variable is mandatory in 10.1, skip wsrep
position recovery if its OFF.
* mysqld: Remove "-wsrep" from server version
* mysqld: Remove wsrep patch version from @@version_comment
* mysqld: Introduce @@wsrep_patch_version
parent 1b00edc4
......@@ -28,29 +28,17 @@ OPTION(WITH_WSREP "WSREP replication API (to use, e.g. Galera Replication librar
# Set the patch version
SET(WSREP_PATCH_VERSION "10")
# MariaDB addition: Revision number of the last revision merged from
# codership branch visible in @@version_comment.
# Branch : codership-mysql/5.6
SET(WSREP_PATCH_REVNO "4144") # Should be updated on every merge.
# MariaDB addition: Revision number of the last revision merged from
# Branch : lp:maria/maria-10.0-galera
SET(WSREP_PATCH_REVNO2 "3919") # Should be updated on every merge.
# MariaDB: Obtain patch revision number:
# Update WSREP_PATCH_REVNO if WSREP_REV environment variable is set.
IF (DEFINED ENV{WSREP_REV})
SET(WSREP_PATCH_REVNO $ENV{WSREP_REV})
ENDIF()
SET(WSREP_INTERFACE_VERSION 25)
# Obtain wsrep API version
FILE(STRINGS "${MySQL_SOURCE_DIR}/wsrep/wsrep_api.h" WSREP_API_VERSION
LIMIT_COUNT 1 REGEX "WSREP_INTERFACE_VERSION")
STRING(REGEX MATCH "([0-9]+)" WSREP_API_VERSION "${WSREP_API_VERSION}")
SET(WSREP_VERSION
"${WSREP_INTERFACE_VERSION}.${WSREP_PATCH_VERSION}.r${WSREP_PATCH_REVNO}")
SET(WSREP_VERSION "${WSREP_API_VERSION}.${WSREP_PATCH_VERSION}"
CACHE INTERNAL "WSREP version")
SET(WSREP_PROC_INFO ${WITH_WSREP})
IF(WITH_WSREP)
SET(COMPILATION_COMMENT "${COMPILATION_COMMENT}, wsrep_${WSREP_VERSION}")
SET(WSREP_PATCH_VERSION "wsrep_${WSREP_VERSION}")
ENDIF()
......@@ -23,6 +23,10 @@
#define MYSQL_CONFIG_NAME "my"
#define MYSQL_COMPILATION_COMMENT "@COMPILATION_COMMENT@"
#ifdef WITH_WSREP
#define WSREP_PATCH_VERSION "@WSREP_PATCH_VERSION@"
#endif
/* mysqld compile time options */
#endif /* _CUSTOMCONFIG_ */
......
......@@ -365,6 +365,20 @@ NUMERIC_BLOCK_SIZE NULL
ENUM_VALUE_LIST TOI,RSU
READ_ONLY NO
COMMAND_LINE_ARGUMENT OPTIONAL
VARIABLE_NAME WSREP_PATCH_VERSION
SESSION_VALUE NULL
GLOBAL_VALUE wsrep_25.10
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE NULL
VARIABLE_SCOPE GLOBAL
VARIABLE_TYPE VARCHAR
VARIABLE_COMMENT wsrep patch version
NUMERIC_MIN_VALUE NULL
NUMERIC_MAX_VALUE NULL
NUMERIC_BLOCK_SIZE NULL
ENUM_VALUE_LIST NULL
READ_ONLY YES
COMMAND_LINE_ARGUMENT NULL
VARIABLE_NAME WSREP_PROVIDER
SESSION_VALUE NULL
GLOBAL_VALUE none
......
......@@ -20,6 +20,7 @@ mysqld_ld_preload=
mysqld_ld_library_path=
flush_caches=0
numa_interleave=0
wsrep_on=0
# Initial logging status: error log is not open, and not using syslog
logging=init
......@@ -319,6 +320,15 @@ parse_arguments() {
--timezone=*) TZ="$val"; export TZ; ;;
--flush[-_]caches) flush_caches=1 ;;
--numa[-_]interleave) numa_interleave=1 ;;
--wsrep[-_]on) wsrep_on=1 ;;
--skip[-_]wsrep[-_]on) wsrep_on=0 ;;
--wsrep[-_]on=*)
if echo $val | grep -iq '\(ON\|1\)'; then
wsrep_on=1
else
wsrep_on=0
fi
;;
--wsrep[-_]urls=*) wsrep_urls="$val"; ;;
--wsrep[-_]provider=*)
if test -n "$val" && test "$val" != "none"
......@@ -968,18 +978,24 @@ do
start_time=`date +%M%S`
# this sets wsrep_start_position_opt
wsrep_recover_position "$cmd"
# Perform wsrep position recovery if wsrep_on=1, skip otherwise.
if test $wsrep_on -eq 1
then
# this sets wsrep_start_position_opt
wsrep_recover_position "$cmd"
[ $? -ne 0 ] && exit 1 #
[ $? -ne 0 ] && exit 1 #
[ -n "$wsrep_urls" ] && url=`wsrep_pick_url $wsrep_urls` # check connect address
[ -n "$wsrep_urls" ] && url=`wsrep_pick_url $wsrep_urls` # check connect address
if [ -z "$url" ]
then
eval_log_error "$cmd $wsrep_start_position_opt"
if [ -z "$url" ]
then
eval_log_error "$cmd $wsrep_start_position_opt"
else
eval_log_error "$cmd $wsrep_start_position_opt --wsrep_cluster_address=$url"
fi
else
eval_log_error "$cmd $wsrep_start_position_opt --wsrep_cluster_address=$url"
eval_log_error "$cmd"
fi
if [ $want_syslog -eq 0 -a ! -f "$err_log" ]; then
......
......@@ -1900,14 +1900,16 @@ static void __cdecl kill_server(int sig_ptr)
}
#endif
if (WSREP_ON)
wsrep_stop_replication(NULL);
/* Stop wsrep threads in case they are running. */
wsrep_stop_replication(NULL);
close_connections();
if (wsrep_inited == 1)
wsrep_deinit(true);
wsrep_thr_deinit();
if (sig != MYSQL_KILL_SIGNAL &&
sig != 0)
unireg_abort(1); /* purecov: inspected */
......@@ -4974,13 +4976,20 @@ a file name for --log-bin-index option", opt_binlog_index_name);
opt_bin_logname= my_once_strdup(buf, MYF(MY_WME));
}
/*
Wsrep initialization must happen at this point, because:
- opt_bin_logname must be known when starting replication
since SST may need it
- SST may modify binlog index file, so it must be opened
after SST has happened
*/
/*
Wsrep initialization must happen at this point, because:
- opt_bin_logname must be known when starting replication
since SST may need it
- SST may modify binlog index file, so it must be opened
after SST has happened
We also (unconditionally) initialize wsrep LOCKs and CONDs.
It is because they are used while accessing wsrep system
variables even when a wsrep provider is not loaded.
*/
wsrep_thr_init();
if (WSREP_ON && !wsrep_recovery && !opt_abort) /* WSREP BEFORE SE */
{
if (opt_bootstrap) // bootsrap option given - disable wsrep functionality
......@@ -9425,9 +9434,6 @@ void set_server_version(void)
#ifdef EMBEDDED_LIBRARY
end= strmov(end, "-embedded");
#endif
#ifdef WITH_WSREP
end= strmov(end, "-wsrep");
#endif
#ifndef DBUG_OFF
if (!strstr(MYSQL_SERVER_SUFFIX_STR, "-debug"))
end= strmov(end, "-debug");
......
......@@ -4857,6 +4857,12 @@ static Sys_var_mybool Sys_wsrep_gtid_mode(
"ignored (backward compatibility).",
GLOBAL_VAR(wsrep_gtid_mode), CMD_LINE(OPT_ARG), DEFAULT(FALSE));
static char *wsrep_patch_version_ptr;
static Sys_var_charptr Sys_wsrep_patch_version(
"wsrep_patch_version", "wsrep patch version",
READ_ONLY GLOBAL_VAR(wsrep_patch_version_ptr), CMD_LINE_HELP_ONLY,
IN_SYSTEM_CHARSET, DEFAULT(WSREP_PATCH_VERSION));
#endif /* WITH_WSREP */
static bool fix_host_cache_size(sys_var *, THD *, enum_var_type)
......
......@@ -617,25 +617,6 @@ int wsrep_init()
wsrep_causal_reads_update(&global_system_variables);
mysql_mutex_register("sql", wsrep_mutexes, array_elements(wsrep_mutexes));
mysql_cond_register("sql", wsrep_conds, array_elements(wsrep_conds));
mysql_mutex_init(key_LOCK_wsrep_ready, &LOCK_wsrep_ready, MY_MUTEX_INIT_FAST);
mysql_cond_init(key_COND_wsrep_ready, &COND_wsrep_ready, NULL);
mysql_mutex_init(key_LOCK_wsrep_sst, &LOCK_wsrep_sst, MY_MUTEX_INIT_FAST);
mysql_cond_init(key_COND_wsrep_sst, &COND_wsrep_sst, NULL);
mysql_mutex_init(key_LOCK_wsrep_sst_init, &LOCK_wsrep_sst_init, MY_MUTEX_INIT_FAST);
mysql_cond_init(key_COND_wsrep_sst_init, &COND_wsrep_sst_init, NULL);
mysql_mutex_init(key_LOCK_wsrep_rollback, &LOCK_wsrep_rollback, MY_MUTEX_INIT_FAST);
mysql_cond_init(key_COND_wsrep_rollback, &COND_wsrep_rollback, NULL);
mysql_mutex_init(key_LOCK_wsrep_replaying, &LOCK_wsrep_replaying, MY_MUTEX_INIT_FAST);
mysql_cond_init(key_COND_wsrep_replaying, &COND_wsrep_replaying, NULL);
mysql_mutex_init(key_LOCK_wsrep_slave_threads, &LOCK_wsrep_slave_threads, MY_MUTEX_INIT_FAST);
mysql_mutex_init(key_LOCK_wsrep_desync, &LOCK_wsrep_desync, MY_MUTEX_INIT_FAST);
mysql_mutex_init(key_LOCK_wsrep_config_state, &LOCK_wsrep_config_state, MY_MUTEX_INIT_FAST);
mysql_file_register("sql", wsrep_files, array_elements(wsrep_files));
wsrep_ready_set(FALSE);
assert(wsrep_provider);
......@@ -826,6 +807,31 @@ int wsrep_init()
return rcode;
}
/* Initialize wsrep thread LOCKs and CONDs */
void wsrep_thr_init()
{
mysql_mutex_register("sql", wsrep_mutexes, array_elements(wsrep_mutexes));
mysql_cond_register("sql", wsrep_conds, array_elements(wsrep_conds));
mysql_mutex_init(key_LOCK_wsrep_ready, &LOCK_wsrep_ready, MY_MUTEX_INIT_FAST);
mysql_cond_init(key_COND_wsrep_ready, &COND_wsrep_ready, NULL);
mysql_mutex_init(key_LOCK_wsrep_sst, &LOCK_wsrep_sst, MY_MUTEX_INIT_FAST);
mysql_cond_init(key_COND_wsrep_sst, &COND_wsrep_sst, NULL);
mysql_mutex_init(key_LOCK_wsrep_sst_init, &LOCK_wsrep_sst_init, MY_MUTEX_INIT_FAST);
mysql_cond_init(key_COND_wsrep_sst_init, &COND_wsrep_sst_init, NULL);
mysql_mutex_init(key_LOCK_wsrep_rollback, &LOCK_wsrep_rollback, MY_MUTEX_INIT_FAST);
mysql_cond_init(key_COND_wsrep_rollback, &COND_wsrep_rollback, NULL);
mysql_mutex_init(key_LOCK_wsrep_replaying, &LOCK_wsrep_replaying, MY_MUTEX_INIT_FAST);
mysql_cond_init(key_COND_wsrep_replaying, &COND_wsrep_replaying, NULL);
mysql_mutex_init(key_LOCK_wsrep_slave_threads, &LOCK_wsrep_slave_threads, MY_MUTEX_INIT_FAST);
mysql_mutex_init(key_LOCK_wsrep_desync, &LOCK_wsrep_desync, MY_MUTEX_INIT_FAST);
mysql_mutex_init(key_LOCK_wsrep_config_state, &LOCK_wsrep_config_state, MY_MUTEX_INIT_FAST);
mysql_file_register("sql", wsrep_files, array_elements(wsrep_files));
}
void wsrep_init_startup (bool first)
{
if (wsrep_init()) unireg_abort(1);
......@@ -864,7 +870,11 @@ void wsrep_deinit(bool free_options)
{
wsrep_sst_auth_free();
}
}
/* Destroy wsrep thread LOCKs and CONDs */
void wsrep_thr_deinit()
{
mysql_mutex_destroy(&LOCK_wsrep_ready);
mysql_cond_destroy(&COND_wsrep_ready);
mysql_mutex_destroy(&LOCK_wsrep_sst);
......@@ -882,10 +892,11 @@ void wsrep_deinit(bool free_options)
void wsrep_recover()
{
char uuid_str[40];
if (!memcmp(&local_uuid, &WSREP_UUID_UNDEFINED, sizeof(wsrep_uuid_t)) &&
local_seqno == -2)
{
char uuid_str[40];
wsrep_uuid_print(&local_uuid, uuid_str, sizeof(uuid_str));
WSREP_INFO("Position %s:%lld given at startup, skipping position recovery",
uuid_str, (long long)local_seqno);
......@@ -895,7 +906,6 @@ void wsrep_recover()
memset(&xid, 0, sizeof(xid));
xid.formatID= -1;
wsrep_get_SE_checkpoint(&xid);
char uuid_str[40];
wsrep_uuid_print(wsrep_xid_uuid(&xid), uuid_str, sizeof(uuid_str));
WSREP_INFO("Recovered position: %s:%lld", uuid_str,
(long long)wsrep_xid_seqno(&xid));
......
......@@ -118,6 +118,12 @@ int wsrep_show_status(THD *thd, SHOW_VAR *var, char *buff,
enum enum_var_type scope);
int wsrep_init();
void wsrep_deinit(bool free_options);
/* Initialize wsrep thread LOCKs and CONDs */
void wsrep_thr_init();
/* Destroy wsrep thread LOCKs and CONDs */
void wsrep_thr_deinit();
void wsrep_recover();
bool wsrep_before_SE(); // initialize wsrep before storage
// engines (true) or after (false)
......@@ -338,6 +344,8 @@ int wsrep_create_trigger_query(THD *thd, uchar** buf, size_t* buf_len);
#define wsrep_recover() do { } while(0)
#define wsrep_slave_threads (1)
#define wsrep_replicate_myisam (0)
#define wsrep_thr_init() do {} while(0)
#define wsrep_thr_deinit() do {} while(0)
#endif /* WITH_WSREP */
#endif /* WSREP_MYSQLD_H */
......@@ -295,6 +295,8 @@ bool wsrep_provider_options_check(sys_var *self, THD* thd, set_var* var)
bool wsrep_provider_options_update(sys_var *self, THD* thd, enum_var_type type)
{
DBUG_ASSERT(wsrep != NULL);
wsrep_status_t ret= wsrep->options_set(wsrep, wsrep_provider_options);
if (ret != WSREP_OK)
{
......@@ -495,6 +497,8 @@ bool wsrep_desync_check (sys_var *self, THD* thd, set_var* var)
bool wsrep_desync_update (sys_var *self, THD* thd, enum_var_type type)
{
DBUG_ASSERT(wsrep != NULL);
wsrep_status_t ret(WSREP_WARNING);
if (wsrep_desync) {
ret = wsrep->desync (wsrep);
......@@ -548,6 +552,7 @@ int wsrep_show_status (THD *thd, SHOW_VAR *var, char *buff,
*v++= wsrep_status_vars[i];
DBUG_ASSERT(i < maxi);
DBUG_ASSERT(wsrep != NULL);
wsrep_stats_var* stats= wsrep->stats_get(wsrep);
for (wsrep_stats_var *sv= stats; i < maxi && sv && sv->name; i++, sv++, v++)
......
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