diff options
Diffstat (limited to 'sql')
-rw-r--r-- | sql/event_parse_data.cc | 3 | ||||
-rw-r--r-- | sql/events.cc | 17 | ||||
-rw-r--r-- | sql/handler.cc | 73 | ||||
-rw-r--r-- | sql/log.cc | 3 | ||||
-rw-r--r-- | sql/slave.cc | 5 | ||||
-rw-r--r-- | sql/sql_acl.cc | 57 | ||||
-rw-r--r-- | sql/sql_base.cc | 53 | ||||
-rw-r--r-- | sql/sql_parse.cc | 18 | ||||
-rw-r--r-- | sql/tztime.cc | 10 | ||||
-rw-r--r-- | sql/wsrep_hton.cc | 5 | ||||
-rw-r--r-- | sql/wsrep_mysqld.cc | 6 | ||||
-rw-r--r-- | sql/wsrep_mysqld.h | 1 | ||||
-rw-r--r-- | sql/wsrep_thd.h | 5 |
13 files changed, 111 insertions, 145 deletions
diff --git a/sql/event_parse_data.cc b/sql/event_parse_data.cc index 7647419aff9..44d89887c3b 100644 --- a/sql/event_parse_data.cc +++ b/sql/event_parse_data.cc @@ -564,7 +564,8 @@ Event_parse_data::init_definer(THD *thd) void Event_parse_data::check_originator_id(THD *thd) { /* Disable replicated events on slave. */ - if ((thd->system_thread == SYSTEM_THREAD_SLAVE_SQL) || + if (IF_WSREP(WSREP(thd) && thd->wsrep_applier, 0) || + (thd->system_thread == SYSTEM_THREAD_SLAVE_SQL) || (thd->system_thread == SYSTEM_THREAD_SLAVE_IO)) { DBUG_PRINT("info", ("Invoked object status set to SLAVESIDE_DISABLED.")); diff --git a/sql/events.cc b/sql/events.cc index d42a5d7b0a0..7c6b29b7604 100644 --- a/sql/events.cc +++ b/sql/events.cc @@ -1130,23 +1130,6 @@ Events::load_events_from_db(THD *thd) delete et; goto end; } -#ifdef WITH_WSREP - /* - When SST from master node who initials event, the event status is ENABLED - this is problematic because there are two nodes with same events and - both enabled. - */ - if (WSREP(thd) && et->originator != thd->variables.server_id) - { - store_record(table, record[1]); - table->field[ET_FIELD_STATUS]-> - store((longlong) Event_parse_data::SLAVESIDE_DISABLED, - TRUE); - (void) table->file->ha_update_row(table->record[1], table->record[0]); - delete et; - continue; - } -#endif /** Since the Event_queue_element object could be deleted inside Event_queue::create_event we should save the value of dropped flag diff --git a/sql/handler.cc b/sql/handler.cc index 68762061053..42f5f7ac442 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -1144,6 +1144,25 @@ void trans_register_ha(THD *thd, bool all, handlerton *ht_arg) DBUG_VOID_RETURN; } + +static int prepare_or_error(handlerton *ht, THD *thd, bool all) +{ + int err= ht->prepare(ht, thd, all); + status_var_increment(thd->status_var.ha_prepare_count); + if (err) + { + /* avoid sending error, if we're going to replay the transaction */ +#ifdef WITH_WSREP + if (ht == wsrep_hton && + err != WSREP_TRX_SIZE_EXCEEDED && + thd->wsrep_conflict_state != MUST_REPLAY) +#endif + my_error(ER_ERROR_DURING_COMMIT, MYF(0), err); + } + return err; +} + + /** @retval 0 ok @@ -1161,32 +1180,14 @@ int ha_prepare(THD *thd) { for (; ha_info; ha_info= ha_info->next()) { - int err; handlerton *ht= ha_info->ht(); - status_var_increment(thd->status_var.ha_prepare_count); if (ht->prepare) { - if ((err= ht->prepare(ht, thd, all))) + if (prepare_or_error(ht, thd, all)) { -#ifdef WITH_WSREP - if (ht == wsrep_hton) - { - error= 1; - /* avoid sending error, if we need to replay */ - if (thd->wsrep_conflict_state!= MUST_REPLAY) - { - my_error(ER_LOCK_DEADLOCK, MYF(0), err); - } - } - else -#endif - { - /* not wsrep hton, bail to native mysql behavior */ - my_error(ER_ERROR_DURING_COMMIT, MYF(0), err); - ha_rollback_trans(thd, all); - error=1; - break; - } + ha_rollback_trans(thd, all); + error=1; + break; } } else @@ -1417,7 +1418,6 @@ int ha_commit_trans(THD *thd, bool all) for (Ha_trx_info *hi= ha_info; hi; hi= hi->next()) { - int err; handlerton *ht= hi->ht(); /* Do not call two-phase commit if this particular @@ -1430,32 +1430,9 @@ int ha_commit_trans(THD *thd, bool all) Sic: we know that prepare() is not NULL since otherwise trans->no_2pc would have been set. */ - err= ht->prepare(ht, thd, all); - status_var_increment(thd->status_var.ha_prepare_count); - if (err) - { -#ifdef WITH_WSREP - if (ht == wsrep_hton) - { - switch (err) { - case WSREP_TRX_SIZE_EXCEEDED: - /* give user size exeeded error from wsrep_api.h */ - my_error(ER_ERROR_DURING_COMMIT, MYF(0), WSREP_SIZE_EXCEEDED); - break; - case WSREP_TRX_CERT_FAIL: - case WSREP_TRX_ERROR: - /* avoid sending error, if we need to replay */ - if (thd->wsrep_conflict_state!= MUST_REPLAY) - { - my_error(ER_LOCK_DEADLOCK, MYF(0), err); - } - } - goto err; - } -#endif /* WITH_WSREP */ - my_error(ER_ERROR_DURING_COMMIT, MYF(0), err); + if (prepare_or_error(ht, thd, all)) goto err; - } + need_prepare_ordered|= (ht->prepare_ordered != NULL); need_commit_ordered|= (ht->commit_ordered != NULL); } diff --git a/sql/log.cc b/sql/log.cc index a9ba0c4eb32..e0fd74b5e38 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -2230,8 +2230,7 @@ static int binlog_savepoint_rollback(handlerton *hton, THD *thd, void *sv) DBUG_RETURN(mysql_bin_log.write(&qinfo)); } - if (!wsrep_emulate_bin_log) - binlog_trans_log_truncate(thd, *(my_off_t*)sv); + binlog_trans_log_truncate(thd, *(my_off_t*)sv); DBUG_RETURN(0); } diff --git a/sql/slave.cc b/sql/slave.cc index 110283ce4b4..3241f3fc117 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -4368,7 +4368,7 @@ pthread_handler_t handle_slave_sql(void *arg) my_off_t saved_skip= 0; Master_info *mi= ((Master_info*)arg); Relay_log_info* rli = &mi->rli; - my_bool wsrep_node_dropped= FALSE; + my_bool wsrep_node_dropped __attribute__((unused)) = FALSE; const char *errmsg; rpl_group_info *serial_rgi; rpl_sql_thread_info sql_info(mi->rpl_filter); @@ -4379,9 +4379,6 @@ pthread_handler_t handle_slave_sql(void *arg) wsrep_restart_point: - LINT_INIT(saved_master_log_pos); - LINT_INIT(saved_log_pos); - serial_rgi= new rpl_group_info(rli); thd = new THD; // note that contructor of THD uses DBUG_ ! thd->thread_stack = (char*)&thd; // remember where our stack is diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 8e976f0f579..b922eead8ea 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -2655,11 +2655,11 @@ bool change_password(THD *thd, const char *host, const char *user, TABLE_LIST tables[TABLES_MAX]; /* Buffer should be extended when password length is extended. */ char buff[512]; - ulong query_length=0; + ulong query_length= 0; enum_binlog_format save_binlog_format; uint new_password_len= (uint) strlen(new_password); int result=0; - const CSET_STRING query_save = thd->query_string; + const CSET_STRING query_save __attribute__((unused)) = thd->query_string; DBUG_ENTER("change_password"); DBUG_PRINT("enter",("host: '%s' user: '%s' new_password: '%s'", @@ -2669,16 +2669,18 @@ bool change_password(THD *thd, const char *host, const char *user, if (check_change_password(thd, host, user, new_password, new_password_len)) DBUG_RETURN(1); -#ifdef WITH_WSREP - if (WSREP(thd) && !thd->wsrep_applier) + if (mysql_bin_log.is_open() || + (WSREP(thd) && !IF_WSREP(thd->wsrep_applier, 0))) { query_length= sprintf(buff, "SET PASSWORD FOR '%-.120s'@'%-.120s'='%-.120s'", - safe_str(user), safe_str(host), new_password); - thd->set_query_inner(buff, query_length, system_charset_info); + safe_str(user), safe_str(host), new_password); + } + if (WSREP(thd) && !IF_WSREP(thd->wsrep_applier, 0)) + { + thd->set_query_inner(buff, query_length, system_charset_info); WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, (char*)"user", NULL); } -#endif /* WITH_WSREP */ if ((result= open_grant_tables(thd, tables, TL_WRITE, Table_user))) DBUG_RETURN(result != 1); @@ -2730,34 +2732,27 @@ bool change_password(THD *thd, const char *host, const char *user, result= 0; if (mysql_bin_log.is_open()) { - query_length= - sprintf(buff,"SET PASSWORD FOR '%-.120s'@'%-.120s'='%-.120s'", - safe_str(acl_user->user.str), - safe_str(acl_user->host.hostname), - new_password); + DBUG_ASSERT(query_length); thd->clear_error(); result= thd->binlog_query(THD::STMT_QUERY_TYPE, buff, query_length, FALSE, FALSE, FALSE, 0); } end: close_mysql_tables(thd); + #ifdef WITH_WSREP +error: // this label is used in WSREP_TO_ISOLATION_END if (WSREP(thd) && !thd->wsrep_applier) { WSREP_TO_ISOLATION_END; - thd->query_string = query_save; + thd->set_query_inner(query_save); thd->wsrep_exec_mode = LOCAL_STATE; } #endif /* WITH_WSREP */ thd->restore_stmt_binlog_format(save_binlog_format); DBUG_RETURN(result); - -error: - WSREP_ERROR("Repliation of SET PASSWORD failed: %s", buff); - DBUG_RETURN(result); - } int acl_check_set_default_role(THD *thd, const char *host, const char *user) @@ -2773,10 +2768,11 @@ int acl_set_default_role(THD *thd, const char *host, const char *user, char user_key[MAX_KEY_LENGTH]; int result= 1; int error; + ulong query_length= 0; bool clear_role= FALSE; char buff[512]; enum_binlog_format save_binlog_format; - const CSET_STRING query_save = thd->query_string; + const CSET_STRING query_save __attribute__((unused)) = thd->query_string; DBUG_ENTER("acl_set_default_role"); DBUG_PRINT("enter",("host: '%s' user: '%s' rolename: '%s'", @@ -2795,6 +2791,20 @@ int acl_set_default_role(THD *thd, const char *host, const char *user, if (!strcasecmp(rolename, "NONE")) clear_role= TRUE; + if (mysql_bin_log.is_open() || + (WSREP(thd) && !IF_WSREP(thd->wsrep_applier, 0))) + { + query_length= + sprintf(buff,"SET DEFAULT ROLE '%-.120s' FOR '%-.120s'@'%-.120s'", + safe_str(rolename), safe_str(user), safe_str(host)); + } + + if (WSREP(thd) && !IF_WSREP(thd->wsrep_applier, 0)) + { + thd->set_query_inner(buff, query_length, system_charset_info); + WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, (char*)"user", NULL); + } + if ((result= open_grant_tables(thd, tables, TL_WRITE, Table_user))) DBUG_RETURN(result != 1); @@ -2871,11 +2881,7 @@ int acl_set_default_role(THD *thd, const char *host, const char *user, result= 0; if (mysql_bin_log.is_open()) { - int query_length= - sprintf(buff,"SET DEFAULT ROLE '%-.120s' FOR '%-.120s'@'%-.120s'", - safe_str(acl_user->default_rolename.str), - safe_str(acl_user->user.str), - safe_str(acl_user->host.hostname)); + DBUG_ASSERT(query_length); thd->clear_error(); result= thd->binlog_query(THD::STMT_QUERY_TYPE, buff, query_length, FALSE, FALSE, FALSE, 0); @@ -2884,11 +2890,12 @@ end: close_mysql_tables(thd); #ifdef WITH_WSREP +error: // this label is used in WSREP_TO_ISOLATION_END if (WSREP(thd) && !thd->wsrep_applier) { WSREP_TO_ISOLATION_END; - thd->query_string = query_save; + thd->set_query_inner(query_save); thd->wsrep_exec_mode = LOCAL_STATE; } #endif /* WITH_WSREP */ diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 25722a68022..4687a05893c 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -4417,7 +4417,7 @@ restart: flags)) { error= TRUE; - goto err; + goto error; } } else @@ -4427,7 +4427,7 @@ restart: ot_ctx.get_timeout(), flags)) { error= TRUE; - goto err; + goto error; } for (table= *start; table && table != thd->lex->first_not_own_table(); table= table->next_global) @@ -4485,16 +4485,16 @@ restart: it may change in future. */ if (ot_ctx.recover_from_failed_open()) - goto err; + goto error; /* Re-open temporary tables after close_tables_for_reopen(). */ if (open_temporary_tables(thd, *start)) - goto err; + goto error; error= FALSE; goto restart; } - goto err; + goto error; } DEBUG_SYNC(thd, "open_tables_after_open_and_process_table"); @@ -4542,11 +4542,11 @@ restart: close_tables_for_reopen(thd, start, ot_ctx.start_of_statement_svp()); if (ot_ctx.recover_from_failed_open()) - goto err; + goto error; /* Re-open temporary tables after close_tables_for_reopen(). */ if (open_temporary_tables(thd, *start)) - goto err; + goto error; error= FALSE; goto restart; @@ -4556,7 +4556,7 @@ restart: Something is wrong with the table or its contents, and an error has been emitted; we must abort. */ - goto err; + goto error; } } } @@ -4567,44 +4567,37 @@ restart: children, attach the children to their parents. At end of statement, the children are detached. Attaching and detaching are always done, even under LOCK TABLES. + + And start wsrep TOI if needed. */ for (tables= *start; tables; tables= tables->next_global) { TABLE *tbl= tables->table; + if (!tbl) + continue; + + if (WSREP_ON && sqlcom_can_generate_row_events(thd) && + wsrep_replicate_myisam && tables && tbl->file->ht == myisam_hton && + tables->lock_type >= TL_WRITE_ALLOW_WRITE) + { + WSREP_TO_ISOLATION_BEGIN(NULL, NULL, tables); + } + /* Schema tables may not have a TABLE object here. */ - if (tbl && tbl->file->ht->db_type == DB_TYPE_MRG_MYISAM) + if (tbl->file->ht->db_type == DB_TYPE_MRG_MYISAM) { /* MERGE tables need to access parent and child TABLE_LISTs. */ DBUG_ASSERT(tbl->pos_in_table_list == tables); if (tbl->file->extra(HA_EXTRA_ATTACH_CHILDREN)) { error= TRUE; - goto err; + goto error; } } } -#ifdef WITH_WSREP - if (WSREP_ON && - (thd->lex->sql_command== SQLCOM_INSERT || - thd->lex->sql_command== SQLCOM_INSERT_SELECT || - thd->lex->sql_command== SQLCOM_REPLACE || - thd->lex->sql_command== SQLCOM_REPLACE_SELECT || - thd->lex->sql_command== SQLCOM_UPDATE || - thd->lex->sql_command== SQLCOM_UPDATE_MULTI || - thd->lex->sql_command== SQLCOM_LOAD || - thd->lex->sql_command== SQLCOM_DELETE) && - wsrep_replicate_myisam && - (*start) && - (*start)->table && (*start)->table->file->ht->db_type == DB_TYPE_MYISAM) - { - WSREP_TO_ISOLATION_BEGIN(NULL, NULL, (*start)); - } - error: -#endif - -err: +error: THD_STAGE_INFO(thd, stage_after_opening_tables); thd_proc_info(thd, 0); diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 57ff2d61cb6..1642319535c 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -4764,14 +4764,12 @@ end_with_restore_list: thd->print_aborted_warning(3, "RELEASE"); } #ifdef WITH_WSREP - if (WSREP(thd)) + if (WSREP(thd) && (thd->wsrep_conflict_state != NO_CONFLICT && + thd->wsrep_conflict_state != REPLAYING)) { - if (thd->wsrep_conflict_state == NO_CONFLICT || - thd->wsrep_conflict_state == REPLAYING) - { - my_ok(thd); - } - } else + DBUG_ASSERT(thd->is_error()); // the error is already issued + } + else #endif /* WITH_WSREP */ my_ok(thd); break; @@ -4810,11 +4808,9 @@ end_with_restore_list: if (tx_release) thd->killed= KILL_CONNECTION; #ifdef WITH_WSREP - if (WSREP(thd)) + if (WSREP(thd) && thd->wsrep_conflict_state != NO_CONFLICT) { - if (thd->wsrep_conflict_state == NO_CONFLICT) { - my_ok(thd); - } + DBUG_ASSERT(thd->is_error()); // the error is already issued } else #endif /* WITH_WSREP */ diff --git a/sql/tztime.cc b/sql/tztime.cc index 577474cd78f..24e61588a06 100644 --- a/sql/tztime.cc +++ b/sql/tztime.cc @@ -2709,11 +2709,11 @@ main(int argc, char **argv) return 1; } -#ifdef WITH_WSREP // Replicate MyISAM DDL for this session, cf. lp:1161432 // timezone info unfixable in XtraDB Cluster - printf("SET GLOBAL wsrep_replicate_myisam= ON;\n"); -#endif /* WITH_WSREP */ + printf("set @prep=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on'), 'SET GLOBAL wsrep_replicate_myisam=?', 'do ?');\n" + "prepare set_wsrep_myisam from @prep;\n" + "set @toggle=1; execute set_wsrep_myisam using @toggle;\n"); if (argc == 1 && !opt_leap) { @@ -2762,10 +2762,8 @@ main(int argc, char **argv) free_root(&tz_storage, MYF(0)); } -#ifdef WITH_WSREP // Reset wsrep_replicate_myisam. lp:1161432 - printf("SET GLOBAL wsrep_replicate_myisam= OFF;\n"); -#endif /* WITH_WSREP */ + printf("set @toggle=0; execute set_wsrep_myisam using @toggle;\n"); free_defaults(default_argv); my_end(0); diff --git a/sql/wsrep_hton.cc b/sql/wsrep_hton.cc index 4fc9ce2bce2..b77cc54ee15 100644 --- a/sql/wsrep_hton.cc +++ b/sql/wsrep_hton.cc @@ -157,6 +157,11 @@ static int wsrep_prepare(handlerton *hton, THD *thd, bool all) !thd_test_options(thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) && (thd->variables.wsrep_on && !wsrep_trans_cache_is_empty(thd))) { + int res= wsrep_run_wsrep_commit(thd, hton, all); + if (res == WSREP_TRX_SIZE_EXCEEDED) + res= EMSGSIZE; + else + res= EDEADLK; // for a better error message DBUG_RETURN (wsrep_run_wsrep_commit(thd, hton, all)); } DBUG_RETURN(0); diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc index 938ec243f61..64b7d6c8721 100644 --- a/sql/wsrep_mysqld.cc +++ b/sql/wsrep_mysqld.cc @@ -37,6 +37,12 @@ #include <slave.h> wsrep_t *wsrep = NULL; +/* + wsrep_emulate_bin_log is a flag to tell that binlog has not been configured. + wsrep needs to get binlog events from transaction cache even when binlog is + not enabled, wsrep_emulate_bin_log opens needed code paths to make this + possible +*/ my_bool wsrep_emulate_bin_log = FALSE; // activating parts of binlog interface #ifdef GTID_SUPPORT /* Sidno in global_sid_map corresponding to group uuid */ diff --git a/sql/wsrep_mysqld.h b/sql/wsrep_mysqld.h index 236dfa8884f..ce22dc473fb 100644 --- a/sql/wsrep_mysqld.h +++ b/sql/wsrep_mysqld.h @@ -330,6 +330,7 @@ int wsrep_create_trigger_query(THD *thd, uchar** buf, size_t* buf_len); #define wsrep_deinit(X) do { } while(0) #define wsrep_recover() do { } while(0) #define wsrep_slave_threads (1) +#define wsrep_replicate_myisam (0) #endif /* WITH_WSREP */ #endif /* WSREP_MYSQLD_H */ diff --git a/sql/wsrep_thd.h b/sql/wsrep_thd.h index 9914e98dcdb..0d01d28f01b 100644 --- a/sql/wsrep_thd.h +++ b/sql/wsrep_thd.h @@ -31,6 +31,9 @@ void wsrep_create_rollbacker(); int wsrep_abort_thd(void *bf_thd_ptr, void *victim_thd_ptr, my_bool signal); +/* + PA = Parallel Applying (on the slave side) +*/ extern void wsrep_thd_set_PA_safe(void *thd_ptr, my_bool safe); extern my_bool wsrep_thd_is_BF(THD *thd, my_bool sync); extern my_bool wsrep_thd_is_wsrep(void *thd_ptr); @@ -44,7 +47,7 @@ extern "C" int wsrep_thd_in_locking_session(void *thd_ptr); #define wsrep_thd_is_BF(T, S) (0) #define wsrep_abort_thd(X,Y,Z) do { } while(0) -#define wsrep_create_appliers(T) (0) +#define wsrep_create_appliers(T) do { } while(0) #endif #endif /* WSREP_THD_H */ |