summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2015-02-06 16:14:23 +0100
committerSergei Golubchik <serg@mariadb.org>2015-02-06 16:14:23 +0100
commit8e7649867f23ef4fca5ddb6678a66e414026ef7b (patch)
treeff7649743a3bf13ea13eb80f1126a13cd756d335 /sql
parentf9448bcb2153aac614ecb260a4dd7f27b04f17a2 (diff)
parent7cda4bee0ef7c8a3ec85e94bc1443ceaba3a64e8 (diff)
downloadmariadb-git-8e7649867f23ef4fca5ddb6678a66e414026ef7b.tar.gz
Merge 10.0-galera into 10.1
Diffstat (limited to 'sql')
-rw-r--r--sql/keycaches.cc1
-rw-r--r--sql/mysqld.cc12
-rw-r--r--sql/rpl_mi.cc7
-rw-r--r--sql/sql_alter.cc20
-rw-r--r--sql/sql_class.cc8
-rw-r--r--sql/sql_parse.cc4
-rw-r--r--sql/sql_prepare.cc2
-rw-r--r--sql/sys_vars.cc40
-rw-r--r--sql/wsrep_applier.cc3
-rw-r--r--sql/wsrep_mysqld.cc26
-rw-r--r--sql/wsrep_mysqld.h3
-rw-r--r--sql/wsrep_thd.cc63
-rw-r--r--sql/wsrep_utils.cc9
-rw-r--r--sql/wsrep_var.cc1
14 files changed, 112 insertions, 87 deletions
diff --git a/sql/keycaches.cc b/sql/keycaches.cc
index 9426ccc9e95..78e64ebac72 100644
--- a/sql/keycaches.cc
+++ b/sql/keycaches.cc
@@ -223,6 +223,7 @@ Rpl_filter *get_or_create_rpl_filter(const char *name, uint length)
void free_rpl_filter(const char *name, Rpl_filter *filter)
{
delete filter;
+ filter= 0;
}
void free_all_rpl_filters()
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 423d07b02cd..6d8305dea91 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -4976,7 +4976,7 @@ a file name for --log-bin-index option", opt_binlog_index_name);
- SST may modify binlog index file, so it must be opened
after SST has happened
*/
- if (WSREP_ON && !wsrep_recovery) /* WSREP BEFORE SE */
+ if (WSREP_ON && !wsrep_recovery && !opt_abort) /* WSREP BEFORE SE */
{
if (opt_bootstrap) // bootsrap option given - disable wsrep functionality
{
@@ -9240,6 +9240,16 @@ static int get_options(int *argc_ptr, char ***argv_ptr)
else
global_system_variables.option_bits&= ~OPTION_BIG_SELECTS;
+ if (!opt_bootstrap && WSREP_PROVIDER_EXISTS &&
+ global_system_variables.binlog_format != BINLOG_FORMAT_ROW)
+ {
+
+ WSREP_ERROR ("Only binlog_format = 'ROW' is currently supported. "
+ "Configured value: '%s'. Please adjust your configuration.",
+ binlog_format_names[global_system_variables.binlog_format]);
+ return 1;
+ }
+
// Synchronize @@global.autocommit on --autocommit
const ulonglong turn_bit_on= opt_autocommit ?
OPTION_AUTOCOMMIT : OPTION_NOT_AUTOCOMMIT;
diff --git a/sql/rpl_mi.cc b/sql/rpl_mi.cc
index e97b5ecc8fe..8ce67bbf4b8 100644
--- a/sql/rpl_mi.cc
+++ b/sql/rpl_mi.cc
@@ -92,6 +92,13 @@ Master_info::Master_info(LEX_STRING *connection_name_arg,
Master_info::~Master_info()
{
+#ifdef WITH_WSREP
+ /*
+ Do not free "wsrep" rpl_filter. It will eventually be freed by
+ free_all_rpl_filters() when server terminates.
+ */
+ if (strncmp(connection_name.str, STRING_WITH_LEN("wsrep")))
+#endif
rpl_filters.delete_element(connection_name.str, connection_name.length,
(void (*)(const char*, uchar*)) free_rpl_filter);
my_free(connection_name.str);
diff --git a/sql/sql_alter.cc b/sql/sql_alter.cc
index cfe360217c2..e413361191d 100644
--- a/sql/sql_alter.cc
+++ b/sql/sql_alter.cc
@@ -307,16 +307,12 @@ bool Sql_cmd_alter_table::execute(THD *thd)
#ifdef WITH_WSREP
TABLE *find_temporary_table(THD *thd, const TABLE_LIST *tl);
- if (WSREP(thd) &&
- (!thd->is_current_stmt_binlog_format_row() ||
- !find_temporary_table(thd, first_table)) &&
- wsrep_to_isolation_begin(thd,
- lex->name.str ? select_lex->db : NULL,
- lex->name.str ? lex->name.str : NULL,
- first_table))
+ if ((!thd->is_current_stmt_binlog_format_row() ||
+ !find_temporary_table(thd, first_table)))
{
- WSREP_WARN("ALTER TABLE isolation failure");
- DBUG_RETURN(TRUE);
+ WSREP_TO_ISOLATION_BEGIN(((lex->name.str) ? select_lex->db : NULL),
+ ((lex->name.str) ? lex->name.str : NULL),
+ first_table);
}
#endif /* WITH_WSREP */
@@ -329,6 +325,12 @@ bool Sql_cmd_alter_table::execute(THD *thd)
lex->ignore);
DBUG_RETURN(result);
+
+#ifdef WITH_WSREP
+error:
+ WSREP_WARN("ALTER TABLE isolation failure");
+ DBUG_RETURN(TRUE);
+#endif /* WITH_WSREP */
}
bool Sql_cmd_discard_import_tablespace::execute(THD *thd)
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 4a66542b71f..9c457557bcb 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -6451,6 +6451,14 @@ int THD::binlog_query(THD::enum_binlog_query_type qtype, char const *query_arg,
The MYSQL_LOG::write() function will set the STMT_END_F flag and
flush the pending rows event if necessary.
*/
+ /*
+ Even though wsrep only supports ROW binary log format, a user can set
+ binlog format to STATEMENT (wsrep_forced_binlog_format). In which case
+ the control might reach here even when binary logging (--log-bin) is
+ not enabled. This is possible because wsrep patch partially enables
+ binary logging by setting wsrep_emulate_binlog.
+ */
+ if (mysql_bin_log.is_open())
{
Query_log_event qinfo(this, query_arg, query_len, is_trans, direct,
suppress_use, errcode);
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 4f88f8d5c96..64e016f8311 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -2820,8 +2820,6 @@ mysql_execute_command(THD *thd)
#endif
case SQLCOM_SHOW_STATUS:
{
- if (WSREP_CLIENT(thd) && wsrep_sync_wait(thd))
- goto error;
execute_show_status(thd, all_tables);
break;
}
@@ -6965,7 +6963,7 @@ static void wsrep_mysql_parse(THD *thd, char *rawbuf, uint length,
WSREP_DEBUG("abort in exec query state, avoiding autocommit");
}
- if (thd->wsrep_conflict_state== MUST_REPLAY)
+ if (thd->wsrep_conflict_state == MUST_REPLAY)
{
wsrep_replay_transaction(thd);
}
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc
index cf92b016a9f..7b157f98431 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -3657,7 +3657,7 @@ reexecute:
break;
case MUST_REPLAY:
- (void)wsrep_replay_transaction(thd);
+ (void) wsrep_replay_transaction(thd);
break;
default:
diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc
index cf2eabb5691..315dc01952b 100644
--- a/sql/sys_vars.cc
+++ b/sql/sys_vars.cc
@@ -437,6 +437,24 @@ static bool binlog_format_check(sys_var *self, THD *thd, set_var *var)
if (check_has_super(self, thd, var))
return true;
+ /*
+ MariaDB Galera does not support STATEMENT or MIXED binlog format currently.
+ */
+ if (WSREP(thd) && var->save_result.ulonglong_value != BINLOG_FORMAT_ROW)
+ {
+ // Push a warning to the error log.
+ push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, ER_UNKNOWN_ERROR,
+ "MariaDB Galera does not support binlog format: %s",
+ binlog_format_names[var->save_result.ulonglong_value]);
+
+ if (var->type == OPT_GLOBAL)
+ {
+ WSREP_ERROR("MariaDB Galera does not support binlog format: %s",
+ binlog_format_names[var->save_result.ulonglong_value]);
+ return true;
+ }
+ }
+
if (var->type == OPT_GLOBAL)
return false;
@@ -465,26 +483,6 @@ static bool binlog_format_check(sys_var *self, THD *thd, set_var *var)
ER_INSIDE_TRANSACTION_PREVENTS_SWITCH_BINLOG_FORMAT))
return true;
-#ifdef WITH_WSREP
- /* MariaDB Galera does not support STATEMENT or MIXED binlog
- format currently */
- if (WSREP(thd) &&
- (var->save_result.ulonglong_value == BINLOG_FORMAT_STMT ||
- var->save_result.ulonglong_value == BINLOG_FORMAT_MIXED))
- {
- WSREP_DEBUG("MariaDB Galera does not support binlog format : %s",
- var->save_result.ulonglong_value == BINLOG_FORMAT_STMT ?
- "STATEMENT" : "MIXED");
- /* Push also warning, because error message is general */
- push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
- ER_UNKNOWN_ERROR,
- "MariaDB Galera does not support binlog format: %s",
- var->save_result.ulonglong_value == BINLOG_FORMAT_STMT ?
- "STATEMENT" : "MIXED");
- return true;
- }
-#endif
-
return false;
}
@@ -4587,7 +4585,7 @@ static Sys_var_charptr Sys_wsrep_provider_options(
static Sys_var_charptr Sys_wsrep_data_home_dir(
"wsrep_data_home_dir", "home directory for wsrep provider",
READ_ONLY GLOBAL_VAR(wsrep_data_home_dir), CMD_LINE(REQUIRED_ARG),
- IN_FS_CHARSET, DEFAULT(""));
+ IN_FS_CHARSET, DEFAULT(mysql_real_data_home));
static Sys_var_charptr Sys_wsrep_cluster_name(
"wsrep_cluster_name", "Name for the cluster",
diff --git a/sql/wsrep_applier.cc b/sql/wsrep_applier.cc
index 23687e98c32..03d356aa046 100644
--- a/sql/wsrep_applier.cc
+++ b/sql/wsrep_applier.cc
@@ -95,7 +95,8 @@ static wsrep_cb_status_t wsrep_apply_events(THD* thd,
DBUG_ENTER("wsrep_apply_events");
- if (thd->killed == KILL_CONNECTION)
+ if (thd->killed == KILL_CONNECTION &&
+ thd->wsrep_conflict_state != REPLAYING)
{
WSREP_INFO("applier has been aborted, skipping apply_rbr: %lld",
(long long) wsrep_thd_trx_seqno(thd));
diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc
index 599b9be69c4..19736cef7bf 100644
--- a/sql/wsrep_mysqld.cc
+++ b/sql/wsrep_mysqld.cc
@@ -333,7 +333,13 @@ wsrep_view_handler_cb (void* app_ctx,
wsrep_cluster_size, wsrep_local_index, view->proto_ver);
/* Proceed further only if view is PRIMARY */
- if (WSREP_VIEW_PRIMARY != view->status) {
+ if (WSREP_VIEW_PRIMARY != view->status)
+ {
+#ifdef HAVE_QUERY_CACHE
+ // query cache must be initialised by now
+ query_cache.flush();
+#endif /* HAVE_QUERY_CACHE */
+
wsrep_ready_set(FALSE);
memb_status= WSREP_MEMBER_UNDEFINED;
/* Always record local_uuid and local_seqno in non-prim since this
@@ -380,9 +386,16 @@ wsrep_view_handler_cb (void* app_ctx,
wsrep_ready_set(FALSE);
/* Close client connections to ensure that they don't interfere
- * with SST */
- WSREP_DEBUG("[debug]: closing client connections for PRIM");
- wsrep_close_client_connections(TRUE);
+ * with SST. Necessary only if storage engines are initialized
+ * before SST.
+ * TODO: Just killing all ongoing transactions should be enough
+ * since wsrep_ready is OFF and no new transactions can start.
+ */
+ if (!wsrep_before_SE())
+ {
+ WSREP_DEBUG("[debug]: closing client connections for PRIM");
+ wsrep_close_client_connections(TRUE);
+ }
ssize_t const req_len= wsrep_sst_prepare (sst_req);
@@ -662,9 +675,6 @@ int wsrep_init()
wsrep->provider_vendor, sizeof(provider_vendor) - 1);
}
- if (!wsrep_data_home_dir || strlen(wsrep_data_home_dir) == 0)
- wsrep_data_home_dir = mysql_real_data_home;
-
char node_addr[512]= { 0, };
size_t const node_addr_max= sizeof(node_addr) - 1;
if (!wsrep_node_address || !strcmp(wsrep_node_address, ""))
@@ -1686,7 +1696,6 @@ wsrep_grant_mdl_exception(MDL_context *requestor_ctx,
pthread_handler_t start_wsrep_THD(void *arg)
{
THD *thd;
- rpl_sql_thread_info sql_info(NULL);
wsrep_thd_processor_fun processor= (wsrep_thd_processor_fun)arg;
if (my_thread_init())
@@ -1717,7 +1726,6 @@ pthread_handler_t start_wsrep_THD(void *arg)
thd->bootstrap=1;
thd->max_client_packet_length= thd->net.max_packet;
thd->security_ctx->master_access= ~(ulong)0;
- thd->system_thread_info.rpl_sql_info= &sql_info;
/* from handle_one_connection... */
pthread_detach_this_thread();
diff --git a/sql/wsrep_mysqld.h b/sql/wsrep_mysqld.h
index a6430560e3e..085dc5de453 100644
--- a/sql/wsrep_mysqld.h
+++ b/sql/wsrep_mysqld.h
@@ -162,7 +162,7 @@ extern wsrep_seqno_t wsrep_locked_seqno;
(global_system_variables.wsrep_on)
#define WSREP(thd) \
- (WSREP_ON && (thd && thd->variables.wsrep_on))
+ (WSREP_ON && wsrep && (thd && thd->variables.wsrep_on))
#define WSREP_CLIENT(thd) \
(WSREP(thd) && thd->wsrep_client_thread)
@@ -315,6 +315,7 @@ int wsrep_create_trigger_query(THD *thd, uchar** buf, size_t* buf_len);
#define WSREP_EMULATE_BINLOG(thd) (0)
#define WSREP_CLIENT(thd) (0)
#define WSREP_FORMAT(my_format) ((ulong)my_format)
+#define WSREP_PROVIDER_EXISTS (0)
#define wsrep_emulate_bin_log (0)
#define wsrep_xid_seqno(X) (0)
#define wsrep_to_isolation (0)
diff --git a/sql/wsrep_thd.cc b/sql/wsrep_thd.cc
index 2b4980ae05f..7ef31171846 100644
--- a/sql/wsrep_thd.cc
+++ b/sql/wsrep_thd.cc
@@ -89,32 +89,6 @@ void wsrep_client_rollback(THD *thd)
#define NUMBER_OF_FIELDS_TO_IDENTIFY_COORDINATOR 1
#define NUMBER_OF_FIELDS_TO_IDENTIFY_WORKER 2
-//#include "rpl_info_factory.h"
-
-#ifdef NOT_USED
-static Relay_log_info* wsrep_relay_log_init(const char* log_fname)
-{
-
- /* MySQL 5.6 version has rli factory: */
-#ifdef MYSQL_56
- uint rli_option = INFO_REPOSITORY_DUMMY;
- Relay_log_info *rli= NULL;
- rli = Rpl_info_factory::create_rli(rli_option, false);
- rli->set_rli_description_event(
- new Format_description_log_event(BINLOG_VERSION));
-#endif
- Relay_log_info* rli= new Relay_log_info(false);
- rli->sql_driver_thd= current_thd;
-
- rli->no_storage= true;
- rli->relay_log.description_event_for_exec=
- new Format_description_log_event(4);
-
- return rli;
-}
-#endif
-
-class Master_info;
static rpl_group_info* wsrep_relay_group_init(const char* log_fname)
{
@@ -126,13 +100,27 @@ static rpl_group_info* wsrep_relay_group_init(const char* log_fname)
rli->relay_log.description_event_for_exec=
new Format_description_log_event(4);
}
- static LEX_STRING dbname= { C_STRING_WITH_LEN("mysql") };
- rli->mi = new Master_info( &dbname, false);
- //rli->mi = new Master_info( &(C_STRING_WITH_LEN("wsrep")), false);
+ static LEX_STRING connection_name= { C_STRING_WITH_LEN("wsrep") };
+
+ /*
+ Master_info's constructor initializes rpl_filter by either an already
+ constructed Rpl_filter object from global 'rpl_filters' list if the
+ specified connection name is same, or it constructs a new Rpl_filter
+ object and adds it to rpl_filters. This object is later destructed by
+ Mater_info's destructor by looking it up based on connection name in
+ rpl_filters list.
+
+ However, since all Master_info objects created here would share same
+ connection name ("wsrep"), destruction of any of the existing Master_info
+ objects (in wsrep_return_from_bf_mode()) would free rpl_filter referenced
+ by any/all existing Master_info objects.
- rli->mi->rpl_filter = new Rpl_filter;
- copy_filter_setting(rli->mi->rpl_filter, get_or_create_rpl_filter("", 0));
+ In order to avoid that, we have added a check in Master_info's destructor
+ to not free the "wsrep" rpl_filter. It will eventually be freed by
+ free_all_rpl_filters() when server terminates.
+ */
+ rli->mi = new Master_info(&connection_name, false);
rli->sql_driver_thd= current_thd;
@@ -154,9 +142,11 @@ static void wsrep_prepare_bf_thd(THD *thd, struct wsrep_thd_shadow* shadow)
else
thd->variables.option_bits&= ~(OPTION_BIN_LOG);
- //if (!thd->wsrep_rli) thd->wsrep_rli= wsrep_relay_log_init("wsrep_relay");
if (!thd->wsrep_rgi) thd->wsrep_rgi= wsrep_relay_group_init("wsrep_relay");
- // thd->wsrep_rli->info_thd = thd;
+
+ /* thd->system_thread_info.rpl_sql_info isn't initialized. */
+ thd->system_thread_info.rpl_sql_info=
+ new rpl_sql_thread_info(thd->wsrep_rgi->rli->mi->rpl_filter);
thd->wsrep_exec_mode= REPL_RECV;
thd->net.vio= 0;
@@ -180,12 +170,11 @@ static void wsrep_return_from_bf_mode(THD *thd, struct wsrep_thd_shadow* shadow)
thd->variables.tx_isolation = shadow->tx_isolation;
thd->reset_db(shadow->db, shadow->db_length);
- delete thd->wsrep_rgi->rli->mi->rpl_filter;
+ delete thd->system_thread_info.rpl_sql_info;
delete thd->wsrep_rgi->rli->mi;
delete thd->wsrep_rgi->rli;
delete thd->wsrep_rgi;
thd->wsrep_rgi = NULL;
-;
}
void wsrep_replay_transaction(THD *thd)
@@ -283,6 +272,10 @@ void wsrep_replay_transaction(THD *thd)
WSREP_ERROR("trx_replay failed for: %d, query: %s",
rcode, thd->query() ? thd->query() : "void");
/* we're now in inconsistent state, must abort */
+
+ /* http://bazaar.launchpad.net/~codership/codership-mysql/5.6/revision/3962#sql/wsrep_thd.cc */
+ mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
+
unireg_abort(1);
break;
}
diff --git a/sql/wsrep_utils.cc b/sql/wsrep_utils.cc
index c4a992c751a..2c3fc0d77fd 100644
--- a/sql/wsrep_utils.cc
+++ b/sql/wsrep_utils.cc
@@ -325,10 +325,6 @@ thd::~thd ()
/* Returns INADDR_NONE, INADDR_ANY, INADDR_LOOPBACK or something else */
unsigned int wsrep_check_ip (const char* const addr)
{
-#if 0
- if (addr && 0 == strcasecmp(addr, MY_BIND_ALL_ADDRESSES)) return INADDR_ANY;
-#endif
-
unsigned int ret = INADDR_NONE;
struct addrinfo *res, hints;
@@ -380,11 +376,12 @@ size_t wsrep_guess_ip (char* buf, size_t buf_len)
unsigned int const ip_type= wsrep_check_ip(my_bind_addr_str);
if (INADDR_NONE == ip_type) {
- WSREP_ERROR("Networking not configured, cannot receive state transfer.");
+ WSREP_ERROR("Networking not configured, cannot receive state "
+ "transfer.");
return 0;
}
- if (INADDR_ANY != ip_type) {;
+ if (INADDR_ANY != ip_type) {
strncpy (buf, my_bind_addr_str, buf_len);
return strlen(buf);
}
diff --git a/sql/wsrep_var.cc b/sql/wsrep_var.cc
index 1c0e51e50ad..ca921b7ef18 100644
--- a/sql/wsrep_var.cc
+++ b/sql/wsrep_var.cc
@@ -66,6 +66,7 @@ bool wsrep_causal_reads_update (SV *sv)
} else {
sv->wsrep_sync_wait &= ~WSREP_SYNC_WAIT_BEFORE_READ;
}
+
return false;
}