summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey Yurchenko <ayurchen@galeracluster.com>2017-06-19 17:23:02 +0700
committerJan Lindström <jan.lindstrom@mariadb.com>2017-10-19 09:34:09 +0300
commit86d31ce9f141d34fffcf7f355d4c0e6e54077eb3 (patch)
treef67f470ef746d475691f322e6a2992250f56338f
parent8da6b4ef5260179b1577843517c46e4b95a9e911 (diff)
downloadmariadb-git-86d31ce9f141d34fffcf7f355d4c0e6e54077eb3.tar.gz
MW-384 protect access to wsrep_ready variable with mutex
-rw-r--r--scripts/mysql_config.pl6
-rw-r--r--sql/mysqld.cc2
-rw-r--r--sql/slave.cc2
-rw-r--r--sql/sql_parse.cc4
-rw-r--r--sql/wsrep_mysqld.cc36
-rw-r--r--sql/wsrep_mysqld.h3
-rw-r--r--sql/wsrep_priv.h2
-rw-r--r--sql/wsrep_sst.cc1
8 files changed, 33 insertions, 23 deletions
diff --git a/scripts/mysql_config.pl b/scripts/mysql_config.pl
index 5490853c091..a9254bb966e 100644
--- a/scripts/mysql_config.pl
+++ b/scripts/mysql_config.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# -*- cperl -*-
#
-# Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -53,7 +53,7 @@ my $cwd = cwd();
my $basedir;
my $socket = '/tmp/mysql.sock';
-my $version = '5.5.38';
+my $version = '5.5.58';
sub which
{
@@ -204,7 +204,7 @@ $flags->{embedded_libs} =
[@ldflags,@lib_e_opts,'','','','',''];
$flags->{include} = ["-I$pkgincludedir"];
-$flags->{cflags} = [@{$flags->{include}},split(" ",'-Wall -DWITH_WSREP -DWSREP_PROC_INFO -DMYSQL_MAX_VARIABLE_VALUE_LEN=2048 -DWITH_INNODB_DISALLOW_WRITES -O2 -g -DNDEBUG -DDBUG_OFF')];
+$flags->{cflags} = [@{$flags->{include}},split(" ",'')];
# ----------------------------------------------------------------------
# Remove some options that a client doesn't have to care about
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 9198f616d15..f76cbe5e5b2 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -7929,7 +7929,7 @@ SHOW_VAR status_vars[]= {
#endif
#ifdef WITH_WSREP
{"wsrep_connected", (char*) &wsrep_connected, SHOW_BOOL},
- {"wsrep_ready", (char*) &wsrep_ready, SHOW_BOOL},
+ {"wsrep_ready", (char*) &wsrep_show_ready, SHOW_FUNC},
{"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},
diff --git a/sql/slave.cc b/sql/slave.cc
index 5f7c5ffdb84..f370e3dd27f 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -3794,7 +3794,7 @@ err_during_init:
*/
if (wsrep_node_dropped && wsrep_restart_slave)
{
- if (wsrep_ready)
+ if (wsrep_ready_get())
{
WSREP_INFO("Slave error due to node temporarily non-primary"
"SQL slave will continue");
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index f0f021d4047..d102c6162d0 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -851,7 +851,7 @@ bool do_command(THD *thd)
* bail out if DB snapshot has not been installed. We however,
* allow queries "SET" and "SHOW", they are trapped later in execute_command
*/
- if (thd->variables.wsrep_on && !thd->wsrep_applier && !wsrep_ready &&
+ if (thd->variables.wsrep_on && !thd->wsrep_applier && !wsrep_ready_get() &&
command != COM_QUERY &&
command != COM_PING &&
command != COM_QUIT &&
@@ -2382,7 +2382,7 @@ mysql_execute_command(THD *thd)
We additionally allow all other commands that do not change data in
case wsrep_dirty_reads is enabled.
*/
- if (thd->variables.wsrep_on && !thd->wsrep_applier && !wsrep_ready &&
+ if (thd->variables.wsrep_on && !thd->wsrep_applier && !wsrep_ready_get() &&
lex->sql_command != SQLCOM_SET_OPTION &&
!(thd->variables.wsrep_dirty_reads &&
!is_update_query(lex->sql_command)) &&
diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc
index 4ac346ca0a3..54fdf430f86 100644
--- a/sql/wsrep_mysqld.cc
+++ b/sql/wsrep_mysqld.cc
@@ -13,6 +13,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+#include <sql_plugin.h> // SHOW_MY_BOOL
#include <mysqld.h>
#include <sql_class.h>
#include <sql_parse.h>
@@ -295,7 +296,7 @@ wsrep_view_handler_cb (void* app_ctx,
// version change
if (view->proto_ver != wsrep_protocol_version)
{
- my_bool wsrep_ready_saved= wsrep_ready;
+ my_bool wsrep_ready_saved= wsrep_ready_get();
wsrep_ready_set(FALSE);
WSREP_INFO("closing client connections for "
"protocol change %ld -> %d",
@@ -409,16 +410,34 @@ out:
return WSREP_CB_SUCCESS;
}
-void wsrep_ready_set (my_bool x)
+my_bool wsrep_ready_set (my_bool x)
{
WSREP_DEBUG("Setting wsrep_ready to %d", x);
if (mysql_mutex_lock (&LOCK_wsrep_ready)) abort();
- if (wsrep_ready != x)
+ my_bool ret= (wsrep_ready != x);
+ if (ret)
{
wsrep_ready= x;
mysql_cond_signal (&COND_wsrep_ready);
}
mysql_mutex_unlock (&LOCK_wsrep_ready);
+ return ret;
+}
+
+my_bool wsrep_ready_get (void)
+{
+ if (mysql_mutex_lock (&LOCK_wsrep_ready)) abort();
+ my_bool ret= wsrep_ready;
+ mysql_mutex_unlock (&LOCK_wsrep_ready);
+ return ret;
+}
+
+int wsrep_show_ready(THD *thd, SHOW_VAR *var, char *buff)
+{
+ var->type= SHOW_MY_BOOL;
+ var->value= buff;
+ *((my_bool *)buff)= wsrep_ready_get();
+ return 0;
}
// Wait until wsrep has reached ready state
@@ -437,17 +456,8 @@ void wsrep_ready_wait ()
static void wsrep_synced_cb(void* app_ctx)
{
WSREP_INFO("Synchronized with group, ready for connections");
- bool signal_main= false;
- if (mysql_mutex_lock (&LOCK_wsrep_ready)) abort();
- if (!wsrep_ready)
- {
- wsrep_ready= TRUE;
- mysql_cond_signal (&COND_wsrep_ready);
- signal_main= true;
-
- }
+ my_bool signal_main= wsrep_ready_set(TRUE);
local_status.set(WSREP_MEMBER_SYNCED);
- mysql_mutex_unlock (&LOCK_wsrep_ready);
if (signal_main)
{
diff --git a/sql/wsrep_mysqld.h b/sql/wsrep_mysqld.h
index bb33d2f1069..56e3baae7cc 100644
--- a/sql/wsrep_mysqld.h
+++ b/sql/wsrep_mysqld.h
@@ -115,7 +115,6 @@ enum enum_wsrep_sync_wait {
// MySQL status variables
extern my_bool wsrep_connected;
-extern my_bool wsrep_ready;
extern const char* wsrep_cluster_state_uuid;
extern long long wsrep_cluster_conf_id;
extern const char* wsrep_cluster_status;
@@ -130,6 +129,7 @@ extern const char* wsrep_provider_vendor;
extern my_bool wsrep_inited; // whether wsrep is initialized ?
int wsrep_show_status(THD *thd, SHOW_VAR *var, char *buff);
+int wsrep_show_ready(THD *thd, SHOW_VAR *var, char *buff);
void wsrep_free_status(THD *thd);
/* Filters out --wsrep-new-cluster oprtion from argv[]
@@ -245,6 +245,7 @@ extern wsrep_seqno_t wsrep_locked_seqno;
#define WSREP_PROVIDER_EXISTS \
(wsrep_provider && strncasecmp(wsrep_provider, WSREP_NONE, FN_REFLEN))
+extern my_bool wsrep_ready_get();
extern void wsrep_ready_wait();
enum wsrep_trx_status {
diff --git a/sql/wsrep_priv.h b/sql/wsrep_priv.h
index 93640fbcc03..ce97ac65182 100644
--- a/sql/wsrep_priv.h
+++ b/sql/wsrep_priv.h
@@ -26,7 +26,7 @@
#include <pthread.h>
#include <cstdio>
-void wsrep_ready_set (my_bool x);
+my_bool wsrep_ready_set (my_bool x);
ssize_t wsrep_sst_prepare (void** msg);
wsrep_cb_status wsrep_sst_donate_cb (void* app_ctx,
diff --git a/sql/wsrep_sst.cc b/sql/wsrep_sst.cc
index a5fe8a1e2d8..d870824ed9d 100644
--- a/sql/wsrep_sst.cc
+++ b/sql/wsrep_sst.cc
@@ -1057,7 +1057,6 @@ wsrep_cb_status_t wsrep_sst_donate_cb (void* app_ctx, void* recv_ctx,
{
/* This will be reset when sync callback is called.
* Should we set wsrep_ready to FALSE here too? */
-// wsrep_notify_status(WSREP_MEMBER_DONOR);
local_status.set(WSREP_MEMBER_DONOR);
const char* method = (char*)msg;