Commit eaec266e authored by Sergei Golubchik's avatar Sergei Golubchik

restore and fix wsrep status variables

parent 13af416a
...@@ -8174,6 +8174,9 @@ SHOW_VAR status_vars[]= { ...@@ -8174,6 +8174,9 @@ SHOW_VAR status_vars[]= {
{"Uptime", (char*) &show_starttime, SHOW_SIMPLE_FUNC}, {"Uptime", (char*) &show_starttime, SHOW_SIMPLE_FUNC},
#ifdef ENABLED_PROFILING #ifdef ENABLED_PROFILING
{"Uptime_since_flush_status",(char*) &show_flushstatustime, SHOW_SIMPLE_FUNC}, {"Uptime_since_flush_status",(char*) &show_flushstatustime, SHOW_SIMPLE_FUNC},
#endif
#ifdef WITH_WSREP
{"wsrep", (char*) &wsrep_show_status, SHOW_FUNC},
#endif #endif
{NullS, NullS, SHOW_LONG} {NullS, NullS, SHOW_LONG}
}; };
......
...@@ -1026,7 +1026,6 @@ THD::THD(bool is_wsrep_applier) ...@@ -1026,7 +1026,6 @@ THD::THD(bool is_wsrep_applier)
wsrep_retry_query_len = 0; wsrep_retry_query_len = 0;
wsrep_retry_command = COM_CONNECT; wsrep_retry_command = COM_CONNECT;
wsrep_consistency_check = NO_CONSISTENCY_CHECK; wsrep_consistency_check = NO_CONSISTENCY_CHECK;
wsrep_status_vars = 0;
wsrep_mysql_replicated = 0; wsrep_mysql_replicated = 0;
wsrep_TOI_pre_query = NULL; wsrep_TOI_pre_query = NULL;
wsrep_TOI_pre_query_len = 0; wsrep_TOI_pre_query_len = 0;
...@@ -1635,7 +1634,6 @@ THD::~THD() ...@@ -1635,7 +1634,6 @@ THD::~THD()
mysql_mutex_destroy(&LOCK_wsrep_thd); mysql_mutex_destroy(&LOCK_wsrep_thd);
if (wsrep_rli) delete wsrep_rli; if (wsrep_rli) delete wsrep_rli;
if (wsrep_rgi) delete wsrep_rgi; if (wsrep_rgi) delete wsrep_rgi;
if (wsrep_status_vars) wsrep->stats_free(wsrep, wsrep_status_vars);
#endif #endif
/* Close connection */ /* Close connection */
#ifndef EMBEDDED_LIBRARY #ifndef EMBEDDED_LIBRARY
......
...@@ -3767,7 +3767,6 @@ class THD :public Statement, ...@@ -3767,7 +3767,6 @@ class THD :public Statement,
enum enum_server_command wsrep_retry_command; enum enum_server_command wsrep_retry_command;
enum wsrep_consistency_check_mode enum wsrep_consistency_check_mode
wsrep_consistency_check; wsrep_consistency_check;
wsrep_stats_var* wsrep_status_vars;
int wsrep_mysql_replicated; int wsrep_mysql_replicated;
const char* wsrep_TOI_pre_query; /* a query to apply before const char* wsrep_TOI_pre_query; /* a query to apply before
the actual TOI query */ the actual TOI query */
......
...@@ -5705,14 +5705,6 @@ static bool execute_sqlcom_select(THD *thd, TABLE_LIST *all_tables) ...@@ -5705,14 +5705,6 @@ static bool execute_sqlcom_select(THD *thd, TABLE_LIST *all_tables)
else else
status_var_add(thd->status_var.rows_sent, thd->get_sent_row_count()); status_var_add(thd->status_var.rows_sent, thd->get_sent_row_count());
#ifdef WITH_WSREP
if (thd->wsrep_status_vars)
{
wsrep->stats_free (wsrep, thd->wsrep_status_vars);
thd->wsrep_status_vars = 0;
}
#endif
return res; return res;
} }
......
...@@ -86,6 +86,7 @@ extern my_bool wsrep_restart_slave; ...@@ -86,6 +86,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 ulong wsrep_running_threads;
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 {
......
...@@ -15,9 +15,9 @@ ...@@ -15,9 +15,9 @@
#include "wsrep_var.h" #include "wsrep_var.h"
#include <sql_plugin.h>
#include <mysqld.h> #include <mysqld.h>
#include <sql_class.h> #include <sql_class.h>
#include <sql_plugin.h>
#include <set_var.h> #include <set_var.h>
#include <sql_acl.h> #include <sql_acl.h>
#include "wsrep_priv.h" #include "wsrep_priv.h"
...@@ -507,99 +507,65 @@ bool wsrep_desync_update (sys_var *self, THD* thd, enum_var_type type) ...@@ -507,99 +507,65 @@ bool wsrep_desync_update (sys_var *self, THD* thd, enum_var_type type)
return false; return false;
} }
/* static SHOW_VAR wsrep_status_vars[]=
* Status variables stuff below {
*/ {"connected", (char*) &wsrep_connected, SHOW_BOOL},
static inline void {"ready", (char*) &wsrep_ready, SHOW_BOOL},
wsrep_assign_to_mysql (SHOW_VAR* mysql, wsrep_stats_var* wsrep) {"cluster_state_uuid",(char*) &wsrep_cluster_state_uuid,SHOW_CHAR_PTR},
{ {"cluster_conf_id", (char*) &wsrep_cluster_conf_id, SHOW_LONGLONG},
mysql->name = wsrep->name; {"cluster_status", (char*) &wsrep_cluster_status, SHOW_CHAR_PTR},
switch (wsrep->type) { {"cluster_size", (char*) &wsrep_cluster_size, SHOW_LONG_NOFLUSH},
case WSREP_VAR_INT64: {"local_index", (char*) &wsrep_local_index, SHOW_LONG_NOFLUSH},
mysql->value = (char*) &wsrep->value._int64; {"local_bf_aborts", (char*) &wsrep_show_bf_aborts, SHOW_SIMPLE_FUNC},
mysql->type = SHOW_LONGLONG; {"provider_name", (char*) &wsrep_provider_name, SHOW_CHAR_PTR},
break; {"provider_version", (char*) &wsrep_provider_version, SHOW_CHAR_PTR},
case WSREP_VAR_STRING: {"provider_vendor", (char*) &wsrep_provider_vendor, SHOW_CHAR_PTR},
mysql->value = (char*) &wsrep->value._string; {"thread_count", (char*) &wsrep_running_threads, SHOW_LONG_NOFLUSH}
mysql->type = SHOW_CHAR_PTR; };
break;
case WSREP_VAR_DOUBLE:
mysql->value = (char*) &wsrep->value._double;
mysql->type = SHOW_DOUBLE;
break;
}
}
#if DYNAMIC
// somehow this mysql status thing works only with statically allocated arrays.
static SHOW_VAR* mysql_status_vars = NULL;
static int mysql_status_len = -1;
#else
static SHOW_VAR mysql_status_vars[512 + 1];
static const int mysql_status_len = 512;
#endif
static void export_wsrep_status_to_mysql(THD* thd) static int show_var_cmp(const void *var1, const void *var2)
{ {
int wsrep_status_len, i; return strcasecmp(((SHOW_VAR*)var1)->name, ((SHOW_VAR*)var2)->name);
}
thd->wsrep_status_vars = wsrep->stats_get(wsrep); int wsrep_show_status (THD *thd, SHOW_VAR *var, char *buff)
{
uint i, maxi= SHOW_VAR_FUNC_BUFF_SIZE / sizeof(*var) - 1;
SHOW_VAR *v= (SHOW_VAR *)buff;
if (!thd->wsrep_status_vars) { var->type= SHOW_ARRAY;
return; var->value= buff;
}
for (wsrep_status_len = 0; for (i=0; i < array_elements(wsrep_status_vars); i++)
thd->wsrep_status_vars[wsrep_status_len].name != NULL; *v++= wsrep_status_vars[i];
wsrep_status_len++);
#if DYNAMIC DBUG_ASSERT(i < maxi);
if (wsrep_status_len != mysql_status_len) {
void* tmp = realloc (mysql_status_vars,
(wsrep_status_len + 1) * sizeof(SHOW_VAR));
if (!tmp) {
sql_print_error ("Out of memory for wsrep status variables." wsrep_stats_var* stats= wsrep->stats_get(wsrep);
"Number of variables: %d", wsrep_status_len); for (wsrep_stats_var *sv= stats; i < maxi && sv && sv->name; i++, sv++, v++)
return; {
v->name = thd->strdup(sv->name);
switch (sv->type) {
case WSREP_VAR_INT64:
v->value = (char*)thd->memdup(&sv->value._int64, sizeof(longlong));
v->type = SHOW_LONGLONG;
break;
case WSREP_VAR_STRING:
v->value = thd->strdup(sv->value._string);
v->type = SHOW_CHAR;
break;
case WSREP_VAR_DOUBLE:
v->value = (char*)thd->memdup(&sv->value._double, sizeof(double));
v->type = SHOW_DOUBLE;
break;
} }
DBUG_ASSERT(i < maxi);
mysql_status_len = wsrep_status_len;
mysql_status_vars = (SHOW_VAR*)tmp;
} }
/* @TODO: fix this: */ wsrep->stats_free(wsrep, stats);
#else
if (mysql_status_len < wsrep_status_len) wsrep_status_len= mysql_status_len;
#endif
for (i = 0; i < wsrep_status_len; i++) my_qsort(buff, i, sizeof(*v), show_var_cmp);
wsrep_assign_to_mysql (mysql_status_vars + i, thd->wsrep_status_vars + i);
mysql_status_vars[wsrep_status_len].name = NullS; v->name= 0; // terminator
mysql_status_vars[wsrep_status_len].value = NullS;
mysql_status_vars[wsrep_status_len].type = SHOW_LONG;
}
int wsrep_show_status (THD *thd, SHOW_VAR *var, char *buff)
{
export_wsrep_status_to_mysql(thd);
var->type= SHOW_ARRAY;
var->value= (char *) &mysql_status_vars;
#if 0
{"wsrep_connected", (char*) &wsrep_connected, SHOW_BOOL},
{"wsrep_ready", (char*) &wsrep_ready, SHOW_BOOL},
{"wsrep_cluster_state_uuid", (char*) &wsrep_cluster_state_uuid,SHOW_CHAR_PTR},
{"wsrep_cluster_conf_id", (char*) &wsrep_cluster_conf_id, SHOW_LONGLONG},
{"wsrep_cluster_status", (char*) &wsrep_cluster_status, SHOW_CHAR_PTR},
{"wsrep_cluster_size", (char*) &wsrep_cluster_size, SHOW_LONG_NOFLUSH},
{"wsrep_local_index", (char*) &wsrep_local_index, SHOW_LONG_NOFLUSH},
{"wsrep_local_bf_aborts", (char*) &wsrep_show_bf_aborts, SHOW_SIMPLE_FUNC},
{"wsrep_provider_name", (char*) &wsrep_provider_name, SHOW_CHAR_PTR},
{"wsrep_provider_version", (char*) &wsrep_provider_version, SHOW_CHAR_PTR},
{"wsrep_provider_vendor", (char*) &wsrep_provider_vendor, SHOW_CHAR_PTR},
{"wsrep_thread_count", (char*) &wsrep_running_threads, SHOW_LONG_NOFLUSH},
{"wsrep", (char*) &wsrep_show_status, SHOW_FUNC},
#endif
return 0; return 0;
} }
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