Commit fca065f9 authored by Seppo Jaakola's avatar Seppo Jaakola

Merged with lp:~codership/codership-mysql/5.5-23, up to revision 3903

parent 2db87f65
......@@ -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.
......
# 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
}
......@@ -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;
......
......@@ -2381,6 +2381,9 @@ class THD :public Statement,
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.
......
......@@ -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;
}
......
......@@ -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 */
}
......
......@@ -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
......
......@@ -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);
/* 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;
}
}
......
......@@ -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;
}
......
......@@ -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);
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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!!!
......
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