Commit 8e84b9e7 authored by Seppo Jaakola's avatar Seppo Jaakola

Merged in change sets 3772-3779 from lp:codership-mysql/5.5

parent ebfa24b1
...@@ -236,7 +236,7 @@ mysql> SHOW STATUS LIKE 'wsrep%'; ...@@ -236,7 +236,7 @@ mysql> SHOW STATUS LIKE 'wsrep%';
- If performing a rolling upgrade on a running cluster, set - If performing a rolling upgrade on a running cluster, set
wsrep_sst_method=mysqldump. wsrep_sst_method=mysqldump.
You might also need to configure wsrep_sst_receive_address and You might also need to configure wsrep_sst_receive_address and
wsrep_sst_auth appropriately. Mysqldump is the only way to transfer data wsrep_sst_auth appropriately. mysqldump is the only way to transfer data
from 5.1.x to 5.5.x reliably. from 5.1.x to 5.5.x reliably.
- remove innodb_plugin settings from configuration files. - remove innodb_plugin settings from configuration files.
...@@ -292,6 +292,15 @@ wsrep_cluster_address= ...@@ -292,6 +292,15 @@ wsrep_cluster_address=
wsrep_cluster_name="my_wsrep_cluster" wsrep_cluster_name="my_wsrep_cluster"
Logical cluster name, must be the same for all nodes of the cluster. Logical cluster name, must be the same for all nodes of the cluster.
wsrep_node_address=
An option to explicitly specify the network address of the node in the form
<address>[:port] if autoguessing for some reason does not produce desirable
results (multiple network interfaces, NAT, etc.)
If not explicitly overridden by wsrep_sst_receive_address, the <address> part
will be used to listen for SST (see below). And the whole <address>[:port]
will be passed to wsrep provider to be used as a base address in its
communications.
wsrep_node_name= wsrep_node_name=
Human readable node name (for easier log reading only). Defaults to hostname. Human readable node name (for easier log reading only). Defaults to hostname.
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
# so WSREP_VERSION is produced regardless # so WSREP_VERSION is produced regardless
# Set the patch version # Set the patch version
SET(WSREP_PATCH_VERSION "6") SET(WSREP_PATCH_VERSION "7")
# Obtain patch revision number # Obtain patch revision number
SET(WSREP_PATCH_REVNO $ENV{WSREP_REV}) SET(WSREP_PATCH_REVNO $ENV{WSREP_REV})
......
...@@ -23,14 +23,14 @@ RSYNC_CONF= ...@@ -23,14 +23,14 @@ RSYNC_CONF=
cleanup_joiner() cleanup_joiner()
{ {
echo "Joiner cleanup:" >&2 echo -n "Joiner rsync SST cleanup..." >&2
set -x
local PID=$(cat "$RSYNC_PID" 2>/dev/null || echo 0) local PID=$(cat "$RSYNC_PID" 2>/dev/null || echo 0)
[ "0" != "$PID" ] && kill $PID && sleep 0.5 && kill -9 $PID || : [ "0" != "$PID" ] && kill $PID && sleep 0.5 && kill -9 $PID >/dev/null 2>&1 \
set +x || :
rm -rf "$RSYNC_CONF" rm -rf "$RSYNC_CONF"
rm -rf "$MAGIC_FILE" rm -rf "$MAGIC_FILE"
rm -rf "$RSYNC_PID" rm -rf "$RSYNC_PID"
echo " done." >&2
} }
check_pid() check_pid()
......
...@@ -5080,7 +5080,7 @@ void wsrep_wait_appliers_close(THD *thd) ...@@ -5080,7 +5080,7 @@ void wsrep_wait_appliers_close(THD *thd)
/* and wait for them to die */ /* and wait for them to die */
mysql_mutex_lock(&LOCK_thread_count); mysql_mutex_lock(&LOCK_thread_count);
while (have_wsrep_appliers(thd) > 0) while (have_wsrep_appliers(thd) > 0)
{ {
mysql_cond_wait(&COND_thread_count,&LOCK_thread_count); mysql_cond_wait(&COND_thread_count,&LOCK_thread_count);
DBUG_PRINT("quit",("One thread died (count=%u)",thread_count)); DBUG_PRINT("quit",("One thread died (count=%u)",thread_count));
} }
......
...@@ -1005,6 +1005,7 @@ THD::THD() ...@@ -1005,6 +1005,7 @@ THD::THD()
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;
#endif #endif
/* Call to init() below requires fully initialized Open_tables_state. */ /* Call to init() below requires fully initialized Open_tables_state. */
reset_open_tables_state(this); reset_open_tables_state(this);
...@@ -1557,6 +1558,7 @@ THD::~THD() ...@@ -1557,6 +1558,7 @@ THD::~THD()
mysql_mutex_unlock(&LOCK_wsrep_thd); mysql_mutex_unlock(&LOCK_wsrep_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_status_vars) wsrep->stats_free(wsrep, wsrep_status_vars);
#endif #endif
/* Close connection */ /* Close connection */
#ifndef EMBEDDED_LIBRARY #ifndef EMBEDDED_LIBRARY
......
...@@ -2400,6 +2400,7 @@ class THD :public Statement, ...@@ -2400,6 +2400,7 @@ 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;
#endif /* WITH_WSREP */ #endif /* WITH_WSREP */
/** /**
Internal parser state. Internal parser state.
......
...@@ -2535,7 +2535,7 @@ mysql_execute_command(THD *thd) ...@@ -2535,7 +2535,7 @@ mysql_execute_command(THD *thd)
case SQLCOM_SHOW_STATUS: case SQLCOM_SHOW_STATUS:
{ {
#ifdef WITH_WSREP #ifdef WITH_WSREP
if (WSREP_CLIENT(thd) && wsrep_causal_wait(thd)) goto error; if (lex->sql_command == SQLCOM_SHOW_STATUS) wsrep_free_status(thd);
#endif /* WITH_WSREP */ #endif /* WITH_WSREP */
execute_show_status(thd, all_tables); execute_show_status(thd, all_tables);
break; break;
......
...@@ -54,7 +54,7 @@ my_bool wsrep_replicate_myisam = 0; // enable myisam replication ...@@ -54,7 +54,7 @@ my_bool wsrep_replicate_myisam = 0; // enable myisam replication
* End configuration options * End configuration options
*/ */
static wsrep_uuid_t cluster_uuid = WSREP_UUID_UNDEFINED; static const wsrep_uuid_t cluster_uuid = WSREP_UUID_UNDEFINED;
const wsrep_uuid_t* wsrep_cluster_uuid() const wsrep_uuid_t* wsrep_cluster_uuid()
{ {
return &cluster_uuid; return &cluster_uuid;
...@@ -120,11 +120,11 @@ static void wsrep_log_cb(wsrep_log_level_t level, const char *msg) { ...@@ -120,11 +120,11 @@ static void wsrep_log_cb(wsrep_log_level_t level, const char *msg) {
} }
} }
static void wsrep_log_states (wsrep_log_level_t level, static void wsrep_log_states (wsrep_log_level_t const level,
wsrep_uuid_t* group_uuid, const wsrep_uuid_t* const group_uuid,
wsrep_seqno_t group_seqno, wsrep_seqno_t const group_seqno,
wsrep_uuid_t* node_uuid, const wsrep_uuid_t* const node_uuid,
wsrep_seqno_t node_seqno) wsrep_seqno_t const node_seqno)
{ {
char uuid_str[37]; char uuid_str[37];
char msg[256]; char msg[256];
...@@ -195,7 +195,7 @@ static void wsrep_view_handler_cb (void* app_ctx, ...@@ -195,7 +195,7 @@ static void wsrep_view_handler_cb (void* app_ctx,
if (memcmp(&cluster_uuid, &view->uuid, sizeof(wsrep_uuid_t))) if (memcmp(&cluster_uuid, &view->uuid, sizeof(wsrep_uuid_t)))
{ {
cluster_uuid= view->uuid; memcpy((wsrep_uuid_t*)&cluster_uuid, &view->uuid, sizeof(cluster_uuid));
wsrep_uuid_print (&cluster_uuid, cluster_uuid_str, wsrep_uuid_print (&cluster_uuid, cluster_uuid_str,
sizeof(cluster_uuid_str)); sizeof(cluster_uuid_str));
} }
...@@ -213,7 +213,7 @@ static void wsrep_view_handler_cb (void* app_ctx, ...@@ -213,7 +213,7 @@ static void wsrep_view_handler_cb (void* app_ctx,
/* Proceed further only if view is PRIMARY */ /* Proceed further only if view is PRIMARY */
if (WSREP_VIEW_PRIMARY != view->status) { if (WSREP_VIEW_PRIMARY != view->status) {
wsrep_ready= FALSE; wsrep_ready_set(FALSE);
new_status= WSREP_MEMBER_UNDEFINED; new_status= WSREP_MEMBER_UNDEFINED;
/* Always record local_uuid and local_seqno in non-prim since this /* Always record local_uuid and local_seqno in non-prim since this
* may lead to re-initializing provider and start position is * may lead to re-initializing provider and start position is
...@@ -234,13 +234,13 @@ static void wsrep_view_handler_cb (void* app_ctx, ...@@ -234,13 +234,13 @@ static void wsrep_view_handler_cb (void* app_ctx,
if (view->proto_ver != wsrep_protocol_version) if (view->proto_ver != wsrep_protocol_version)
{ {
my_bool wsrep_ready_saved= wsrep_ready; my_bool wsrep_ready_saved= wsrep_ready;
wsrep_ready= FALSE; wsrep_ready_set(FALSE);
WSREP_INFO("closing client connections for " WSREP_INFO("closing client connections for "
"protocol change %ld -> %d", "protocol change %ld -> %d",
wsrep_protocol_version, view->proto_ver); wsrep_protocol_version, view->proto_ver);
wsrep_close_client_connections(TRUE); wsrep_close_client_connections(TRUE);
wsrep_protocol_version= view->proto_ver; wsrep_protocol_version= view->proto_ver;
wsrep_ready= wsrep_ready_saved; wsrep_ready_set(wsrep_ready_saved);
} }
break; break;
default: default:
...@@ -255,7 +255,7 @@ static void wsrep_view_handler_cb (void* app_ctx, ...@@ -255,7 +255,7 @@ static void wsrep_view_handler_cb (void* app_ctx,
/* After that wsrep will call wsrep_sst_prepare. */ /* After that wsrep will call wsrep_sst_prepare. */
/* keep ready flag 0 until we receive the snapshot */ /* keep ready flag 0 until we receive the snapshot */
wsrep_ready= FALSE; wsrep_ready_set(FALSE);
/* Close client connections to ensure that they don't interfere /* Close client connections to ensure that they don't interfere
* with SST */ * with SST */
...@@ -411,7 +411,7 @@ int wsrep_init() ...@@ -411,7 +411,7 @@ int wsrep_init()
{ {
int rcode= -1; int rcode= -1;
wsrep_ready= FALSE; wsrep_ready_set(FALSE);
assert(wsrep_provider); assert(wsrep_provider);
wsrep_init_position(); wsrep_init_position();
...@@ -438,8 +438,9 @@ int wsrep_init() ...@@ -438,8 +438,9 @@ int wsrep_init()
!strcmp(wsrep_provider, WSREP_NONE)) !strcmp(wsrep_provider, WSREP_NONE))
{ {
// enable normal operation in case no provider is specified // enable normal operation in case no provider is specified
wsrep_ready= TRUE; wsrep_ready_set(TRUE);
global_system_variables.wsrep_on = 0; global_system_variables.wsrep_on = 0;
return 0;
} }
else else
{ {
...@@ -452,41 +453,69 @@ int wsrep_init() ...@@ -452,41 +453,69 @@ int wsrep_init()
wsrep->provider_vendor, sizeof(provider_vendor) - 1); wsrep->provider_vendor, sizeof(provider_vendor) - 1);
} }
struct wsrep_init_args wsrep_args;
if (!wsrep_data_home_dir || strlen(wsrep_data_home_dir) == 0) if (!wsrep_data_home_dir || strlen(wsrep_data_home_dir) == 0)
wsrep_data_home_dir = mysql_real_data_home; wsrep_data_home_dir = mysql_real_data_home;
if (strcmp (wsrep_provider, WSREP_NONE) && char node_addr[512]= { 0, };
(!wsrep_node_incoming_address ||
!strcmp (wsrep_node_incoming_address, WSREP_NODE_INCOMING_AUTO))) {
static char inc_addr[256];
size_t inc_addr_max = sizeof (inc_addr);
size_t ret = default_address (inc_addr, inc_addr_max);
if (ret > 0 && ret < inc_addr_max) {
wsrep_node_incoming_address = inc_addr;
}
else {
wsrep_node_incoming_address = NULL;
}
}
char node_addr[256] = {0, };
if (!wsrep_node_address || !strcmp(wsrep_node_address, "")) if (!wsrep_node_address || !strcmp(wsrep_node_address, ""))
{ {
size_t node_addr_max= sizeof(node_addr); size_t const node_addr_max= sizeof(node_addr);
size_t ret= default_ip(node_addr, node_addr_max); size_t const ret= guess_ip(node_addr, node_addr_max);
if (!(ret > 0 && ret < node_addr_max)) if (!(ret > 0 && ret < node_addr_max))
{ {
WSREP_WARN("Failed to autoguess base node address"); WSREP_WARN("Failed to guess base node address. Set it explicitly via "
node_addr[0]= 0; "wsrep_node_address.");
node_addr[0]= '\0';
} }
} }
else if (wsrep_node_address) else
{ {
strncpy(node_addr, wsrep_node_address, sizeof(node_addr) - 1); strncpy(node_addr, wsrep_node_address, sizeof(node_addr) - 1);
} }
static char inc_addr[512]= { 0, };
if ((!wsrep_node_incoming_address ||
!strcmp (wsrep_node_incoming_address, WSREP_NODE_INCOMING_AUTO))) {
size_t const node_addr_len= strlen(node_addr);
if (node_addr_len > 0)
{
const char* const colon= strrchr(node_addr, ':');
if (strchr(node_addr, ':') == colon) // 1 or 0 ':'
{
size_t const inc_addr_max= sizeof (inc_addr);
size_t const ip_len= colon ? colon - node_addr : node_addr_len;
if (ip_len + 7 /* :55555\0 */ < inc_addr_max)
{
memcpy (inc_addr, node_addr, ip_len);
snprintf(inc_addr + ip_len, inc_addr_max - ip_len, ":%u",mysqld_port);
}
else
{
WSREP_WARN("Guessing address for incoming client connections: "
"address too long.");
inc_addr[0]= '\0';
}
}
else
{
WSREP_WARN("Guessing address for incoming client connections: "
"too many colons :) .");
inc_addr[0]= '\0';
}
}
// this is to display detected address on SHOW VARIABLES...
wsrep_node_incoming_address = inc_addr;
if (!strlen(wsrep_node_incoming_address))
{
WSREP_WARN("Guessing address for incoming client connections failed. "
"Try setting wsrep_node_incoming_address explicitly.");
}
}
struct wsrep_init_args wsrep_args;
wsrep_args.data_dir = wsrep_data_home_dir; wsrep_args.data_dir = wsrep_data_home_dir;
wsrep_args.node_name = (wsrep_node_name) ? wsrep_node_name : ""; wsrep_args.node_name = (wsrep_node_name) ? wsrep_node_name : "";
wsrep_args.node_address = node_addr; wsrep_args.node_address = node_addr;
...@@ -599,14 +628,14 @@ bool wsrep_start_replication() ...@@ -599,14 +628,14 @@ bool wsrep_start_replication()
!strcmp(wsrep_provider, WSREP_NONE)) !strcmp(wsrep_provider, WSREP_NONE))
{ {
// enable normal operation in case no provider is specified // enable normal operation in case no provider is specified
wsrep_ready = TRUE; wsrep_ready_set(TRUE);
return true; return true;
} }
if (!wsrep_cluster_address || strlen(wsrep_cluster_address)== 0) if (!wsrep_cluster_address || strlen(wsrep_cluster_address)== 0)
{ {
// if provider is non-trivial, but no address is specified, wait for address // if provider is non-trivial, but no address is specified, wait for address
wsrep_ready = FALSE; wsrep_ready_set(FALSE);
return true; return true;
} }
......
...@@ -18,10 +18,8 @@ ...@@ -18,10 +18,8 @@
#include "mysqld.h" #include "mysqld.h"
typedef struct st_mysql_show_var SHOW_VAR; typedef struct st_mysql_show_var SHOW_VAR;
//#include <mysql.h>
#include <sql_priv.h> #include <sql_priv.h>
#include "../wsrep/wsrep_api.h" #include "../wsrep/wsrep_api.h"
//#include <sql_class.h>
class set_var; class set_var;
class THD; class THD;
...@@ -77,6 +75,7 @@ extern const char* wsrep_provider_name; ...@@ -77,6 +75,7 @@ extern const char* wsrep_provider_name;
extern const char* wsrep_provider_version; extern const char* wsrep_provider_version;
extern const char* wsrep_provider_vendor; extern const char* wsrep_provider_vendor;
extern int wsrep_show_status(THD *thd, SHOW_VAR *var, char *buff); extern int wsrep_show_status(THD *thd, SHOW_VAR *var, char *buff);
extern void wsrep_free_status(THD *thd);
#define WSREP_SST_ADDRESS_AUTO "AUTO" #define WSREP_SST_ADDRESS_AUTO "AUTO"
// MySQL variables funcs // MySQL variables funcs
......
...@@ -37,14 +37,14 @@ extern int wsrep_sst_donate_cb (void* app_ctx, ...@@ -37,14 +37,14 @@ extern int wsrep_sst_donate_cb (void* app_ctx,
const char* state, size_t state_len, const char* state, size_t state_len,
bool bypass); bool bypass);
extern size_t default_ip (char* buf, size_t buf_len); extern size_t guess_ip (char* buf, size_t buf_len);
extern size_t default_address(char* buf, size_t buf_len); extern size_t guess_address(char* buf, size_t buf_len);
extern wsrep_uuid_t local_uuid; extern wsrep_uuid_t local_uuid;
extern wsrep_seqno_t local_seqno; extern wsrep_seqno_t local_seqno;
/*! SST thread signals init thread about sst completion */ /*! SST thread signals init thread about sst completion */
extern void wsrep_sst_complete(wsrep_uuid_t* uuid, wsrep_seqno_t seqno, bool); extern void wsrep_sst_complete(const wsrep_uuid_t* uuid, wsrep_seqno_t, bool);
extern void wsrep_notify_status (wsrep_member_status_t new_status, extern void wsrep_notify_status (wsrep_member_status_t new_status,
const wsrep_view_info_t* view = 0); const wsrep_view_info_t* view = 0);
......
...@@ -202,7 +202,7 @@ bool wsrep_sst_wait () ...@@ -202,7 +202,7 @@ bool wsrep_sst_wait ()
} }
// Signal end of SST // Signal end of SST
void wsrep_sst_complete (wsrep_uuid_t* sst_uuid, void wsrep_sst_complete (const wsrep_uuid_t* sst_uuid,
wsrep_seqno_t sst_seqno, wsrep_seqno_t sst_seqno,
bool needed) bool needed)
{ {
...@@ -242,8 +242,7 @@ struct sst_thread_arg ...@@ -242,8 +242,7 @@ struct sst_thread_arg
sst_thread_arg (const char* c) : cmd(c), err(-1), ret_str(0) sst_thread_arg (const char* c) : cmd(c), err(-1), ret_str(0)
{ {
mysql_mutex_init(key_LOCK_wsrep_sst_thread, mysql_mutex_init(key_LOCK_wsrep_sst_thread, &lock, MY_MUTEX_INIT_FAST);
&lock, MY_MUTEX_INIT_FAST);
mysql_cond_init(key_COND_wsrep_sst_thread, &cond, NULL); mysql_cond_init(key_COND_wsrep_sst_thread, &cond, NULL);
} }
...@@ -382,8 +381,8 @@ static ssize_t sst_prepare_other (const char* method, ...@@ -382,8 +381,8 @@ static ssize_t sst_prepare_other (const char* method,
const char* sst_dir= mysql_real_data_home; const char* sst_dir= mysql_real_data_home;
int ret= snprintf (cmd_str, cmd_len, int ret= snprintf (cmd_str, cmd_len,
"wsrep_sst_%s 'joiner' '%s' '%s' '%s' '%s' '%d' 2>sst.err", "wsrep_sst_%s 'joiner' '%s' '%s' '%s' '%s' '%d'",
method, addr_in, (sst_auth_real) ? sst_auth_real : "", method, addr_in, (sst_auth_real) ? sst_auth_real : "",
sst_dir, wsrep_defaults_file, (int)getpid()); sst_dir, wsrep_defaults_file, (int)getpid());
if (ret < 0 || ret >= cmd_len) if (ret < 0 || ret >= cmd_len)
...@@ -416,7 +415,7 @@ static ssize_t sst_prepare_other (const char* method, ...@@ -416,7 +415,7 @@ static ssize_t sst_prepare_other (const char* method,
//extern ulong my_bind_addr; //extern ulong my_bind_addr;
extern uint mysqld_port; extern uint mysqld_port;
/*! Just tells donor where ti sent mysqldump */ /*! Just tells donor where to send mysqldump */
static ssize_t sst_prepare_mysqldump (const char* addr_in, static ssize_t sst_prepare_mysqldump (const char* addr_in,
const char** addr_out) const char** addr_out)
{ {
...@@ -497,7 +496,7 @@ ssize_t wsrep_sst_prepare (void** msg) ...@@ -497,7 +496,7 @@ ssize_t wsrep_sst_prepare (void** msg)
} }
else else
{ {
ssize_t ret= default_ip (ip_buf, ip_max); ssize_t ret= guess_ip (ip_buf, ip_max);
if (ret && ret < ip_max) if (ret && ret < ip_max)
{ {
......
...@@ -316,7 +316,7 @@ thd::~thd () ...@@ -316,7 +316,7 @@ thd::~thd ()
extern ulong my_bind_addr; extern ulong my_bind_addr;
extern uint mysqld_port; extern uint mysqld_port;
size_t default_ip (char* buf, size_t buf_len) size_t guess_ip (char* buf, size_t buf_len)
{ {
size_t ip_len = 0; size_t ip_len = 0;
...@@ -325,64 +325,83 @@ size_t default_ip (char* buf, size_t buf_len) ...@@ -325,64 +325,83 @@ size_t default_ip (char* buf, size_t buf_len)
return 0; return 0;
} }
if (htonl(INADDR_ANY) == my_bind_addr) { if (htonl(INADDR_ANY) != my_bind_addr) {
// binds to all interfaces, try to find the address of the first one uint8_t* b = (uint8_t*)&my_bind_addr;
ip_len = snprintf (buf, buf_len,
"%hhu.%hhu.%hhu.%hhu", b[0],b[1],b[2],b[3]);
return ip_len;
}
// mysqld binds to all interfaces - try IP from wsrep_node_address
if (wsrep_node_address && wsrep_node_address[0] != '\0') {
const char* const colon_ptr = strchr(wsrep_node_address, ':');
if (colon_ptr)
ip_len = colon_ptr - wsrep_node_address;
else
ip_len = strlen(wsrep_node_address);
if (ip_len >= buf_len) {
WSREP_WARN("default_ip(): buffer too short: %zu <= %zd", buf_len, ip_len);
return 0;
}
memcpy (buf, wsrep_node_address, ip_len);
buf[ip_len] = '\0';
return ip_len;
}
// try to find the address of the first one
#if (TARGET_OS_LINUX == 1) #if (TARGET_OS_LINUX == 1)
const char cmd[] = "/sbin/ifconfig | " const char cmd[] = "/sbin/ifconfig | "
"grep -m1 -1 -E '^[a-z]?eth[0-9]' | tail -n 1 | " "grep -m1 -1 -E '^[a-z]?eth[0-9]' | tail -n 1 | "
"awk '{ print $2 }' | awk -F : '{ print $2 }'"; "awk '{ print $2 }' | awk -F : '{ print $2 }'";
#elif defined(__sun__) #elif defined(__sun__)
const char cmd[] = "/sbin/ifconfig -a | " const char cmd[] = "/sbin/ifconfig -a | "
"/usr/gnu/bin/grep -m1 -1 -E 'net[0-9]:' | tail -n 1 | awk '{ print $2 }'"; "/usr/gnu/bin/grep -m1 -1 -E 'net[0-9]:' | tail -n 1 | awk '{ print $2 }'";
#else #else
char *cmd; char *cmd;
#error "OS not supported" #error "OS not supported"
#endif #endif
wsp::process proc (cmd, "r"); wsp::process proc (cmd, "r");
if (NULL != proc.pipe()) { if (NULL != proc.pipe()) {
char* ret; char* ret;
ret = fgets (buf, buf_len, proc.pipe()); ret = fgets (buf, buf_len, proc.pipe());
if (proc.wait()) return 0; if (proc.wait()) return 0;
if (NULL == ret) { if (NULL == ret) {
WSREP_ERROR("Failed to read output of: '%s'", cmd); WSREP_ERROR("Failed to read output of: '%s'", cmd);
return 0;
}
}
else {
WSREP_ERROR("Failed to execute: '%s'", cmd);
return 0; return 0;
} }
}
else {
WSREP_ERROR("Failed to execute: '%s'", cmd);
return 0;
}
// clear possible \n at the end of ip string left by fgets() // clear possible \n at the end of ip string left by fgets()
ip_len = strlen (buf); ip_len = strlen (buf);
if (ip_len > 0 && '\n' == buf[ip_len - 1]) { if (ip_len > 0 && '\n' == buf[ip_len - 1]) {
ip_len--; ip_len--;
buf[ip_len] = '\0'; buf[ip_len] = '\0';
} }
if (INADDR_NONE == inet_addr(buf)) { if (INADDR_NONE == inet_addr(buf)) {
if (strlen(buf) != 0) { if (strlen(buf) != 0) {
WSREP_WARN("Shell command returned invalid address: '%s'", buf); WSREP_WARN("Shell command returned invalid address: '%s'", buf);
}
return 0;
} }
} return 0;
else {
uint8_t* b = (uint8_t*)&my_bind_addr;
ip_len = snprintf (buf, buf_len,
"%hhu.%hhu.%hhu.%hhu", b[0],b[1],b[2],b[3]);
} }
return ip_len; return ip_len;
} }
size_t default_address(char* buf, size_t buf_len) size_t guess_address(char* buf, size_t buf_len)
{ {
size_t addr_len = default_ip (buf, buf_len); size_t addr_len = guess_ip (buf, buf_len);
if (addr_len && addr_len < buf_len) { if (addr_len && addr_len < buf_len) {
addr_len += snprintf (buf + addr_len, buf_len - addr_len, addr_len += snprintf (buf + addr_len, buf_len - addr_len,
......
...@@ -464,31 +464,27 @@ wsrep_assign_to_mysql (SHOW_VAR* mysql, wsrep_stats_var* wsrep) ...@@ -464,31 +464,27 @@ wsrep_assign_to_mysql (SHOW_VAR* mysql, wsrep_stats_var* wsrep)
} }
} }
static wsrep_stats_var* wsrep_status_vars = NULL;
#if DYNAMIC #if DYNAMIC
// somehow this mysql status thing works only with statically allocated arrays. // somehow this mysql status thing works only with statically allocated arrays.
static SHOW_VAR* mysql_status_vars = NULL; static SHOW_VAR* mysql_status_vars = NULL;
static int mysql_status_len = -1; static int mysql_status_len = -1;
#else #else
static SHOW_VAR mysql_status_vars[100 + 1]; static SHOW_VAR mysql_status_vars[512 + 1];
static const int mysql_status_len = 100; static const int mysql_status_len = 512;
#endif #endif
static void export_wsrep_status_to_mysql() static void export_wsrep_status_to_mysql(THD* thd)
{ {
int wsrep_status_len, i; int wsrep_status_len, i;
if (wsrep_status_vars) wsrep->stats_free (wsrep, wsrep_status_vars); thd->wsrep_status_vars = wsrep->stats_get(wsrep);
wsrep_status_vars = wsrep->stats_get (wsrep);
if (!wsrep_status_vars) { if (!thd->wsrep_status_vars) {
return; return;
} }
for (wsrep_status_len = 0; for (wsrep_status_len = 0;
wsrep_status_vars[wsrep_status_len].name != NULL; thd->wsrep_status_vars[wsrep_status_len].name != NULL;
wsrep_status_len++); wsrep_status_len++);
#if DYNAMIC #if DYNAMIC
...@@ -511,7 +507,7 @@ static void export_wsrep_status_to_mysql() ...@@ -511,7 +507,7 @@ static void export_wsrep_status_to_mysql()
#endif #endif
for (i = 0; i < wsrep_status_len; i++) for (i = 0; i < wsrep_status_len; i++)
wsrep_assign_to_mysql (mysql_status_vars + i, wsrep_status_vars + i); wsrep_assign_to_mysql (mysql_status_vars + i, thd->wsrep_status_vars + i);
mysql_status_vars[wsrep_status_len].name = NullS; mysql_status_vars[wsrep_status_len].name = NullS;
mysql_status_vars[wsrep_status_len].value = NullS; mysql_status_vars[wsrep_status_len].value = NullS;
...@@ -520,8 +516,17 @@ static void export_wsrep_status_to_mysql() ...@@ -520,8 +516,17 @@ static void export_wsrep_status_to_mysql()
int wsrep_show_status (THD *thd, SHOW_VAR *var, char *buff) int wsrep_show_status (THD *thd, SHOW_VAR *var, char *buff)
{ {
export_wsrep_status_to_mysql(); export_wsrep_status_to_mysql(thd);
var->type= SHOW_ARRAY; var->type= SHOW_ARRAY;
var->value= (char *) &mysql_status_vars; var->value= (char *) &mysql_status_vars;
return 0; return 0;
} }
void wsrep_free_status (THD* thd)
{
if (thd->wsrep_status_vars)
{
wsrep->stats_free (wsrep, thd->wsrep_status_vars);
thd->wsrep_status_vars = 0;
}
}
...@@ -1423,22 +1423,12 @@ row_ins_check_foreign_constraint( ...@@ -1423,22 +1423,12 @@ row_ins_check_foreign_constraint(
if (check_ref) { if (check_ref) {
err = DB_SUCCESS; err = DB_SUCCESS;
#ifdef WITH_WSREP #ifdef WITH_WSREP
if (thr->fk_cascade_depth == 0) { err = wsrep_append_foreign_key(
err = wsrep_append_foreign_key( thr_get_trx(thr),
thr_get_trx(thr), foreign,
foreign, rec,
rec, check_index,
check_index, check_ref, TRUE);
check_ref, TRUE);
} else {
fprintf(stderr, "WSREP: skipping FK key append\n");
err = wsrep_append_foreign_key(
thr_get_trx(thr),
foreign,
rec,
check_index,
TRUE, TRUE);
}
#endif /* WITH_WSREP */ #endif /* WITH_WSREP */
goto end_scan; goto end_scan;
} else if (foreign->type != 0) { } else if (foreign->type != 0) {
...@@ -1469,14 +1459,6 @@ row_ins_check_foreign_constraint( ...@@ -1469,14 +1459,6 @@ row_ins_check_foreign_constraint(
goto end_scan; goto end_scan;
} }
#ifdef WITH_WSREP_REMOVED
err = wsrep_append_foreign_key(
thr_get_trx(thr),
foreign,
rec,
check_index,
FALSE);
#endif /* WITH_WSREP */
/* row_ins_foreign_check_on_constraint /* row_ins_foreign_check_on_constraint
may have repositioned pcur on a may have repositioned pcur on a
different block */ different block */
......
...@@ -1429,22 +1429,12 @@ row_ins_check_foreign_constraint( ...@@ -1429,22 +1429,12 @@ row_ins_check_foreign_constraint(
if (check_ref) { if (check_ref) {
err = DB_SUCCESS; err = DB_SUCCESS;
#ifdef WITH_WSREP #ifdef WITH_WSREP
if (thr->fk_cascade_depth == 0) { err = wsrep_append_foreign_key(
err = wsrep_append_foreign_key( thr_get_trx(thr),
thr_get_trx(thr), foreign,
foreign, rec,
rec, check_index,
check_index, check_ref, TRUE);
check_ref, TRUE);
} else {
fprintf(stderr, "WSREP: skipping FK key append\n");
err = wsrep_append_foreign_key(
thr_get_trx(thr),
foreign,
rec,
check_index,
TRUE, TRUE);
}
#endif /* WITH_WSREP */ #endif /* WITH_WSREP */
goto end_scan; goto end_scan;
} else if (foreign->type != 0) { } else if (foreign->type != 0) {
...@@ -1475,14 +1465,6 @@ row_ins_check_foreign_constraint( ...@@ -1475,14 +1465,6 @@ row_ins_check_foreign_constraint(
goto end_scan; goto end_scan;
} }
#ifdef WITH_WSREP_REMOVED
err = wsrep_append_foreign_key(
thr_get_trx(thr),
foreign,
rec,
check_index,
FALSE);
#endif /* WITH_WSREP */
/* row_ins_foreign_check_on_constraint /* row_ins_foreign_check_on_constraint
may have repositioned pcur on a may have repositioned pcur on a
different block */ different block */
......
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