From 72fd15f7c31aa3e3705ae1b005a3247a985c5bb3 Mon Sep 17 00:00:00 2001 From: SachinSetiya Date: Thu, 1 Dec 2016 12:16:13 +0530 Subject: MDEV-11016 wsrep_node_is_ready() check is too strict Problem:- The condition that checks for node readiness is too strict as it does not allow SELECTs even if these selects do not access any tables. For example,if we run SELECT 1; OR SELECT @@max_allowed_packet; Solution:- We need not to report this error when all_tables(lex->query_tables) is NULL: --- sql/sql_parse.cc | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'sql') diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 48addaab143..eb4f7141918 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2388,11 +2388,15 @@ mysql_execute_command(THD *thd) /* Bail out if DB snapshot has not been installed. We however, allow SET and SHOW queries. + SHOW and SELECT queries (only if wsrep_dirty_reads is set or when it + does not access any table). */ if (thd->variables.wsrep_on && !thd->wsrep_applier && !wsrep_ready && lex->sql_command != SQLCOM_SET_OPTION && !(thd->variables.wsrep_dirty_reads && lex->sql_command == SQLCOM_SELECT) && + !(lex->sql_command == SQLCOM_SELECT && + !all_tables) && !wsrep_is_show_query(lex->sql_command)) { #if DIRTY_HACK -- cgit v1.2.1 From 95422c445db7db60fca688711d98955e59e009e2 Mon Sep 17 00:00:00 2001 From: Sachin Setiya Date: Wed, 14 Dec 2016 15:58:14 +0530 Subject: Revert " MDEV-11016 wsrep_node_is_ready() check is too strict" This reverts commit 72fd15f7c31aa3e3705ae1b005a3247a985c5bb3. # Conflicts: # mysql-test/suite/galera/r/galera_var_dirty_reads.result # mysql-test/suite/galera/t/galera_var_dirty_reads.test --- sql/sql_parse.cc | 4 ---- 1 file changed, 4 deletions(-) (limited to 'sql') diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index eb4f7141918..48addaab143 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2388,15 +2388,11 @@ mysql_execute_command(THD *thd) /* Bail out if DB snapshot has not been installed. We however, allow SET and SHOW queries. - SHOW and SELECT queries (only if wsrep_dirty_reads is set or when it - does not access any table). */ if (thd->variables.wsrep_on && !thd->wsrep_applier && !wsrep_ready && lex->sql_command != SQLCOM_SET_OPTION && !(thd->variables.wsrep_dirty_reads && lex->sql_command == SQLCOM_SELECT) && - !(lex->sql_command == SQLCOM_SELECT && - !all_tables) && !wsrep_is_show_query(lex->sql_command)) { #if DIRTY_HACK -- cgit v1.2.1 From 5ddd8149e44122feb0989b9944113d2b92d6f84a Mon Sep 17 00:00:00 2001 From: Sachin Setiya Date: Wed, 14 Dec 2016 17:14:42 +0530 Subject: MDEV-11479 Improved wsrep_dirty_reads Tasks:- Changes in wsrep_dirty_reads variable 1.) Global + Session scope (Current: session-only) 2.) Can be set using command line. 3.) Allow all commands that do not change data (besides SELECT) 4.) Allow prepared Statements that do not change data 5.) Works with wsrep_sync_wait enabled --- sql/sql_parse.cc | 9 ++++++--- sql/sys_vars.cc | 5 +++-- sql/wsrep_mysqld.cc | 4 ++++ sql/wsrep_mysqld.h | 1 + 4 files changed, 14 insertions(+), 5 deletions(-) (limited to 'sql') diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 48addaab143..ec6eb0e6f87 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2386,13 +2386,16 @@ mysql_execute_command(THD *thd) } /* - Bail out if DB snapshot has not been installed. We however, - allow SET and SHOW queries. + Bail out if DB snapshot has not been installed. SET and SHOW commands, + however, are always allowed. + + 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 && lex->sql_command != SQLCOM_SET_OPTION && !(thd->variables.wsrep_dirty_reads && - lex->sql_command == SQLCOM_SELECT) && + !is_update_query(lex->sql_command)) && !wsrep_is_show_query(lex->sql_command)) { #if DIRTY_HACK diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index bdcedfff5a3..e0de7960ec9 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -3966,8 +3966,9 @@ static Sys_var_mybool Sys_wsrep_restart_slave( GLOBAL_VAR(wsrep_restart_slave), CMD_LINE(OPT_ARG), DEFAULT(FALSE)); static Sys_var_mybool Sys_wsrep_dirty_reads( - "wsrep_dirty_reads", "Do not reject SELECT queries even when the node " - "is not ready.", SESSION_ONLY(wsrep_dirty_reads), NO_CMD_LINE, + "wsrep_dirty_reads", + "Allow reads even when the node is not in the primary component.", + SESSION_VAR(wsrep_dirty_reads), CMD_LINE(OPT_ARG), DEFAULT(FALSE), NO_MUTEX_GUARD, NOT_IN_BINLOG); #endif /* WITH_WSREP */ diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc index 48114fcba34..21c7e94096d 100644 --- a/sql/wsrep_mysqld.cc +++ b/sql/wsrep_mysqld.cc @@ -65,6 +65,8 @@ my_bool wsrep_restart_slave_activated = 0; // node has dropped, and slave // restart will be needed my_bool wsrep_slave_UK_checks = 0; // slave thread does UK checks my_bool wsrep_slave_FK_checks = 0; // slave thread does FK checks +// Allow reads even if the node is not in the primary component. +bool wsrep_dirty_reads = false; /* Set during the creation of first wsrep applier and rollback threads. @@ -894,6 +896,8 @@ bool wsrep_must_sync_wait (THD* thd, uint mask) { return (thd->variables.wsrep_sync_wait & mask) && thd->variables.wsrep_on && + !(thd->variables.wsrep_dirty_reads && + !is_update_query(thd->lex->sql_command)) && !thd->in_active_multi_stmt_transaction() && thd->wsrep_conflict_state != REPLAYING && thd->wsrep_sync_wait_gtid.seqno == WSREP_SEQNO_UNDEFINED; diff --git a/sql/wsrep_mysqld.h b/sql/wsrep_mysqld.h index 3fb5189937e..85d4cea241f 100644 --- a/sql/wsrep_mysqld.h +++ b/sql/wsrep_mysqld.h @@ -80,6 +80,7 @@ extern ulong wsrep_retry_autocommit; extern my_bool wsrep_auto_increment_control; extern my_bool wsrep_drupal_282555_workaround; extern my_bool wsrep_incremental_data_collection; +extern bool wsrep_dirty_reads; extern const char* wsrep_start_position; extern ulong wsrep_max_ws_size; extern ulong wsrep_max_ws_rows; -- cgit v1.2.1 From ea2695ccbc4ef80cb8b21a2ca4bf0eedb195adae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Wed, 5 Apr 2017 08:54:20 +0300 Subject: fix warning "ignoring return value" of fwrite. Merge pull request https://github.com/MariaDB/server/pull/343 contributed by Eric Herman. --- sql/wsrep_binlog.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'sql') diff --git a/sql/wsrep_binlog.cc b/sql/wsrep_binlog.cc index af4ec84db85..7feebc63cf4 100644 --- a/sql/wsrep_binlog.cc +++ b/sql/wsrep_binlog.cc @@ -308,9 +308,13 @@ void wsrep_dump_rbr_buf(THD *thd, const void* rbr_buf, size_t buf_len) } FILE *of= fopen(filename, "wb"); + if (of) { - fwrite (rbr_buf, buf_len, 1, of); + if (fwrite(rbr_buf, buf_len, 1, of) == 0) + WSREP_ERROR("Failed to write buffer of length %llu to '%s'", + (unsigned long long)buf_len, filename); + fclose(of); } else -- cgit v1.2.1 From 19b9fe07f5356b1d5965c16b322a0ca7d5fbdfe8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Wed, 5 Apr 2017 10:50:12 +0300 Subject: Fix compiler error on gcc 6.x and most of the compiler warnings. --- sql/sql_class.cc | 4 ++-- sql/wsrep_sst.cc | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'sql') diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 7905daa235d..fd2dec5a146 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -853,11 +853,11 @@ extern "C" wsrep_ws_handle_t* wsrep_thd_ws_handle(THD *thd) return &thd->wsrep_ws_handle; } -extern "C"void wsrep_thd_LOCK(THD *thd) +extern "C" void wsrep_thd_LOCK(THD *thd) { mysql_mutex_lock(&thd->LOCK_wsrep_thd); } -extern "C"void wsrep_thd_UNLOCK(THD *thd) +extern "C" void wsrep_thd_UNLOCK(THD *thd) { mysql_mutex_unlock(&thd->LOCK_wsrep_thd); } diff --git a/sql/wsrep_sst.cc b/sql/wsrep_sst.cc index 8008a977a84..a5fe8a1e2d8 100644 --- a/sql/wsrep_sst.cc +++ b/sql/wsrep_sst.cc @@ -748,7 +748,7 @@ static int sst_donate_mysqldump (const char* addr, "%s", host, port, mysqld_port, mysqld_unix_port, mysql_real_data_home, wsrep_defaults_file, uuid_str, - (long long)seqno, bypass ? " "WSREP_SST_OPT_BYPASS : ""); + (long long)seqno, bypass ? " " WSREP_SST_OPT_BYPASS : ""); if (ret < 0 || ret >= cmd_len) { @@ -1023,7 +1023,7 @@ static int sst_donate_other (const char* method, method, addr, mysqld_unix_port, mysql_real_data_home, wsrep_defaults_file, uuid, (long long) seqno, - bypass ? " "WSREP_SST_OPT_BYPASS : ""); + bypass ? " " WSREP_SST_OPT_BYPASS : ""); if (ret < 0 || ret >= cmd_len) { -- cgit v1.2.1 From b8afa783bcd32c9a0e5b26d780f4debf859f1b8f Mon Sep 17 00:00:00 2001 From: Sachin Setiya Date: Tue, 18 Apr 2017 11:50:43 +0530 Subject: MW-267 Fix Galera crash at startup when compiled with gcc 6 Signed-off-by: Sachin Setiya --- sql/wsrep_mysqld.cc | 2 +- sql/wsrep_mysqld.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'sql') diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc index 21c7e94096d..a0938bdfb43 100644 --- a/sql/wsrep_mysqld.cc +++ b/sql/wsrep_mysqld.cc @@ -83,7 +83,7 @@ my_bool wsrep_creating_startup_threads = 0; */ my_bool wsrep_inited = 0; // initialized ? -static const wsrep_uuid_t cluster_uuid = WSREP_UUID_UNDEFINED; +static wsrep_uuid_t cluster_uuid = WSREP_UUID_UNDEFINED; const wsrep_uuid_t* wsrep_cluster_uuid() { return &cluster_uuid; diff --git a/sql/wsrep_mysqld.h b/sql/wsrep_mysqld.h index 85d4cea241f..bd45399a948 100644 --- a/sql/wsrep_mysqld.h +++ b/sql/wsrep_mysqld.h @@ -314,7 +314,6 @@ int wsrep_create_trigger_query(THD *thd, uchar** buf, size_t* buf_len); int wsrep_create_event_query(THD *thd, uchar** buf, size_t* buf_len); int wsrep_alter_event_query(THD *thd, uchar** buf, size_t* buf_len); -const wsrep_uuid_t* wsrep_cluster_uuid(); struct xid_t; void wsrep_set_SE_checkpoint(xid_t*); void wsrep_get_SE_checkpoint(wsrep_uuid_t&, wsrep_seqno_t&); -- cgit v1.2.1 From 1d4cc423886201d9d373e17bb29d667ab8a5f503 Mon Sep 17 00:00:00 2001 From: Alexey Yurchenko Date: Fri, 12 Aug 2016 14:21:01 +0300 Subject: MW-267: followup to the original pull request, removed unnecessary cast. --- sql/wsrep_mysqld.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'sql') diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc index a0938bdfb43..53d53c2c404 100644 --- a/sql/wsrep_mysqld.cc +++ b/sql/wsrep_mysqld.cc @@ -249,8 +249,7 @@ wsrep_view_handler_cb (void* app_ctx, if (memcmp(&cluster_uuid, &view->state_id.uuid, sizeof(wsrep_uuid_t))) { - memcpy((wsrep_uuid_t*)&cluster_uuid, &view->state_id.uuid, - sizeof(cluster_uuid)); + memcpy(&cluster_uuid, &view->state_id.uuid, sizeof(cluster_uuid)); wsrep_uuid_print (&cluster_uuid, cluster_uuid_str, sizeof(cluster_uuid_str)); -- cgit v1.2.1 From 33aaee8ee997dc76a9148d96ebe0d40b2830ddd9 Mon Sep 17 00:00:00 2001 From: Daniele Sciascia Date: Wed, 18 May 2016 11:07:58 +0200 Subject: MW-175 Fix definitively lost memory in wsrep_get_params --- sql/wsrep_var.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'sql') diff --git a/sql/wsrep_var.cc b/sql/wsrep_var.cc index 66b33e7697c..6385fa926a2 100644 --- a/sql/wsrep_var.cc +++ b/sql/wsrep_var.cc @@ -185,9 +185,8 @@ static bool refresh_provider_options() char* opts= wsrep->options_get(wsrep); if (opts) { - if (wsrep_provider_options) my_free((void *)wsrep_provider_options); - wsrep_provider_options = (char*)my_memdup(opts, strlen(opts) + 1, - MYF(MY_WME)); + wsrep_provider_options_init(opts); + free(opts); } else { -- cgit v1.2.1 From a4bc8db216b4dd61ca0b1cb5a8b7806437416dc7 Mon Sep 17 00:00:00 2001 From: sjaakola Date: Thu, 27 Apr 2017 19:51:18 +0300 Subject: MW-322 - CTAS fix merged to 5.5-v25 branch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jan Lindström --- sql/handler.cc | 5 +++++ sql/sql_base.cc | 13 ++++++++++++- sql/sql_insert.cc | 29 +++++++++++++++++++++++++++++ sql/wsrep_mysqld.cc | 24 +++++++----------------- sql/wsrep_mysqld.h | 11 +++++++++++ 5 files changed, 64 insertions(+), 18 deletions(-) (limited to 'sql') diff --git a/sql/handler.cc b/sql/handler.cc index 5917ba505a3..5cff15821c7 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -5426,6 +5426,11 @@ void ha_wsrep_fake_trx_id(THD *thd) DBUG_VOID_RETURN; } + if (thd->wsrep_ws_handle.trx_id != WSREP_UNDEFINED_TRX_ID) + { + WSREP_DEBUG("fake trx id skipped: %lu", thd->wsrep_ws_handle.trx_id); + DBUG_VOID_RETURN; + } handlerton *hton= installed_htons[DB_TYPE_INNODB]; if (hton && hton->wsrep_fake_trx_id) { diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 345c7acb508..3832a4ab471 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -9506,11 +9506,22 @@ void tdc_remove_table(THD *thd, enum_tdc_remove_table_type remove_type, I_P_List_iterator it(share->free_tables); #ifndef DBUG_OFF if (remove_type == TDC_RT_REMOVE_ALL) +#ifdef WITH_WSREP { - DBUG_ASSERT(share->used_tables.is_empty()); + /* following assert may cause false posivive fire for CTAS */ + if (thd->lex->sql_command != SQLCOM_CREATE_TABLE) + { +#endif /* WITH_WSREP */ + { + DBUG_ASSERT(share->used_tables.is_empty()); + } +#ifdef WITH_WSREP + } } else if (remove_type == TDC_RT_REMOVE_NOT_OWN || remove_type == TDC_RT_REMOVE_NOT_OWN_AND_MARK_NOT_USABLE) +#endif /* WITH_WSREP */ + { I_P_List_iterator it2(share->used_tables); while ((table= it2++)) diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 4f0129c6e70..e8f00b76d5a 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -4313,9 +4313,38 @@ bool select_create::send_eof() */ if (!table->s->tmp_table) { + #ifdef WITH_WSREP + /* + append table level exclusive key for CTAS + */ + wsrep_key_arr_t key_arr= {0, 0}; + wsrep_prepare_keys_for_isolation(thd, + create_table->db, + create_table->table_name, + table_list, + &key_arr); + int rcode = wsrep->append_key( + wsrep, + &thd->wsrep_ws_handle, + key_arr.keys, //&wkey, + key_arr.keys_len, + WSREP_KEY_EXCLUSIVE, + false); + wsrep_keys_free(&key_arr); + if (rcode) { + DBUG_PRINT("wsrep", ("row key failed: %d", rcode)); + WSREP_ERROR("Appending table key for CTAS failed: %s, %d", + (wsrep_thd_query(thd)) ? + wsrep_thd_query(thd) : "void", rcode); + return true; + } + /* If commit fails, we should be able to reset the OK status. */ + thd->stmt_da->can_overwrite_status= TRUE; +#endif /* WITH_WSREP */ trans_commit_stmt(thd); trans_commit_implicit(thd); #ifdef WITH_WSREP + thd->stmt_da->can_overwrite_status= FALSE; mysql_mutex_lock(&thd->LOCK_wsrep_thd); if (thd->wsrep_conflict_state != NO_CONFLICT) { diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc index 53d53c2c404..4ac346ca0a3 100644 --- a/sql/wsrep_mysqld.cc +++ b/sql/wsrep_mysqld.cc @@ -944,17 +944,7 @@ bool wsrep_sync_wait (THD* thd, uint mask) return false; } -/* - * Helpers to deal with TOI key arrays - */ -typedef struct wsrep_key_arr -{ - wsrep_key_t* keys; - size_t keys_len; -} wsrep_key_arr_t; - - -static void wsrep_keys_free(wsrep_key_arr_t* key_arr) +void wsrep_keys_free(wsrep_key_arr_t* key_arr) { for (size_t i= 0; i < key_arr->keys_len; ++i) { @@ -1019,11 +1009,11 @@ static bool wsrep_prepare_key_for_isolation(const char* db, } /* Prepare key list from db/table and table_list */ -static bool wsrep_prepare_keys_for_isolation(THD* thd, - const char* db, - const char* table, - const TABLE_LIST* table_list, - wsrep_key_arr_t* ka) +bool wsrep_prepare_keys_for_isolation(THD* thd, + const char* db, + const char* table, + const TABLE_LIST* table_list, + wsrep_key_arr_t* ka) { ka->keys= 0; ka->keys_len= 0; @@ -1554,7 +1544,7 @@ wsrep_grant_mdl_exception(MDL_context *requestor_ctx, } else if (request_thd->lex->sql_command == SQLCOM_DROP_TABLE) { - WSREP_DEBUG("DROP caused BF abort"); + WSREP_DEBUG("DROP caused BF abort, conf %d", granted_thd->wsrep_conflict_state); ticket->wsrep_report(wsrep_debug); mysql_mutex_unlock(&granted_thd->LOCK_wsrep_thd); wsrep_abort_thd((void*)request_thd, (void*)granted_thd, 1); diff --git a/sql/wsrep_mysqld.h b/sql/wsrep_mysqld.h index bd45399a948..23e9718e533 100644 --- a/sql/wsrep_mysqld.h +++ b/sql/wsrep_mysqld.h @@ -322,4 +322,15 @@ const wsrep_uuid_t* wsrep_xid_uuid(const xid_t*); wsrep_seqno_t wsrep_xid_seqno(const xid_t*); extern "C" int wsrep_is_wsrep_xid(const void* xid); +typedef struct wsrep_key_arr +{ + wsrep_key_t* keys; + size_t keys_len; +} wsrep_key_arr_t; +bool wsrep_prepare_keys_for_isolation(THD* thd, + const char* db, + const char* table, + const TABLE_LIST* table_list, + wsrep_key_arr_t* ka); +void wsrep_keys_free(wsrep_key_arr_t* key_arr); #endif /* WSREP_MYSQLD_H */ -- cgit v1.2.1 From 6326f0eac6f5a7b8132676af1b37bd7ec453009e Mon Sep 17 00:00:00 2001 From: sjaakola Date: Fri, 5 May 2017 11:09:01 +0300 Subject: MW-322 CTAS fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pushed fix for a typo Signed-off-by: Jan Lindström --- sql/sql_insert.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sql') diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index e8f00b76d5a..09e3d2c3c61 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -4313,7 +4313,7 @@ bool select_create::send_eof() */ if (!table->s->tmp_table) { - #ifdef WITH_WSREP +#ifdef WITH_WSREP /* append table level exclusive key for CTAS */ -- cgit v1.2.1 From a82611771b58fcfee024ce59c13adc2a928c5428 Mon Sep 17 00:00:00 2001 From: Daniele Sciascia Date: Wed, 8 Mar 2017 13:08:21 +0100 Subject: MW-86 Add separate wsrep_sync_wait bitmask value for SHOW commands MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, setting `wsrep_sync_wait = 1` would have an effect on both SELECT and SHOW statements. This patch changes wsrep_sync_wait so that bitmask value 1 is used for SELECT statements, while bitmask value 8 is reserved for SHOW statements. It is still possible to achieve sync wait on both SELECT and SHOW statements by setting `wsrep_sync_wait = 9`. Signed-off-by: Jan Lindström --- sql/sql_parse.cc | 70 ++++++++++++++++++------------------------------------ sql/sql_parse.h | 5 ++++ sql/wsrep_mysqld.h | 5 ++-- 3 files changed, 31 insertions(+), 49 deletions(-) (limited to 'sql') diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 745ea171030..3862de0c135 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2473,9 +2473,7 @@ mysql_execute_command(THD *thd) #endif case SQLCOM_SHOW_STATUS_PROC: case SQLCOM_SHOW_STATUS_FUNC: -#ifdef WITH_WSREP - if (WSREP_CLIENT(thd) && wsrep_sync_wait(thd)) goto error; -#endif /* WITH_WSREP */ + WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW); if ((res= check_table_access(thd, SELECT_ACL, all_tables, FALSE, UINT_MAX, FALSE))) goto error; @@ -2483,7 +2481,9 @@ mysql_execute_command(THD *thd) break; case SQLCOM_SHOW_STATUS: { + WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW); execute_show_status(thd, all_tables); + #ifdef WITH_WSREP if (lex->sql_command == SQLCOM_SHOW_STATUS) wsrep_free_status(thd); #endif /* WITH_WSREP */ @@ -2497,27 +2497,22 @@ mysql_execute_command(THD *thd) case SQLCOM_SHOW_PLUGINS: case SQLCOM_SHOW_FIELDS: case SQLCOM_SHOW_KEYS: -#ifndef WITH_WSREP case SQLCOM_SHOW_VARIABLES: case SQLCOM_SHOW_CHARSETS: case SQLCOM_SHOW_COLLATIONS: case SQLCOM_SHOW_STORAGE_ENGINES: case SQLCOM_SHOW_PROFILE: -#endif /* WITH_WSREP */ + WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW); case SQLCOM_SHOW_CLIENT_STATS: case SQLCOM_SHOW_USER_STATS: case SQLCOM_SHOW_TABLE_STATS: case SQLCOM_SHOW_INDEX_STATS: case SQLCOM_SELECT: + { #ifdef WITH_WSREP - if (WSREP_CLIENT(thd) && wsrep_sync_wait(thd)) goto error; - case SQLCOM_SHOW_VARIABLES: - case SQLCOM_SHOW_CHARSETS: - case SQLCOM_SHOW_COLLATIONS: - case SQLCOM_SHOW_STORAGE_ENGINES: - case SQLCOM_SHOW_PROFILE: + if (lex->sql_command == SQLCOM_SELECT) + WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_READ); #endif /* WITH_WSREP */ - { thd->status_var.last_query_cost= 0.0; /* @@ -3079,9 +3074,7 @@ end_with_restore_list: goto error; #else { -#ifdef WITH_WSREP - if (WSREP_CLIENT(thd) && wsrep_sync_wait(thd)) goto error; -#endif /* WITH_WSREP */ + WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW); /* Access check: @@ -3138,9 +3131,7 @@ end_with_restore_list: case SQLCOM_CHECKSUM: { DBUG_ASSERT(first_table == all_tables && first_table != 0); -#ifdef WITH_WSREP - if (WSREP_CLIENT(thd) && wsrep_sync_wait(thd)) goto error; -#endif /* WITH_WSREP */ + WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_READ); if (check_table_access(thd, SELECT_ACL, all_tables, FALSE, UINT_MAX, FALSE)) @@ -3150,11 +3141,8 @@ end_with_restore_list: break; } case SQLCOM_UPDATE: -#ifdef WITH_WSREP - if (WSREP_CLIENT(thd) && - wsrep_sync_wait(thd, WSREP_SYNC_WAIT_BEFORE_UPDATE_DELETE)) goto error; -#endif /* WITH_WSREP */ { + WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_UPDATE_DELETE); ha_rows found= 0, updated= 0; DBUG_ASSERT(first_table == all_tables && first_table != 0); if (update_precheck(thd, all_tables)) @@ -3193,10 +3181,7 @@ end_with_restore_list: /* if we switched from normal update, rights are checked */ if (up_result != 2) { -#ifdef WITH_WSREP - if (WSREP_CLIENT(thd) && - wsrep_sync_wait(thd, WSREP_SYNC_WAIT_BEFORE_UPDATE_DELETE)) goto error; -#endif /* WITH_WSREP */ + WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_UPDATE_DELETE); if ((res= multi_update_precheck(thd, all_tables))) break; } @@ -3266,10 +3251,7 @@ end_with_restore_list: break; } case SQLCOM_REPLACE: -#ifdef WITH_WSREP - if (WSREP_CLIENT(thd) && - wsrep_sync_wait(thd, WSREP_SYNC_WAIT_BEFORE_INSERT_REPLACE)) goto error; -#endif /* WITH_WSREP */ + WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_INSERT_REPLACE); #ifndef DBUG_OFF if (mysql_bin_log.is_open()) { @@ -3305,11 +3287,8 @@ end_with_restore_list: } #endif case SQLCOM_INSERT: -#ifdef WITH_WSREP - if (WSREP_CLIENT(thd) && - wsrep_sync_wait(thd, WSREP_SYNC_WAIT_BEFORE_INSERT_REPLACE)) goto error; -#endif /* WITH_WSREP */ { + WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_INSERT_REPLACE); DBUG_ASSERT(first_table == all_tables && first_table != 0); if ((res= insert_precheck(thd, all_tables))) break; @@ -3350,12 +3329,9 @@ end_with_restore_list: } case SQLCOM_REPLACE_SELECT: case SQLCOM_INSERT_SELECT: -#ifdef WITH_WSREP - if (WSREP_CLIENT(thd) && - wsrep_sync_wait(thd, WSREP_SYNC_WAIT_BEFORE_INSERT_REPLACE)) goto error; -#endif /* WITH_WSREP */ { - select_result *sel_result; + WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_INSERT_REPLACE); + select_insert *sel_result; DBUG_ASSERT(first_table == all_tables && first_table != 0); if ((res= insert_precheck(thd, all_tables))) break; @@ -3450,11 +3426,8 @@ end_with_restore_list: break; } case SQLCOM_DELETE: -#ifdef WITH_WSREP - if (WSREP_CLIENT(thd) && - wsrep_sync_wait(thd, WSREP_SYNC_WAIT_BEFORE_UPDATE_DELETE)) goto error; -#endif /* WITH_WSREP */ { + WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_UPDATE_DELETE); DBUG_ASSERT(first_table == all_tables && first_table != 0); if ((res= delete_precheck(thd, all_tables))) break; @@ -3469,11 +3442,8 @@ end_with_restore_list: break; } case SQLCOM_DELETE_MULTI: -#ifdef WITH_WSREP - if (WSREP_CLIENT(thd) && - wsrep_sync_wait(thd, WSREP_SYNC_WAIT_BEFORE_UPDATE_DELETE)) goto error; -#endif /* WITH_WSREP */ { + WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_UPDATE_DELETE); DBUG_ASSERT(first_table == all_tables && first_table != 0); TABLE_LIST *aux_tables= thd->lex->auxiliary_table_list.first; multi_delete *del_result; @@ -3840,6 +3810,7 @@ end_with_restore_list: my_error(ER_WRONG_DB_NAME, MYF(0), lex->name.str); break; } + WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW); res= mysqld_show_create_db(thd, lex->name.str, &lex->create_info); break; } @@ -3891,6 +3862,7 @@ end_with_restore_list: /* lex->unit.cleanup() is called outside, no need to call it here */ break; case SQLCOM_SHOW_CREATE_EVENT: + WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW); res= Events::show_create_event(thd, lex->spname->m_db, lex->spname->m_name); break; @@ -4751,12 +4723,14 @@ create_sp_error: } case SQLCOM_SHOW_CREATE_PROC: { + WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW); if (sp_show_create_routine(thd, TYPE_ENUM_PROCEDURE, lex->spname)) goto error; break; } case SQLCOM_SHOW_CREATE_FUNC: { + WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW); if (sp_show_create_routine(thd, TYPE_ENUM_FUNCTION, lex->spname)) goto error; break; @@ -4769,6 +4743,7 @@ create_sp_error: stored_procedure_type type= (lex->sql_command == SQLCOM_SHOW_PROC_CODE ? TYPE_ENUM_PROCEDURE : TYPE_ENUM_FUNCTION); + WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW); if (sp_cache_routine(thd, type, lex->spname, FALSE, &sp)) goto error; if (!sp || sp->show_routine_code(thd)) @@ -4790,6 +4765,7 @@ create_sp_error: if (check_ident_length(&lex->spname->m_name)) goto error; + WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW); if (show_create_trigger(thd, lex->spname)) goto error; /* Error has been already logged. */ diff --git a/sql/sql_parse.h b/sql/sql_parse.h index 58885594a5d..e176e4eadf8 100644 --- a/sql/sql_parse.h +++ b/sql/sql_parse.h @@ -218,10 +218,15 @@ inline bool is_supported_parser_charset(CHARSET_INFO *cs) if (WSREP(thd) || (thd && thd->wsrep_exec_mode==TOTAL_ORDER)) \ wsrep_to_isolation_end(thd); +#define WSREP_SYNC_WAIT(thd_, before_) \ + if (WSREP_CLIENT(thd_) && \ + wsrep_sync_wait(thd_, before_)) goto error; + #else #define WSREP_TO_ISOLATION_BEGIN(db_, table_, table_list_) #define WSREP_TO_ISOLATION_END +#define WSREP_SYNC_WAIT(thd_, before_) #endif /* WITH_WSREP */ diff --git a/sql/wsrep_mysqld.h b/sql/wsrep_mysqld.h index 23e9718e533..bb33d2f1069 100644 --- a/sql/wsrep_mysqld.h +++ b/sql/wsrep_mysqld.h @@ -105,11 +105,12 @@ extern my_bool wsrep_creating_startup_threads; enum enum_wsrep_OSU_method { WSREP_OSU_TOI, WSREP_OSU_RSU }; enum enum_wsrep_sync_wait { WSREP_SYNC_WAIT_NONE = 0x0, - // show, select, begin + // select, begin WSREP_SYNC_WAIT_BEFORE_READ = 0x1, WSREP_SYNC_WAIT_BEFORE_UPDATE_DELETE = 0x2, WSREP_SYNC_WAIT_BEFORE_INSERT_REPLACE = 0x4, - WSREP_SYNC_WAIT_MAX = 0x7 + WSREP_SYNC_WAIT_BEFORE_SHOW = 0x8, + WSREP_SYNC_WAIT_MAX = 0xF }; // MySQL status variables -- cgit v1.2.1 From 34853fa7937b8081516eddb0226e8031f06ba96f Mon Sep 17 00:00:00 2001 From: Daniele Sciascia Date: Mon, 13 Mar 2017 15:35:04 +0100 Subject: MW-86 Additional wsrep_sync_wait coverage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The following commands are now subject to wsrep_sync_wait with bitmask value 8: SHOW BINARY LOGS SHOW BINLOG EVENTS SHOW GRANTS Signed-off-by: Jan Lindström --- sql/sql_parse.cc | 10 +++++++--- sql/sql_parse.h | 4 ++-- 2 files changed, 9 insertions(+), 5 deletions(-) (limited to 'sql') diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 3862de0c135..c222adbbac2 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2502,7 +2502,6 @@ mysql_execute_command(THD *thd) case SQLCOM_SHOW_COLLATIONS: case SQLCOM_SHOW_STORAGE_ENGINES: case SQLCOM_SHOW_PROFILE: - WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW); case SQLCOM_SHOW_CLIENT_STATS: case SQLCOM_SHOW_USER_STATS: case SQLCOM_SHOW_TABLE_STATS: @@ -2510,8 +2509,10 @@ mysql_execute_command(THD *thd) case SQLCOM_SELECT: { #ifdef WITH_WSREP - if (lex->sql_command == SQLCOM_SELECT) - WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_READ); + if (lex->sql_command == SQLCOM_SELECT) + WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_READ) + else + WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW) #endif /* WITH_WSREP */ thd->status_var.last_query_cost= 0.0; @@ -2635,6 +2636,7 @@ case SQLCOM_PREPARE: case SQLCOM_SHOW_RELAYLOG_EVENTS: /* fall through */ case SQLCOM_SHOW_BINLOG_EVENTS: { + WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW); if (check_global_access(thd, REPL_SLAVE_ACL)) goto error; res = mysql_show_binlog_events(thd); @@ -3061,6 +3063,7 @@ end_with_restore_list: { if (check_global_access(thd, SUPER_ACL | REPL_CLIENT_ACL)) goto error; + WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW); res = show_binlogs(thd); break; } @@ -4163,6 +4166,7 @@ end_with_restore_list: !strcmp(thd->security_ctx->priv_user, grant_user->user.str)) || !check_access(thd, SELECT_ACL, "mysql", NULL, NULL, 1, 0)) { + WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW); res = mysql_show_grants(thd, grant_user); } break; diff --git a/sql/sql_parse.h b/sql/sql_parse.h index e176e4eadf8..2093ecc85ee 100644 --- a/sql/sql_parse.h +++ b/sql/sql_parse.h @@ -219,8 +219,8 @@ inline bool is_supported_parser_charset(CHARSET_INFO *cs) wsrep_to_isolation_end(thd); #define WSREP_SYNC_WAIT(thd_, before_) \ - if (WSREP_CLIENT(thd_) && \ - wsrep_sync_wait(thd_, before_)) goto error; + { if (WSREP_CLIENT(thd_) && \ + wsrep_sync_wait(thd_, before_)) goto error; } #else -- cgit v1.2.1 From be416cfa3b6ec6faad3e0ac273fc8698de61094d Mon Sep 17 00:00:00 2001 From: Daniele Sciascia Date: Mon, 13 Mar 2017 22:45:42 +0100 Subject: MW-86 Removed unnecessary wsrep_sync_wait before processing SQLCOM_REPLACE MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sync waiting before processing SQLCOM_REPLACE was not necessary given that this case falls through to processing of SQLCOM_INSERT. In case of SQLCOM_REPLACE, wsrep_sync_wait would be called twice. Signed-off-by: Jan Lindström --- sql/sql_parse.cc | 1 - 1 file changed, 1 deletion(-) (limited to 'sql') diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index c222adbbac2..52b18318849 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -3254,7 +3254,6 @@ end_with_restore_list: break; } case SQLCOM_REPLACE: - WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_INSERT_REPLACE); #ifndef DBUG_OFF if (mysql_bin_log.is_open()) { -- cgit v1.2.1 From 86d31ce9f141d34fffcf7f355d4c0e6e54077eb3 Mon Sep 17 00:00:00 2001 From: Alexey Yurchenko Date: Mon, 19 Jun 2017 17:23:02 +0700 Subject: MW-384 protect access to wsrep_ready variable with mutex --- sql/mysqld.cc | 2 +- sql/slave.cc | 2 +- sql/sql_parse.cc | 4 ++-- sql/wsrep_mysqld.cc | 36 +++++++++++++++++++++++------------- sql/wsrep_mysqld.h | 3 ++- sql/wsrep_priv.h | 2 +- sql/wsrep_sst.cc | 1 - 7 files changed, 30 insertions(+), 20 deletions(-) (limited to 'sql') 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 // SHOW_MY_BOOL #include #include #include @@ -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 #include -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; -- cgit v1.2.1 From 0332acc77cc7e22ed2f98537477d3e23fb3efa36 Mon Sep 17 00:00:00 2001 From: sjaakola Date: Fri, 4 Aug 2017 11:22:35 +0300 Subject: MW-394 Merged fix for LOAD DATA splitting with log_bin==OFF, from mysql-wsrep-bugs/MW-394 --- sql/sql_class.cc | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'sql') diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 43d7ffd94d6..d540abb276c 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -4297,14 +4297,16 @@ extern "C" int thd_non_transactional_update(const MYSQL_THD thd) extern "C" int thd_binlog_format(const MYSQL_THD thd) { #ifdef WITH_WSREP - if (((WSREP(thd) && wsrep_emulate_bin_log) || mysql_bin_log.is_open()) && - (thd->variables.option_bits & OPTION_BIN_LOG)) -#else + if (WSREP(thd)) + { + /* for wsrep binlog format is meaningful also when binlogging is off */ + return (int) WSREP_BINLOG_FORMAT(thd->variables.binlog_format); + } +#endif /* WITH_WSREP */ if (mysql_bin_log.is_open() && (thd->variables.option_bits & OPTION_BIN_LOG)) -#endif - return (int) WSREP_BINLOG_FORMAT(thd->variables.binlog_format); + return (int) thd->variables.binlog_format; else - return BINLOG_FORMAT_UNSPEC; + return BINLOG_FORMAT_UNSPEC; } extern "C" void thd_mark_transaction_to_rollback(MYSQL_THD thd, bool all) -- cgit v1.2.1 From 38530c86aa36e2cbd315447a5362bcc751fb9205 Mon Sep 17 00:00:00 2001 From: Daniele Sciascia Date: Thu, 5 Oct 2017 11:41:02 +0200 Subject: MW-415 THD::COND_wsrep_thd is never destroyed THD::COND_wsrep_thd is never destroyed. This patch adds missing call to mysql_cond_destroy(&COND_wsrep_thd) in THD::release_resources(). --- sql/sql_class.cc | 1 + 1 file changed, 1 insertion(+) (limited to 'sql') diff --git a/sql/sql_class.cc b/sql/sql_class.cc index d540abb276c..1398fdff94f 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -1693,6 +1693,7 @@ THD::~THD() mysql_mutex_lock(&LOCK_wsrep_thd); mysql_mutex_unlock(&LOCK_wsrep_thd); mysql_mutex_destroy(&LOCK_wsrep_thd); + mysql_cond_destroy(&COND_wsrep_thd); if (wsrep_rli) delete wsrep_rli; if (wsrep_status_vars) wsrep->stats_free(wsrep, wsrep_status_vars); #endif -- cgit v1.2.1 From 8822b30f1e258a5f0efc124043f42970e600c5d4 Mon Sep 17 00:00:00 2001 From: sjaakola Date: Tue, 10 Oct 2017 23:39:48 +0300 Subject: MW-416 Replicating DDL after ACL check, 5.6 version Re-implemented the fix for MW-416 according to 5.7 version --- sql/events.cc | 15 +++++++++++++++ sql/sql_class.h | 1 + sql/sql_parse.cc | 7 ------- sql/sql_plugin.cc | 19 +++++++++++++++---- sql/sql_trigger.cc | 5 +++++ sql/sql_view.cc | 5 +++++ 6 files changed, 41 insertions(+), 11 deletions(-) (limited to 'sql') diff --git a/sql/events.cc b/sql/events.cc index 7aa7dae4d7f..a6379ec5a46 100644 --- a/sql/events.cc +++ b/sql/events.cc @@ -327,6 +327,7 @@ Events::create_event(THD *thd, Event_parse_data *parse_data, if (check_access(thd, EVENT_ACL, parse_data->dbname.str, NULL, NULL, 0, 0)) DBUG_RETURN(TRUE); + WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL); if (check_db_dir_existence(parse_data->dbname.str)) { @@ -406,6 +407,10 @@ Events::create_event(THD *thd, Event_parse_data *parse_data, thd->set_current_stmt_binlog_format_row(); DBUG_RETURN(ret); +#ifdef WITH_WSREP + error: + DBUG_RETURN(TRUE); +#endif /* WITH_WSREP */ } @@ -446,6 +451,7 @@ Events::update_event(THD *thd, Event_parse_data *parse_data, if (check_access(thd, EVENT_ACL, parse_data->dbname.str, NULL, NULL, 0, 0)) DBUG_RETURN(TRUE); + WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL); if (new_dbname) /* It's a rename */ { @@ -521,6 +527,10 @@ Events::update_event(THD *thd, Event_parse_data *parse_data, thd->set_current_stmt_binlog_format_row(); DBUG_RETURN(ret); +#ifdef WITH_WSREP + error: + DBUG_RETURN(TRUE); +#endif /* WITH_WSREP */ } @@ -560,6 +570,7 @@ Events::drop_event(THD *thd, LEX_STRING dbname, LEX_STRING name, bool if_exists) if (check_access(thd, EVENT_ACL, dbname.str, NULL, NULL, 0, 0)) DBUG_RETURN(TRUE); + WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL); /* Turn off row binlogging of this statement and use statement-based so @@ -585,6 +596,10 @@ Events::drop_event(THD *thd, LEX_STRING dbname, LEX_STRING name, bool if_exists) if (save_binlog_row_based) thd->set_current_stmt_binlog_format_row(); DBUG_RETURN(ret); +#ifdef WITH_WSREP + error: + DBUG_RETURN(TRUE); +#endif /* WITH_WSREP */ } diff --git a/sql/sql_class.h b/sql/sql_class.h index 8cfb3ced4b6..70bf6f7783d 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -2383,6 +2383,7 @@ public: enum wsrep_query_state wsrep_query_state; enum wsrep_conflict_state wsrep_conflict_state; mysql_mutex_t LOCK_wsrep_thd; + mysql_cond_t COND_wsrep_thd; // changed from wsrep_seqno_t to wsrep_trx_meta_t in wsrep API rev 75 // wsrep_seqno_t wsrep_trx_seqno; wsrep_trx_meta_t wsrep_trx_meta; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index d102c6162d0..553a6e7539d 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -3825,7 +3825,6 @@ end_with_restore_list: if (res) break; - WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL) switch (lex->sql_command) { case SQLCOM_CREATE_EVENT: { @@ -3861,7 +3860,6 @@ end_with_restore_list: lex->spname->m_name); break; case SQLCOM_DROP_EVENT: - WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL) if (!(res= Events::drop_event(thd, lex->spname->m_db, lex->spname->m_name, lex->drop_if_exists))) @@ -4773,7 +4771,6 @@ create_sp_error: Note: SQLCOM_CREATE_VIEW also handles 'ALTER VIEW' commands as specified through the thd->lex->create_view_mode flag. */ - WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL) res= mysql_create_view(thd, first_table, thd->lex->create_view_mode); break; } @@ -4789,7 +4786,6 @@ create_sp_error: case SQLCOM_CREATE_TRIGGER: { /* Conditionally writes to binlog. */ - WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL) res= mysql_create_or_drop_trigger(thd, all_tables, 1); break; @@ -4797,7 +4793,6 @@ create_sp_error: case SQLCOM_DROP_TRIGGER: { /* Conditionally writes to binlog. */ - WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL) res= mysql_create_or_drop_trigger(thd, all_tables, 0); break; } @@ -4860,13 +4855,11 @@ create_sp_error: my_ok(thd); break; case SQLCOM_INSTALL_PLUGIN: - WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL) if (! (res= mysql_install_plugin(thd, &thd->lex->comment, &thd->lex->ident))) my_ok(thd); break; case SQLCOM_UNINSTALL_PLUGIN: - WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL) if (! (res= mysql_uninstall_plugin(thd, &thd->lex->comment, &thd->lex->ident))) my_ok(thd); diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index d4f497743b7..7e5c7c9c852 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -2079,6 +2079,8 @@ bool mysql_install_plugin(THD *thd, const LEX_STRING *name, bool error; int argc=orig_argc; char **argv=orig_argv; + unsigned long event_class_mask[MYSQL_AUDIT_CLASS_MASK_SIZE] = + { MYSQL_AUDIT_GENERAL_CLASSMASK }; DBUG_ENTER("mysql_install_plugin"); if (opt_noacl) @@ -2090,6 +2092,7 @@ bool mysql_install_plugin(THD *thd, const LEX_STRING *name, tables.init_one_table("mysql", 5, "plugin", 6, "plugin", TL_WRITE); if (check_table_access(thd, INSERT_ACL, &tables, FALSE, 1, FALSE)) DBUG_RETURN(TRUE); + WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL); /* need to open before acquiring LOCK_plugin or it will deadlock */ if (! (table = open_ltable(thd, &tables, TL_WRITE, @@ -2123,8 +2126,7 @@ bool mysql_install_plugin(THD *thd, const LEX_STRING *name, See also mysql_uninstall_plugin() and initialize_audit_plugin() */ - unsigned long event_class_mask[MYSQL_AUDIT_CLASS_MASK_SIZE] = - { MYSQL_AUDIT_GENERAL_CLASSMASK }; + mysql_audit_acquire_plugins(thd, event_class_mask); mysql_mutex_lock(&LOCK_plugin); @@ -2155,6 +2157,10 @@ err: if (argv) free_defaults(argv); DBUG_RETURN(error); +#ifdef WITH_WSREP + error: + DBUG_RETURN(TRUE); +#endif /* WITH_WSREP */ } @@ -2221,6 +2227,8 @@ bool mysql_uninstall_plugin(THD *thd, const LEX_STRING *name, TABLE_LIST tables; LEX_STRING dl= *dl_arg; bool error= false; + unsigned long event_class_mask[MYSQL_AUDIT_CLASS_MASK_SIZE] = + { MYSQL_AUDIT_GENERAL_CLASSMASK }; DBUG_ENTER("mysql_uninstall_plugin"); if (opt_noacl) @@ -2233,6 +2241,7 @@ bool mysql_uninstall_plugin(THD *thd, const LEX_STRING *name, if (check_table_access(thd, DELETE_ACL, &tables, FALSE, 1, FALSE)) DBUG_RETURN(TRUE); + WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL); /* need to open before acquiring LOCK_plugin or it will deadlock */ if (! (table= open_ltable(thd, &tables, TL_WRITE, MYSQL_LOCK_IGNORE_TIMEOUT))) @@ -2259,8 +2268,6 @@ bool mysql_uninstall_plugin(THD *thd, const LEX_STRING *name, See also mysql_install_plugin() and initialize_audit_plugin() */ - unsigned long event_class_mask[MYSQL_AUDIT_CLASS_MASK_SIZE] = - { MYSQL_AUDIT_GENERAL_CLASSMASK }; mysql_audit_acquire_plugins(thd, event_class_mask); mysql_mutex_lock(&LOCK_plugin); @@ -2290,6 +2297,10 @@ bool mysql_uninstall_plugin(THD *thd, const LEX_STRING *name, mysql_mutex_unlock(&LOCK_plugin); DBUG_RETURN(error); +#ifdef WITH_WSREP + error: + DBUG_RETURN(TRUE); +#endif /* WITH_WSREP */ } diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc index c562ee9762c..70ed6f0e600 100644 --- a/sql/sql_trigger.cc +++ b/sql/sql_trigger.cc @@ -501,6 +501,7 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create) if (err_status) goto end; } + WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL); /* We should have only one table in table list. */ DBUG_ASSERT(tables->next_global == 0); @@ -605,6 +606,10 @@ end: my_ok(thd); DBUG_RETURN(result); +#ifdef WITH_WSREP + error: + DBUG_RETURN(TRUE); +#endif /* WITH_WSREP */ } diff --git a/sql/sql_view.cc b/sql/sql_view.cc index 5bd82fdd842..f6948a76f6a 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -429,6 +429,7 @@ bool mysql_create_view(THD *thd, TABLE_LIST *views, if ((res= create_view_precheck(thd, tables, view, mode))) goto err; + WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL); lex->link_first_table_back(view, link_to_local); view->open_type= OT_BASE_ONLY; @@ -721,6 +722,10 @@ bool mysql_create_view(THD *thd, TABLE_LIST *views, lex->link_first_table_back(view, link_to_local); DBUG_RETURN(0); +#ifdef WITH_WSREP + error: + res= TRUE; +#endif /* WITH_WSREP */ err: thd_proc_info(thd, "end"); lex->link_first_table_back(view, link_to_local); -- cgit v1.2.1 From 12d7ee03efa36e9eb293fefe8313d3848fc41113 Mon Sep 17 00:00:00 2001 From: sjaakola Date: Tue, 10 Oct 2017 23:39:48 +0300 Subject: MW-416 Replicating DDL after ACL check --- sql/event_data_objects.cc | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) (limited to 'sql') diff --git a/sql/event_data_objects.cc b/sql/event_data_objects.cc index 656881b9977..0cb123451df 100644 --- a/sql/event_data_objects.cc +++ b/sql/event_data_objects.cc @@ -1468,23 +1468,35 @@ end: thd->security_ctx->master_access |= SUPER_ACL; #ifdef WITH_WSREP - if (WSREP(thd)) { - // sql_print_information("sizeof(LEX) = %d", sizeof(struct LEX)); - // sizeof(LEX) = 4512, so it's relatively safe to allocate it on stack. - LEX lex; - lex.sql_command = SQLCOM_DROP_EVENT; - LEX* saved = thd->lex; - thd->lex = &lex; - WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL); - thd->lex = saved; + /* + This code is processing event execution and does not have client + connection. Here, event execution will now execute a prepared + DROP EVENT statement, but thd->lex->sql_command is set to + SQLCOM_CREATE_PROCEDURE + DROP EVENT will be logged in binlog, and we have to + replicate it to make all nodes have consistent event definitions + Wsrep DDL replication is triggered inside Events::drop_event(), + and here we need to prepare the THD so that DDL replication is + possible, essentially it requires setting sql_command to + SQLCOMM_DROP_EVENT, we will switch sql_command for the duration + of DDL replication only. + */ + const enum_sql_command sql_command_save= thd->lex->sql_command; + const bool sql_command_set= WSREP(thd); + if (WSREP(thd)) + { + thd->lex->sql_command = SQLCOM_DROP_EVENT; } #endif ret= Events::drop_event(thd, dbname, name, FALSE); #ifdef WITH_WSREP - WSREP_TO_ISOLATION_END; - error: + if (sql_command_set) + { + WSREP_TO_ISOLATION_END; + thd->lex->sql_command = sql_command_save; + } #endif thd->security_ctx->master_access= saved_master_access; } -- cgit v1.2.1 From 241a2687d7ce07572adb2fb4629bbd319a732e5a Mon Sep 17 00:00:00 2001 From: sjaakola Date: Wed, 11 Oct 2017 15:35:17 +0300 Subject: MW-416 Replicate DDL after ACL check CREATE VIEW handling had an issue, because CREATE VIEW replication happened when view was unlinked from table list. This caused debug assert in wsrep_mysqld.cc:wsrep_can_run_in_toi() MySQL 5.5 version does not have this assert, but it is still better to run replication when table list is not manipulated. --- sql/sql_view.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sql') diff --git a/sql/sql_view.cc b/sql/sql_view.cc index f6948a76f6a..bbc5f002461 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -429,10 +429,10 @@ bool mysql_create_view(THD *thd, TABLE_LIST *views, if ((res= create_view_precheck(thd, tables, view, mode))) goto err; - WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL); lex->link_first_table_back(view, link_to_local); view->open_type= OT_BASE_ONLY; + WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL); if (open_and_lock_tables(thd, lex->query_tables, TRUE, 0)) { -- cgit v1.2.1 From 181f3015bf62bccc108aacd4df55065e0158b060 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Thu, 19 Oct 2017 11:06:55 +0300 Subject: MariaDB adjustments. Add missing COND variable and disable test that fail. --- sql/mysqld.cc | 3 ++- sql/mysqld.h | 1 + sql/sql_class.cc | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) (limited to 'sql') diff --git a/sql/mysqld.cc b/sql/mysqld.cc index f76cbe5e5b2..3edbeafe224 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -911,7 +911,7 @@ PSI_cond_key key_BINLOG_COND_prep_xids, key_BINLOG_update_cond, key_COND_thread_count, key_COND_thread_cache, key_COND_flush_thread_cache, key_BINLOG_COND_queue_busy; #ifdef WITH_WSREP -PSI_cond_key key_COND_wsrep_rollback, +PSI_cond_key key_COND_wsrep_rollback, key_COND_wsrep_thd, key_COND_wsrep_replaying, key_COND_wsrep_ready, key_COND_wsrep_sst, key_COND_wsrep_sst_init, key_COND_wsrep_sst_thread; #endif /* WITH_WSREP */ @@ -962,6 +962,7 @@ static PSI_cond_info all_server_conds[]= { &key_COND_wsrep_sst_init, "COND_wsrep_sst_init", PSI_FLAG_GLOBAL}, { &key_COND_wsrep_sst_thread, "wsrep_sst_thread", 0}, { &key_COND_wsrep_rollback, "COND_wsrep_rollback", PSI_FLAG_GLOBAL}, + { &key_COND_wsrep_thd, "THD::COND_wsrep_thd", 0}, { &key_COND_wsrep_replaying, "COND_wsrep_replaying", PSI_FLAG_GLOBAL}, #endif { &key_COND_flush_thread_cache, "COND_flush_thread_cache", PSI_FLAG_GLOBAL} diff --git a/sql/mysqld.h b/sql/mysqld.h index 14997455f2f..91fa2eda7fd 100644 --- a/sql/mysqld.h +++ b/sql/mysqld.h @@ -223,6 +223,7 @@ extern PSI_mutex_key key_PAGE_lock, key_LOCK_sync, key_LOCK_active, #endif /* HAVE_MMAP */ #ifdef WITH_WSREP extern PSI_mutex_key key_LOCK_wsrep_thd; +extern PSI_cond_key key_COND_wsrep_thd; #endif /* HAVE_WSREP */ #ifdef HAVE_OPENSSL diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 1398fdff94f..fcba6661410 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -1105,6 +1105,7 @@ THD::THD() #ifdef WITH_WSREP mysql_mutex_init(key_LOCK_wsrep_thd, &LOCK_wsrep_thd, MY_MUTEX_INIT_FAST); + mysql_cond_init(key_COND_wsrep_thd, &COND_wsrep_thd, NULL); wsrep_ws_handle.trx_id = WSREP_UNDEFINED_TRX_ID; wsrep_ws_handle.opaque = NULL; wsrep_retry_counter = 0; -- cgit v1.2.1 From e6e026ae51a77969749de201d491a176483bbc69 Mon Sep 17 00:00:00 2001 From: Ian Gilfillan Date: Thu, 23 Nov 2017 14:02:36 +0200 Subject: Update wsrep_sync_wait documentation as per MW-86 --- sql/sys_vars.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sql') diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index a0475c136ae..53b606c0336 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -3897,8 +3897,8 @@ static Sys_var_mybool Sys_wsrep_causal_reads( static Sys_var_uint Sys_wsrep_sync_wait( "wsrep_sync_wait", "Ensure \"synchronous\" read view before executing " "an operation of the type specified by bitmask: 1 - READ(includes " - "SELECT, SHOW and BEGIN/START TRANSACTION); 2 - UPDATE and DELETE; 4 - " - "INSERT and REPLACE", + "SELECT and BEGIN/START TRANSACTION); 2 - UPDATE and DELETE; 4 - " + "INSERT and REPLACE; 8 - SHOW", SESSION_VAR(wsrep_sync_wait), CMD_LINE(OPT_ARG), VALID_RANGE(WSREP_SYNC_WAIT_NONE, WSREP_SYNC_WAIT_MAX), DEFAULT(WSREP_SYNC_WAIT_NONE), BLOCK_SIZE(1), -- cgit v1.2.1 From 843503e90f902a0c4691467b294a5edc34cf9f21 Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Tue, 24 Oct 2017 16:48:08 +0300 Subject: Set wsrep_rli to NULL after deleting it --- sql/sql_class.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'sql') diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 883f0c9cc88..7aae3ed91ed 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -1695,7 +1695,10 @@ THD::~THD() mysql_mutex_unlock(&LOCK_wsrep_thd); mysql_mutex_destroy(&LOCK_wsrep_thd); mysql_cond_destroy(&COND_wsrep_thd); - if (wsrep_rli) delete wsrep_rli; + if (wsrep_rli != NULL) { + delete wsrep_rli; + wsrep_rli = NULL; + } if (wsrep_status_vars) wsrep->stats_free(wsrep, wsrep_status_vars); #endif /* Close connection */ -- cgit v1.2.1 From 2400b769c641adaaed3badc1f8eeae1de4065c05 Mon Sep 17 00:00:00 2001 From: Nirbhay Choubey Date: Mon, 21 Nov 2016 16:20:10 -0500 Subject: MDEV-10442: "Address already in use" on restart SST processes should inherit mysqld's process group. --- sql/wsrep_utils.cc | 1 - 1 file changed, 1 deletion(-) (limited to 'sql') diff --git a/sql/wsrep_utils.cc b/sql/wsrep_utils.cc index 951007c2660..14bf4f29794 100644 --- a/sql/wsrep_utils.cc +++ b/sql/wsrep_utils.cc @@ -264,7 +264,6 @@ process::process (const char* cmd, const char* type, char** env) err_ = posix_spawnattr_setflags (&attr, POSIX_SPAWN_SETSIGDEF | POSIX_SPAWN_SETSIGMASK | - /* start a new process group */ POSIX_SPAWN_SETPGROUP | POSIX_SPAWN_USEVFORK); if (err_) { -- cgit v1.2.1 From 09b25f85966f44aae933e86b84b4ebe59ded47c3 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Thu, 1 Mar 2018 16:35:46 +0100 Subject: only allow SUPER user to modify wsrep_on --- sql/sys_vars.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sql') diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index 53b606c0336..8a9120abdd0 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -3854,7 +3854,7 @@ static Sys_var_mybool Sys_wsrep_on ( "wsrep_on", "To enable wsrep replication ", SESSION_VAR(wsrep_on), CMD_LINE(OPT_ARG), DEFAULT(TRUE), - NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), + NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(check_has_super), ON_UPDATE(wsrep_on_update)); static Sys_var_charptr Sys_wsrep_start_position ( -- cgit v1.2.1 From 4ec7b840776e498456b9a22a51178099e4d66aa3 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Fri, 2 Mar 2018 10:54:34 +1100 Subject: MDEV-8743: use O_CLOEXEC MYSQL_LOG::open / TC_LOG_MMAP::open For galera compatibility, the main thing is to ensure the FD 1, 2 are not opened with O_CLOEXEC otherwise galera sst errors don't appear in the error.log Files without O_CLOEXEC from the test below: 0 -> /dev/pts/9 1 -> /tmp/error.log (intended) 2 -> /tmp/error.log (intended) 5 -> /tmp/datadir 6 -> /tmp/datadir/aria_log.00000001 (Innodb temp files) 8 -> /tmp/ibIIrhFL (deleted) 9 -> /tmp/ibfx1vai (deleted) 10 -> /tmp/ibAQUKFO (deleted) 11 -> /tmp/ibWBQSHR (deleted) 15 -> /tmp/ibEXEcfo (deleted) 20 -> /tmp/datadir/mysql/host.MYD 22 -> /tmp/datadir/mysql/user.MYD ... (rest of MYD files) Test for this and the previous commit. sql/mysqld --skip-networking --datadir=/tmp/datadir --log-bin=/tmp/datadir/mysqlbin --socket /tmp/s.sock --lc-messages-dir=${PWD}/sql/share --verbose --log-error=/tmp/error.log --general-log-file=/tmp/general.log --general-log=1 --slow-query-log-file=/tmp/slow.log --slow-query-log=1 180302 10:56:41 [Note] sql/mysqld (mysqld 5.5.60-MariaDB-wsrep) starting as process 26056 ... $ cd /proc/26056 $ ls -la --sort=none fd total 0 dr-x------. 2 dan dan 0 Mar 2 10:57 . dr-xr-xr-x. 9 dan dan 0 Mar 2 10:56 .. lrwx------. 1 dan dan 64 Mar 2 10:57 0 -> /dev/pts/9 l-wx------. 1 dan dan 64 Mar 2 10:57 1 -> /tmp/error.log l-wx------. 1 dan dan 64 Mar 2 10:57 2 -> /tmp/error.log lrwx------. 1 dan dan 64 Mar 2 10:57 3 -> /tmp/datadir/mysqlbin.index lrwx------. 1 dan dan 64 Mar 2 10:57 4 -> /tmp/datadir/aria_log_control lr-x------. 1 dan dan 64 Mar 2 10:57 5 -> /tmp/datadir lrwx------. 1 dan dan 64 Mar 2 10:57 6 -> /tmp/datadir/aria_log.00000001 lrwx------. 1 dan dan 64 Mar 2 10:57 7 -> /tmp/datadir/ibdata1 lrwx------. 1 dan dan 64 Mar 2 10:57 8 -> /tmp/ibIIrhFL (deleted) lrwx------. 1 dan dan 64 Mar 2 10:57 9 -> /tmp/ibfx1vai (deleted) lrwx------. 1 dan dan 64 Mar 2 10:57 10 -> /tmp/ibAQUKFO (deleted) lrwx------. 1 dan dan 64 Mar 2 10:57 11 -> /tmp/ibWBQSHR (deleted) lrwx------. 1 dan dan 64 Mar 2 10:57 12 -> /tmp/datadir/ib_logfile0 lrwx------. 1 dan dan 64 Mar 2 10:57 13 -> /tmp/datadir/ib_logfile1 l-wx------. 1 dan dan 64 Mar 2 10:57 14 -> /tmp/slow.log lrwx------. 1 dan dan 64 Mar 2 10:57 15 -> /tmp/ibEXEcfo (deleted) l-wx------. 1 dan dan 64 Mar 2 10:57 16 -> /tmp/general.log lrwx------. 1 dan dan 64 Mar 2 10:57 17 -> socket:[1897356] lrwx------. 1 dan dan 64 Mar 2 10:57 18 -> socket:[45335] l-wx------. 1 dan dan 64 Mar 2 10:57 19 -> /tmp/datadir/mysqlbin.000004 lrwx------. 1 dan dan 64 Mar 2 10:57 20 -> /tmp/datadir/mysql/host.MYD lrwx------. 1 dan dan 64 Mar 2 10:57 21 -> /tmp/datadir/mysql/host.MYI lrwx------. 1 dan dan 64 Mar 2 10:57 22 -> /tmp/datadir/mysql/user.MYD lrwx------. 1 dan dan 64 Mar 2 10:57 23 -> /tmp/datadir/mysql/user.MYI lrwx------. 1 dan dan 64 Mar 2 10:57 24 -> /tmp/datadir/mysql/db.MYD lrwx------. 1 dan dan 64 Mar 2 10:57 25 -> /tmp/datadir/mysql/db.MYI lrwx------. 1 dan dan 64 Mar 2 10:57 26 -> /tmp/datadir/mysql/proxies_priv.MYD lrwx------. 1 dan dan 64 Mar 2 10:57 27 -> /tmp/datadir/mysql/proxies_priv.MYI lrwx------. 1 dan dan 64 Mar 2 10:57 28 -> /tmp/datadir/mysql/tables_priv.MYD lrwx------. 1 dan dan 64 Mar 2 10:57 29 -> /tmp/datadir/mysql/tables_priv.MYI lrwx------. 1 dan dan 64 Mar 2 10:57 30 -> /tmp/datadir/mysql/columns_priv.MYD lrwx------. 1 dan dan 64 Mar 2 10:57 31 -> /tmp/datadir/mysql/columns_priv.MYI lrwx------. 1 dan dan 64 Mar 2 10:57 32 -> /tmp/datadir/mysql/procs_priv.MYD lrwx------. 1 dan dan 64 Mar 2 10:57 33 -> /tmp/datadir/mysql/procs_priv.MYI lrwx------. 1 dan dan 64 Mar 2 10:57 34 -> /tmp/datadir/mysql/servers.MYD lrwx------. 1 dan dan 64 Mar 2 10:57 35 -> /tmp/datadir/mysql/servers.MYI lrwx------. 1 dan dan 64 Mar 2 10:57 36 -> /tmp/datadir/mysql/event.MYD lrwx------. 1 dan dan 64 Mar 2 10:57 37 -> /tmp/datadir/mysql/event.MYI O_CLOEXEC files are those with flags 02000000 /usr/include/bits/fcntl-linux.h:# define __O_CLOEXEC 02000000 /usr/include/bits/fcntl-linux.h:# define O_CLOEXEC __O_CLOEXEC /* Set close_on_exec. */ $ find fdinfo/ -type f -ls -exec cat {} \; | more 1924720 0 -r-------- 1 dan dan 0 Mar 2 10:57 fdinfo/0 pos: 0 flags: 0100002 mnt_id: 25 1924721 0 -r-------- 1 dan dan 0 Mar 2 10:57 fdinfo/1 pos: 9954 flags: 0102001 mnt_id: 82 1924722 0 -r-------- 1 dan dan 0 Mar 2 10:57 fdinfo/2 pos: 10951 flags: 0102001 mnt_id: 82 1924723 0 -r-------- 1 dan dan 0 Mar 2 10:57 fdinfo/3 pos: 116 flags: 02100002 mnt_id: 82 1924724 0 -r-------- 1 dan dan 0 Mar 2 10:57 fdinfo/4 pos: 52 flags: 0100002 mnt_id: 82 lock: 1: POSIX ADVISORY WRITE 26056 00:2c:1866365 0 EOF 1924725 0 -r-------- 1 dan dan 0 Mar 2 10:57 fdinfo/5 pos: 0 flags: 0100000 mnt_id: 82 1924726 0 -r-------- 1 dan dan 0 Mar 2 10:57 fdinfo/6 pos: 16384 flags: 0100002 mnt_id: 82 1924727 0 -r-------- 1 dan dan 0 Mar 2 10:57 fdinfo/7 pos: 0 flags: 02100002 mnt_id: 82 lock: 1: POSIX ADVISORY WRITE 26056 00:2c:1866491 0 EOF 1924728 0 -r-------- 1 dan dan 0 Mar 2 10:57 fdinfo/8 pos: 0 flags: 0100002 mnt_id: 82 1924729 0 -r-------- 1 dan dan 0 Mar 2 10:57 fdinfo/9 pos: 0 flags: 0100002 mnt_id: 82 1924730 0 -r-------- 1 dan dan 0 Mar 2 10:57 fdinfo/10 pos: 0 flags: 0100002 mnt_id: 82 1924731 0 -r-------- 1 dan dan 0 Mar 2 10:57 fdinfo/11 pos: 0 flags: 0100002 mnt_id: 82 1924732 0 -r-------- 1 dan dan 0 Mar 2 10:57 fdinfo/12 pos: 0 flags: 02100002 mnt_id: 82 lock: 1: POSIX ADVISORY WRITE 26056 00:2c:1866492 0 EOF 1924733 0 -r-------- 1 dan dan 0 Mar 2 10:57 fdinfo/13 pos: 0 flags: 02100002 mnt_id: 82 lock: 1: POSIX ADVISORY WRITE 26056 00:2c:1866493 0 EOF 1924734 0 -r-------- 1 dan dan 0 Mar 2 10:57 fdinfo/14 pos: 763 flags: 02102001 mnt_id: 82 1924735 0 -r-------- 1 dan dan 0 Mar 2 10:57 fdinfo/15 pos: 0 flags: 0100002 mnt_id: 82 1924736 0 -r-------- 1 dan dan 0 Mar 2 10:57 fdinfo/16 pos: 473 flags: 02102001 mnt_id: 82 1924737 0 -r-------- 1 dan dan 0 Mar 2 10:57 fdinfo/17 pos: 0 flags: 02000002 mnt_id: 9 1924738 0 -r-------- 1 dan dan 0 Mar 2 10:57 fdinfo/18 pos: 0 flags: 02 mnt_id: 9 1924739 0 -r-------- 1 dan dan 0 Mar 2 10:57 fdinfo/19 pos: 245 flags: 02100001 mnt_id: 82 1924740 0 -r-------- 1 dan dan 0 Mar 2 10:57 fdinfo/20 pos: 0 flags: 0100002 mnt_id: 82 1924741 0 -r-------- 1 dan dan 0 Mar 2 10:57 fdinfo/21 pos: 503 flags: 0500002 mnt_id: 82 1924742 0 -r-------- 1 dan dan 0 Mar 2 10:57 fdinfo/22 pos: 324 flags: 0100002 mnt_id: 82 1924743 0 -r-------- 1 dan dan 0 Mar 2 10:57 fdinfo/23 pos: 642 flags: 0500002 mnt_id: 82 1924744 0 -r-------- 1 dan dan 0 Mar 2 10:57 fdinfo/24 pos: 880 flags: 0100002 mnt_id: 82 1924745 0 -r-------- 1 dan dan 0 Mar 2 10:57 fdinfo/25 pos: 581 flags: 0500002 mnt_id: 82 1924746 0 -r-------- 1 dan dan 0 Mar 2 10:57 fdinfo/26 pos: 1386 flags: 0100002 mnt_id: 82 1924747 0 -r-------- 1 dan dan 0 Mar 2 10:57 fdinfo/27 pos: 498 flags: 0500002 mnt_id: 82 1924748 0 -r-------- 1 dan dan 0 Mar 2 10:57 fdinfo/28 pos: 0 flags: 0100002 mnt_id: 82 1924749 0 -r-------- 1 dan dan 0 Mar 2 10:57 fdinfo/29 pos: 513 flags: 0500002 mnt_id: 82 1924750 0 -r-------- 1 dan dan 0 Mar 2 10:57 fdinfo/30 pos: 0 flags: 0100002 mnt_id: 82 1924751 0 -r-------- 1 dan dan 0 Mar 2 10:57 fdinfo/31 pos: 494 flags: 0500002 mnt_id: 82 1924752 0 -r-------- 1 dan dan 0 Mar 2 10:57 fdinfo/32 pos: 0 flags: 0100002 mnt_id: 82 1924753 0 -r-------- 1 dan dan 0 Mar 2 10:57 fdinfo/33 pos: 535 flags: 0500002 mnt_id: 82 1924754 0 -r-------- 1 dan dan 0 Mar 2 10:57 fdinfo/34 pos: 0 flags: 0100002 mnt_id: 82 1924755 0 -r-------- 1 dan dan 0 Mar 2 10:57 fdinfo/35 pos: 396 flags: 0500002 mnt_id: 82 1924756 0 -r-------- 1 dan dan 0 Mar 2 10:57 fdinfo/36 pos: 0 flags: 0100002 mnt_id: 82 1924757 0 -r-------- 1 dan dan 0 Mar 2 10:57 fdinfo/37 pos: 517 flags: 0500002 mnt_id: 82 --- sql/log.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'sql') diff --git a/sql/log.cc b/sql/log.cc index 4760e668aeb..ca7833a0460 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -2466,7 +2466,7 @@ bool MYSQL_LOG::open( File file= -1; my_off_t seek_offset; bool is_fifo = false; - int open_flags= O_CREAT | O_BINARY; + int open_flags= O_CREAT | O_BINARY | O_CLOEXEC; DBUG_ENTER("MYSQL_LOG::open"); DBUG_PRINT("enter", ("log_type: %d", (int) log_type_arg)); @@ -3088,7 +3088,7 @@ bool MYSQL_BIN_LOG::open_index_file(const char *index_file_name_arg, ".index", opt); if ((index_file_nr= mysql_file_open(m_key_file_log_index, index_file_name, - O_RDWR | O_CREAT | O_BINARY, + O_RDWR | O_CREAT | O_BINARY | O_CLOEXEC, MYF(MY_WME))) < 0 || mysql_file_sync(index_file_nr, MYF(MY_WME)) || init_io_cache(&index_file, index_file_nr, @@ -7045,14 +7045,14 @@ int TC_LOG_MMAP::open(const char *opt_name) DBUG_ASSERT(TC_LOG_PAGE_SIZE % tc_log_page_size == 0); fn_format(logname,opt_name,mysql_data_home,"",MY_UNPACK_FILENAME); - if ((fd= mysql_file_open(key_file_tclog, logname, O_RDWR, MYF(0))) < 0) + if ((fd= mysql_file_open(key_file_tclog, logname, O_RDWR | O_CLOEXEC, MYF(0))) < 0) { if (my_errno != ENOENT) goto err; if (using_heuristic_recover()) return 1; if ((fd= mysql_file_create(key_file_tclog, logname, CREATE_MODE, - O_RDWR, MYF(MY_WME))) < 0) + O_RDWR | O_CLOEXEC, MYF(MY_WME))) < 0) goto err; inited=1; file_length= opt_tc_log_size; -- cgit v1.2.1 From ccd566af20dc47a5708e2e707c9624796ea79bef Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Thu, 19 Apr 2018 07:38:57 +1000 Subject: MDEV-8743: mysqld port/socket - FD_CLOEXEC if no SOCK_CLOEXEC In MDEV-8743, the port/socket of mysqld was changed to set FD_CLOEXEC. The existing mysql_socket_socket function already set that with SOCK_CLOEXEC when the socket was created. So here we move the fcntl functionality to the mysql_socket_socket as port/socket are the only callers. Preprocessor checks of SOCK_CLOEXEC cannot be done as its a 0 if not there and SOCK_CLOEXEC (being the value of the enum in bits/socket_type.h) Preprocesssor logic for arithmetic and non-arithmetic defines are hard/nonportable/ugly to read. As such we just check in my_global.h and define HAVE_SOCK_CLOEXEC if we have it. There was a disparity in behaviour between defined(WITH_WSREP) and not depending on the OS, so the WITH_WSREP condition was removed from setting calling fcntl. All sockets are now maked SOCK_CLOEXEC/FD_CLOEXEC. strace of mysqld with SOCK_CLOEXEC: socket(AF_INET, SOCK_STREAM|SOCK_CLOEXEC, IPPROTO_TCP) = 10 write(2, "180419 14:52:40 [Note] Server socket created on IP: '127.0.0.1'.\n", 65180419 14:52:40 [Note] Server socket created on IP: '127.0.0.1'. ) = 65 setsockopt(10, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0 bind(10, {sa_family=AF_INET, sin_port=htons(16020), sin_addr=inet_addr("127.0.0.1")}, 16) = 0 listen(10, 150) = 0 socket(AF_INET, SOCK_STREAM|SOCK_CLOEXEC, IPPROTO_TCP) = 11 write(2, "180419 14:52:40 [Note] Server socket created on IP: '127.0.0.1'.\n", 65180419 14:52:40 [Note] Server socket created on IP: '127.0.0.1'. ) = 65 setsockopt(11, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0 bind(11, {sa_family=AF_INET, sin_port=htons(16021), sin_addr=inet_addr("127.0.0.1")}, 16) = 0 listen(11, 150) = 0 socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC, 0) = 12 unlink("/home/dan/repos/build-mariadb-server-10.0/mysql-test/var/tmp/mysqld.1.sock") = -1 ENOENT (No such file or directory) setsockopt(12, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0 umask(000) = 006 bind(12, {sa_family=AF_UNIX, sun_path="/home/dan/repos/build-mariadb-server-10.0/mysql-test/var/tmp/mysqld.1.sock"}, 110) = 0 umask(006) = 000 listen(12, 150) = 0 --- sql/mysqld.cc | 7 ------- 1 file changed, 7 deletions(-) (limited to 'sql') diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 8575709203c..15f4af5edbb 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -2593,10 +2593,6 @@ static MYSQL_SOCKET activate_tcp_port(uint port) socket_errno); unireg_abort(1); } -#if defined(WITH_WSREP) && defined(HAVE_FCNTL) && defined(FD_CLOEXEC) - (void) fcntl(mysql_socket_getfd(ip_sock), F_SETFD, FD_CLOEXEC); -#endif /* WITH_WSREP */ - DBUG_RETURN(ip_sock); } @@ -2714,9 +2710,6 @@ static void network_init(void) if (mysql_socket_listen(unix_sock,(int) back_log) < 0) sql_print_warning("listen() on Unix socket failed with error %d", socket_errno); -#if defined(WITH_WSREP) && defined(HAVE_FCNTL) - (void) fcntl(mysql_socket_getfd(unix_sock), F_SETFD, FD_CLOEXEC); -#endif /* WITH_WSREP */ } #endif DBUG_PRINT("info",("server started")); -- cgit v1.2.1 From c2c61bbccea3525e12d8897c009898138a335392 Mon Sep 17 00:00:00 2001 From: Teemu Ollakka Date: Sun, 17 Dec 2017 14:41:55 +0200 Subject: Provider rollback for ineffective trx codership/mysql-wsrep#318 Adapt MTR tests to new Galera status variables and fix exposed leaks In certain cases it is possible that transaction has populated keys in the provider but during commit time the IO cache is empty, so the provider commit does not happen (for example early ROLLBACK TO SAVEPOINT followed by COMMIT). Run provider post_rollback() to clean up the transaction object. --- sql/wsrep_hton.cc | 39 ++++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) (limited to 'sql') diff --git a/sql/wsrep_hton.cc b/sql/wsrep_hton.cc index 0572230b18b..c18c179a4bd 100644 --- a/sql/wsrep_hton.cc +++ b/sql/wsrep_hton.cc @@ -99,16 +99,45 @@ void wsrep_register_hton(THD* thd, bool all) */ void wsrep_post_commit(THD* thd, bool all) { - if (thd->wsrep_exec_mode == LOCAL_COMMIT) + if (!WSREP(thd)) return; + + switch (thd->wsrep_exec_mode) { - DBUG_ASSERT(thd->wsrep_trx_meta.gtid.seqno != WSREP_SEQNO_UNDEFINED); - if (wsrep->post_commit(wsrep, &thd->wsrep_ws_handle)) + case LOCAL_COMMIT: { + DBUG_ASSERT(thd->wsrep_trx_meta.gtid.seqno != WSREP_SEQNO_UNDEFINED); + if (wsrep->post_commit(wsrep, &thd->wsrep_ws_handle)) + { DBUG_PRINT("wsrep", ("set committed fail")); - WSREP_WARN("set committed fail: %llu %d", + WSREP_WARN("set committed fail: %llu %d", (long long)thd->real_id, thd->stmt_da->status()); + } + wsrep_cleanup_transaction(thd); + break; } - wsrep_cleanup_transaction(thd); + case LOCAL_STATE: + { + /* non-InnoDB statements may have populated events in stmt cache + => cleanup + */ + WSREP_DEBUG("cleanup transaction for LOCAL_STATE"); + /* + Run post-rollback hook to clean up in the case if + some keys were populated for the transaction in provider + but during commit time there was no write set to replicate. + This may happen when client sets the SAVEPOINT and immediately + rolls back to savepoint after first operation. + */ + if (all && thd->wsrep_conflict_state != MUST_REPLAY && + wsrep->post_rollback(wsrep, &thd->wsrep_ws_handle)) + { + WSREP_WARN("post_rollback fail: %llu %d", + (long long)thd->thread_id, thd->stmt_da->status()); + } + wsrep_cleanup_transaction(thd); + break; + } + default: break; } } -- cgit v1.2.1 From 231c02f7b9fc05ffa07dacd5f31bbd2ff14e7cca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Tue, 24 Apr 2018 13:58:42 +0300 Subject: MariaDB adjustments. --- sql/wsrep_hton.cc | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) (limited to 'sql') diff --git a/sql/wsrep_hton.cc b/sql/wsrep_hton.cc index c18c179a4bd..1676daab5fe 100644 --- a/sql/wsrep_hton.cc +++ b/sql/wsrep_hton.cc @@ -103,10 +103,10 @@ void wsrep_post_commit(THD* thd, bool all) switch (thd->wsrep_exec_mode) { - case LOCAL_COMMIT: + case LOCAL_COMMIT: { DBUG_ASSERT(thd->wsrep_trx_meta.gtid.seqno != WSREP_SEQNO_UNDEFINED); - if (wsrep->post_commit(wsrep, &thd->wsrep_ws_handle)) + if (wsrep && wsrep->post_commit(wsrep, &thd->wsrep_ws_handle)) { DBUG_PRINT("wsrep", ("set committed fail")); WSREP_WARN("set committed fail: %llu %d", @@ -115,29 +115,29 @@ void wsrep_post_commit(THD* thd, bool all) wsrep_cleanup_transaction(thd); break; } - case LOCAL_STATE: - { - /* non-InnoDB statements may have populated events in stmt cache - => cleanup - */ - WSREP_DEBUG("cleanup transaction for LOCAL_STATE"); - /* - Run post-rollback hook to clean up in the case if - some keys were populated for the transaction in provider - but during commit time there was no write set to replicate. - This may happen when client sets the SAVEPOINT and immediately - rolls back to savepoint after first operation. + case LOCAL_STATE: + { + /* non-InnoDB statements may have populated events in stmt cache + => cleanup + */ + WSREP_DEBUG("cleanup transaction for LOCAL_STATE"); + /* + Run post-rollback hook to clean up in the case if + some keys were populated for the transaction in provider + but during commit time there was no write set to replicate. + This may happen when client sets the SAVEPOINT and immediately + rolls back to savepoint after first operation. */ - if (all && thd->wsrep_conflict_state != MUST_REPLAY && - wsrep->post_rollback(wsrep, &thd->wsrep_ws_handle)) - { - WSREP_WARN("post_rollback fail: %llu %d", - (long long)thd->thread_id, thd->stmt_da->status()); - } - wsrep_cleanup_transaction(thd); - break; - } - default: break; + if (all && thd->wsrep_conflict_state != MUST_REPLAY && + wsrep && wsrep->post_rollback(wsrep, &thd->wsrep_ws_handle)) + { + WSREP_WARN("post_rollback fail: %llu %d", + (long long)thd->thread_id, thd->stmt_da->status()); + } + wsrep_cleanup_transaction(thd); + break; + } + default: break; } } -- cgit v1.2.1 From 1ecd68d867ced1d00ebffdcedbf6bc97493f5067 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 30 Apr 2018 23:06:09 +0200 Subject: Use after free in authentication --- sql/sql_acl.cc | 1 + 1 file changed, 1 insertion(+) (limited to 'sql') diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index c3740f8ab29..15a238193dd 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -8253,6 +8253,7 @@ static bool send_plugin_request_packet(MPVIO_EXT *mpvio, const char *client_auth_plugin= ((st_mysql_auth *) (plugin_decl(mpvio->plugin)->info))->client_auth_plugin; + DBUG_EXECUTE_IF("auth_disconnect", { vio_close(net->vio); DBUG_RETURN(1); }); DBUG_ASSERT(client_auth_plugin); /* -- cgit v1.2.1