summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Docs/README-wsrep7
-rw-r--r--scripts/wsrep_sst_common.sh12
-rw-r--r--sql/sql_class.cc4
-rw-r--r--sql/sql_class.h3
-rw-r--r--sql/sql_parse.cc25
-rw-r--r--sql/sql_table.cc49
-rw-r--r--sql/wsrep_check_opts.cc2
-rw-r--r--sql/wsrep_hton.cc7
-rw-r--r--sql/wsrep_mysqld.cc19
-rw-r--r--sql/wsrep_sst.cc11
-rw-r--r--sql/wsrep_var.cc10
-rw-r--r--storage/innobase/row/row0upd.c1
-rw-r--r--storage/xtradb/row/row0upd.c1
-rw-r--r--support-files/mysql.spec.sh5
-rw-r--r--support-files/wsrep.cnf.sh2
15 files changed, 132 insertions, 26 deletions
diff --git a/Docs/README-wsrep b/Docs/README-wsrep
index 025379764b2..422ec52f48a 100644
--- a/Docs/README-wsrep
+++ b/Docs/README-wsrep
@@ -377,11 +377,12 @@ the other cluster members by transferring state snapshot from one of them.
The options below govern how this happens and should be set up before attempting
to join or start a cluster.
-wsrep_sst_method=mysqldump
+wsrep_sst_method=rsync
What method to use to copy database state to a newly joined node. Supported
methods:
- - mysqldump: slow (except for small datasets) but most tested.
- - rsync: much faster on large datasets.
+ - mysqldump: slow (except for small datasets) but allows for upgrade
+ between major MySQL versions or InnoDB features.
+ - rsync: much faster on large datasets (default).
- rsync_wan: same as rsync but with deltaxfer to minimize network traffic.
- xtrabackup: very fast and practically non-blocking SST method based on
Percona's xtrabackup tool.
diff --git a/scripts/wsrep_sst_common.sh b/scripts/wsrep_sst_common.sh
index 44c97fdb5f4..30303de0779 100644
--- a/scripts/wsrep_sst_common.sh
+++ b/scripts/wsrep_sst_common.sh
@@ -1,4 +1,4 @@
-# Copyright (C) 2010 Codership Oy
+# Copyright (C) 2012 Codership Oy
#
# 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
@@ -19,6 +19,7 @@
set -u
WSREP_SST_OPT_BYPASS=0
+WSREP_SST_OPT_DATA=""
while [ $# -gt 0 ]; do
case "$1" in
@@ -86,7 +87,12 @@ shift
done
readonly WSREP_SST_OPT_BYPASS
-SST_PROGRESS_FILE="$WSREP_SST_OPT_DATA/sst_in_progress"
+if [ -n "$WSREP_SST_OPT_DATA" ]
+then
+ SST_PROGRESS_FILE="$WSREP_SST_OPT_DATA/sst_in_progress"
+else
+ SST_PROGRESS_FILE=""
+fi
wsrep_log()
{
@@ -108,6 +114,6 @@ wsrep_log_info()
wsrep_cleanup_progress_file()
{
- rm -f $SST_PROGRESS_FILE 2>/dev/null
+ [ -n "$SST_PROGRESS_FILE" ] && rm -f "$SST_PROGRESS_FILE" 2>/dev/null
}
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 2469f2dd3b1..0e371adfe56 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -1116,6 +1116,8 @@ THD::THD()
wsrep_status_vars = 0;
wsrep_mysql_replicated = 0;
wsrep_bf_thd = NULL;
+ wsrep_TOI_pre_query = NULL;
+ wsrep_TOI_pre_query_len = 0;
#endif
/* Call to init() below requires fully initialized Open_tables_state. */
reset_open_tables_state(this);
@@ -1477,6 +1479,8 @@ void THD::init(void)
wsrep_consistency_check = NO_CONSISTENCY_CHECK;
wsrep_mysql_replicated = 0;
wsrep_bf_thd = NULL;
+ wsrep_TOI_pre_query = NULL;
+ wsrep_TOI_pre_query_len = 0;
#endif
if (variables.sql_log_bin)
variables.option_bits|= OPTION_BIN_LOG;
diff --git a/sql/sql_class.h b/sql/sql_class.h
index f6391f82b02..f1932cfe8c7 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -2381,6 +2381,9 @@ public:
wsrep_stats_var* wsrep_status_vars;
int wsrep_mysql_replicated;
THD* wsrep_bf_thd;
+ const char* wsrep_TOI_pre_query; /* a query to apply before
+ the actual TOI query */
+ size_t wsrep_TOI_pre_query_len;
#endif /* WITH_WSREP */
/**
Internal parser state.
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 657239d5b0e..2962b6bfbba 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -2893,12 +2893,6 @@ case SQLCOM_PREPARE:
if (create_info.options & HA_LEX_CREATE_TMP_TABLE)
thd->variables.option_bits|= OPTION_KEEP_LOG;
/* regular create */
-#ifdef WITH_WSREP
- if (!thd->is_current_stmt_binlog_format_row() ||
- !(create_info.options & HA_LEX_CREATE_TMP_TABLE))
- WSREP_TO_ISOLATION_BEGIN(create_table->db, create_table->table_name,
- NULL)
-#endif /* WITH_WSREP */
if (create_info.options & HA_LEX_CREATE_TABLE_LIKE)
{
/* CREATE TABLE ... LIKE ... */
@@ -2907,6 +2901,12 @@ case SQLCOM_PREPARE:
}
else
{
+#ifdef WITH_WSREP
+ if (!thd->is_current_stmt_binlog_format_row() ||
+ !(create_info.options & HA_LEX_CREATE_TMP_TABLE))
+ WSREP_TO_ISOLATION_BEGIN(create_table->db, create_table->table_name,
+ NULL)
+#endif /* WITH_WSREP */
/* Regular CREATE TABLE */
res= mysql_create_table(thd, create_table,
&create_info, &alter_info);
@@ -8260,6 +8260,15 @@ wsrep_status_t wsrep_apply_cb(void* const ctx,
#endif /* WSREP_PROC_INFO */
if (WSREP_OK != rcode) wsrep_write_rbr_buf(thd, buf, buf_len);
+ TABLE *tmp;
+ while ((tmp = thd->temporary_tables))
+ {
+ WSREP_DEBUG("Applier %lu, has temporary tables: %s.%s",
+ thd->thread_id,
+ (tmp->s) ? tmp->s->db.str : "void",
+ (tmp->s) ? tmp->s->table_name.str : "void");
+ close_temporary_table(thd, tmp, 1, 1);
+ }
return rcode;
}
@@ -8447,6 +8456,10 @@ void wsrep_replication_process(THD *thd)
mysql_cond_broadcast(&COND_thread_count);
mysql_mutex_unlock(&LOCK_thread_count);
+ if (thd->temporary_tables)
+ {
+ WSREP_DEBUG("Applier %lu, has temporary tables at exit", thd->thread_id);
+ }
wsrep_return_from_bf_mode(thd, &shadow);
DBUG_VOID_RETURN;
}
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 7d87b0b22db..332f9d1b80f 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -4752,6 +4752,49 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, TABLE_LIST* src_table,
uint not_used;
DBUG_ENTER("mysql_create_like_table");
+#ifdef WITH_WSREP
+ if (!thd->wsrep_applier)
+ {
+ TABLE *tmp_table;
+ bool is_tmp_table= FALSE;
+
+ for (tmp_table= thd->temporary_tables; tmp_table; tmp_table=tmp_table->next)
+ {
+ if (!strcmp(src_table->db, tmp_table->s->db.str) &&
+ !strcmp(src_table->table_name, tmp_table->s->table_name.str))
+ {
+ is_tmp_table= TRUE;
+ break;
+ }
+ }
+ if (!is_tmp_table)
+ {
+ WSREP_TO_ISOLATION_BEGIN(table->db, table->table_name, NULL);
+ }
+ else
+ {
+ TABLE_LIST tbl;
+ bzero((void*) &tbl, sizeof(tbl));
+ tbl.db= src_table->db;
+ tbl.table_name= tbl.alias= src_table->table_name;
+ tbl.table= tmp_table;
+ char buf[2048];
+ String query(buf, sizeof(buf), system_charset_info);
+ query.length(0); // Have to zero it since constructor doesn't
+
+ (void) store_create_info(thd, &tbl, &query, NULL, TRUE);
+ WSREP_DEBUG("TMP TABLE: %s", query.ptr());
+
+ thd->wsrep_TOI_pre_query= query.ptr();
+ thd->wsrep_TOI_pre_query_len= query.length();
+
+ WSREP_TO_ISOLATION_BEGIN(table->db, table->table_name, NULL);
+
+ thd->wsrep_TOI_pre_query= NULL;
+ thd->wsrep_TOI_pre_query_len= 0;
+ }
+ }
+#endif
/*
We the open source table to get its description in HA_CREATE_INFO
@@ -4899,6 +4942,12 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, TABLE_LIST* src_table,
err:
DBUG_RETURN(res);
+#ifdef WITH_WSREP
+ error:
+ thd->wsrep_TOI_pre_query= NULL;
+ DBUG_RETURN(TRUE);
+#endif /* WITH_WSREP */
+
}
diff --git a/sql/wsrep_check_opts.cc b/sql/wsrep_check_opts.cc
index 5764be39093..ce8a46c6bd5 100644
--- a/sql/wsrep_check_opts.cc
+++ b/sql/wsrep_check_opts.cc
@@ -40,7 +40,7 @@ static struct opt opts[] =
{
{ "wsrep_slave_threads", "1" }, // mysqld.cc
{ "bind_address", "0.0.0.0" }, // mysqld.cc
- { "wsrep_sst_method","mysqldump" }, // mysqld.cc
+ { "wsrep_sst_method", "rsync" }, // mysqld.cc
{ "wsrep_sst_receive_address","AUTO"}, // mysqld.cc
{ "binlog_format", "ROW" }, // mysqld.cc
{ "wsrep_provider", "none" }, // mysqld.cc
diff --git a/sql/wsrep_hton.cc b/sql/wsrep_hton.cc
index 8b682d579d8..bd934031fc3 100644
--- a/sql/wsrep_hton.cc
+++ b/sql/wsrep_hton.cc
@@ -75,7 +75,12 @@ void wsrep_register_hton(THD* thd, bool all)
if (i->ht()->db_type == DB_TYPE_INNODB)
{
trans_register_ha(thd, all, wsrep_hton);
- thd->ha_data[wsrep_hton->slot].ha_info[all].set_trx_read_write();
+
+ /* follow innodb read/write settting */
+ if (i->is_trx_read_write())
+ {
+ thd->ha_data[wsrep_hton->slot].ha_info[all].set_trx_read_write();
+ }
break;
}
}
diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc
index 790cf45def4..f6ff3eecbcb 100644
--- a/sql/wsrep_mysqld.cc
+++ b/sql/wsrep_mysqld.cc
@@ -983,16 +983,23 @@ int wsrep_to_buf_helper(
if (open_cached_file(&tmp_io_cache, mysql_tmpdir, TEMP_PREFIX,
65536, MYF(MY_WME)))
return 1;
- Query_log_event ev(thd, query, query_len, FALSE, FALSE, FALSE, 0);
- int ret(0);
- Format_description_log_event *tmp_fd = new Format_description_log_event(4);
- tmp_fd->checksum_alg = binlog_checksum_options;
- tmp_fd->write(&tmp_io_cache);
- delete tmp_fd;
+ int ret(0);
+ /* if there is prepare query, add event for it */
+ if (thd->wsrep_TOI_pre_query)
+ {
+ Query_log_event ev(thd, thd->wsrep_TOI_pre_query,
+ thd->wsrep_TOI_pre_query_len,
+ FALSE, FALSE, FALSE, 0);
+ if (ev.write(&tmp_io_cache)) ret= 1;
+ }
+ /* append the actual query */
+ Query_log_event ev(thd, query, query_len, FALSE, FALSE, FALSE, 0);
if (ev.write(&tmp_io_cache)) ret= 1;
+
if (!ret && wsrep_write_cache(&tmp_io_cache, buf, buf_len)) ret= 1;
+
close_cached_file(&tmp_io_cache);
return ret;
}
diff --git a/sql/wsrep_sst.cc b/sql/wsrep_sst.cc
index 5aca1de6d0e..204a937ea8f 100644
--- a/sql/wsrep_sst.cc
+++ b/sql/wsrep_sst.cc
@@ -45,8 +45,9 @@ extern const char wsrep_defaults_file[];
#define WSREP_SST_OPT_BYPASS "--bypass"
#define WSREP_SST_MYSQLDUMP "mysqldump"
+#define WSREP_SST_RSYNC "rsync"
#define WSREP_SST_SKIP "skip"
-#define WSREP_SST_DEFAULT WSREP_SST_MYSQLDUMP
+#define WSREP_SST_DEFAULT WSREP_SST_RSYNC
#define WSREP_SST_ADDRESS_AUTO "AUTO"
#define WSREP_SST_AUTH_MASK "********"
@@ -691,9 +692,11 @@ static int sst_donate_mysqldump (const char* addr,
WSREP_SST_OPT_PORT" '%s' "
WSREP_SST_OPT_LPORT" '%u' "
WSREP_SST_OPT_SOCKET" '%s' "
+ WSREP_SST_OPT_DATA" '%s' "
WSREP_SST_OPT_GTID" '%s:%lld'"
"%s",
- user, pswd, host, port, mysqld_port, mysqld_unix_port, uuid_str,
+ user, pswd, host, port, mysqld_port, mysqld_unix_port,
+ mysql_real_data_home, uuid_str,
(long long)seqno, bypass ? " "WSREP_SST_OPT_BYPASS : "");
WSREP_DEBUG("Running: '%s'", cmd_str);
@@ -747,8 +750,8 @@ static int sst_flush_tables(THD* thd)
else
{
/* make sure logs are flushed after global read lock acquired */
- err= reload_acl_and_cache(thd, REFRESH_ENGINE_LOG,
- (TABLE_LIST*) 0, &not_used);
+ err= reload_acl_and_cache(thd, REFRESH_ENGINE_LOG,
+ (TABLE_LIST*) 0, &not_used);
}
if (err)
diff --git a/sql/wsrep_var.cc b/sql/wsrep_var.cc
index b051254f3ff..8fa81376337 100644
--- a/sql/wsrep_var.cc
+++ b/sql/wsrep_var.cc
@@ -236,7 +236,17 @@ bool wsrep_provider_update (sys_var *self, THD* thd, enum_var_type type)
WSREP_DEBUG("wsrep_provider_update: %s", wsrep_provider);
+ /* stop replication is heavy operation, and includes closing all client
+ connections. Closing clients may need to get LOCK_global_system_variables
+ at least in MariaDB.
+
+ Note: releasing LOCK_global_system_variables may cause race condition, if
+ there can be several concurrent clients changing wsrep_provider
+ */
+ mysql_mutex_unlock(&LOCK_global_system_variables);
wsrep_stop_replication(thd);
+ mysql_mutex_lock(&LOCK_global_system_variables);
+
wsrep_deinit();
char* tmp= strdup(wsrep_provider); // wsrep_init() rewrites provider
diff --git a/storage/innobase/row/row0upd.c b/storage/innobase/row/row0upd.c
index ba0a70d2c48..cc0ac9d9613 100644
--- a/storage/innobase/row/row0upd.c
+++ b/storage/innobase/row/row0upd.c
@@ -52,6 +52,7 @@ Created 12/27/1996 Heikki Tuuri
#include "eval0eval.h"
#include "buf0lru.h"
#ifdef WITH_WSREP
+#include "ha_prototypes.h"
extern my_bool wsrep_debug;
#endif
diff --git a/storage/xtradb/row/row0upd.c b/storage/xtradb/row/row0upd.c
index ff63a8801ce..6898eb9cfcd 100644
--- a/storage/xtradb/row/row0upd.c
+++ b/storage/xtradb/row/row0upd.c
@@ -52,6 +52,7 @@ Created 12/27/1996 Heikki Tuuri
#include "eval0eval.h"
#include "buf0lru.h"
#ifdef WITH_WSREP
+#include "ha_prototypes.h"
extern my_bool wsrep_debug;
#endif
diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh
index d40c96fad19..a1b32bdeed0 100644
--- a/support-files/mysql.spec.sh
+++ b/support-files/mysql.spec.sh
@@ -300,11 +300,14 @@ documentation and the manual for more information.
%package -n MySQL-server%{product_suffix}
%if %{defined with_wsrep}
Version: %{mysql_version}
-#Release: %{wsrep_version}.%{release}
%endif
Summary: MySQL: a very fast and reliable SQL database server
Group: Applications/Databases
+%if %{defined with_wsrep}
+Requires: %{distro_requires} rsync
+%else
Requires: %{distro_requires}
+%endif
%if %{defined susever}
Provides: msqlormysql MySQL MySQL-server
Conflicts: mysql mysql-server mysql-advanced mysql-server-advanced
diff --git a/support-files/wsrep.cnf.sh b/support-files/wsrep.cnf.sh
index 507f83324b9..756d4f6783b 100644
--- a/support-files/wsrep.cnf.sh
+++ b/support-files/wsrep.cnf.sh
@@ -108,7 +108,7 @@ wsrep_notify_cmd=
##
# State Snapshot Transfer method
-wsrep_sst_method=mysqldump
+wsrep_sst_method=rsync
# Address which donor should send State Snapshot to.
# Should be the address of THIS node. DON'T SET IT TO DONOR ADDRESS!!!