From 8a71fde01f153bda42d57587527376bc33e9e3e9 Mon Sep 17 00:00:00 2001 From: Daniele Sciascia Date: Tue, 20 Oct 2015 17:54:14 +0200 Subject: [PATCH 01/61] refs codership/mysql-wsrep#201 - Fixes query cache so that it is aware of wsrep_sync_wait. Query cache would return (possibly stale) results to the client, regardless of the value of wsrep_sync_wait. - Includes the test case that reproduced the issue. --- .../suite/galera/r/mysql-wsrep#201.result | 4 +++ .../suite/galera/t/mysql-wsrep#201-master.opt | 1 + .../suite/galera/t/mysql-wsrep#201.test | 33 +++++++++++++++++++ sql/sql_cache.cc | 20 +++++++++++ sql/sql_class.cc | 6 ++++ sql/sql_class.h | 1 + sql/wsrep_mysqld.cc | 17 ++++++---- sql/wsrep_mysqld.h | 1 + 8 files changed, 77 insertions(+), 6 deletions(-) create mode 100644 mysql-test/suite/galera/r/mysql-wsrep#201.result create mode 100644 mysql-test/suite/galera/t/mysql-wsrep#201-master.opt create mode 100644 mysql-test/suite/galera/t/mysql-wsrep#201.test diff --git a/mysql-test/suite/galera/r/mysql-wsrep#201.result b/mysql-test/suite/galera/r/mysql-wsrep#201.result new file mode 100644 index 00000000000..1c0998e35ac --- /dev/null +++ b/mysql-test/suite/galera/r/mysql-wsrep#201.result @@ -0,0 +1,4 @@ +CREATE TABLE t1 (id INT PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (DEFAULT); +SET GLOBAL query_cache_size=1355776; +SET SESSION wsrep_sync_wait = 7; diff --git a/mysql-test/suite/galera/t/mysql-wsrep#201-master.opt b/mysql-test/suite/galera/t/mysql-wsrep#201-master.opt new file mode 100644 index 00000000000..a00258bc48c --- /dev/null +++ b/mysql-test/suite/galera/t/mysql-wsrep#201-master.opt @@ -0,0 +1 @@ +--query_cache_type=1 diff --git a/mysql-test/suite/galera/t/mysql-wsrep#201.test b/mysql-test/suite/galera/t/mysql-wsrep#201.test new file mode 100644 index 00000000000..cc842afb6d0 --- /dev/null +++ b/mysql-test/suite/galera/t/mysql-wsrep#201.test @@ -0,0 +1,33 @@ +--source include/galera_cluster.inc +--source include/have_innodb.inc +--source include/have_query_cache.inc + +CREATE TABLE t1 (id INT PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (DEFAULT); + +--connection node_2 +--let $qcache_size_orig = `SELECT @@GLOBAL.query_cache_size` +SET GLOBAL query_cache_size=1355776; +SET SESSION wsrep_sync_wait = 7; + +--disable_query_log + +--let $count = 10000 +while ($count) +{ + --connection node_1 + INSERT INTO t1 VALUES (DEFAULT); + --let $val1 = `SELECT LAST_INSERT_ID()` + --connection node_2 + --let $val2 = `SELECT MAX(id) FROM t1` + --let $val3 = `SELECT $val1 != $val2` + if ($val3) + { + --echo $val1 $val2 + --die wsrep_sync_wait failed + } + --dec $count +} + +--eval SET GLOBAL query_cache_size = $qcache_size_orig +DROP TABLE t1; diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc index ad0472cfc2c..557d16d1312 100644 --- a/sql/sql_cache.cc +++ b/sql/sql_cache.cc @@ -1804,6 +1804,7 @@ Query_cache::send_result_to_client(THD *thd, char *org_sql, uint query_length) goto err; } } + /* Try to obtain an exclusive lock on the query cache. If the cache is disabled or if a full cache flush is in progress, the attempt to @@ -1915,6 +1916,25 @@ def_week_frmt: %lu, in_trans: %d, autocommit: %d", } DBUG_PRINT("qcache", ("Query in query hash 0x%lx", (ulong)query_block)); +#ifdef WITH_WSREP + if (WSREP_CLIENT(thd) && wsrep_must_sync_wait(thd)) { + unlock(); + if (wsrep_sync_wait(thd)) + goto err; + if (try_lock(TRUE)) + goto err; + query_block = (Query_cache_block *) my_hash_search(&queries, + (uchar*) sql, + tot_length); + if (query_block == 0 || + query_block->query()->result() == 0 || + query_block->query()->result()->type != Query_cache_block::RESULT) + { + goto err_unlock; + } + } +#endif /* WITH_WSREP */ + /* Now lock and test that nothing changed while blocks was unlocked */ BLOCK_LOCK_RD(query_block); diff --git a/sql/sql_class.cc b/sql/sql_class.cc index e13cee8de4a..09533599ac0 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -1118,6 +1118,7 @@ THD::THD() wsrep_bf_thd = NULL; wsrep_TOI_pre_query = NULL; wsrep_TOI_pre_query_len = 0; + wsrep_sync_wait_gtid= WSREP_GTID_UNDEFINED; #endif /* Call to init() below requires fully initialized Open_tables_state. */ reset_open_tables_state(this); @@ -1487,6 +1488,7 @@ void THD::init(void) wsrep_bf_thd = NULL; wsrep_TOI_pre_query = NULL; wsrep_TOI_pre_query_len = 0; + wsrep_sync_wait_gtid= WSREP_GTID_UNDEFINED; /* @@wsrep_causal_reads is now being handled via wsrep_sync_wait, update it @@ -2137,6 +2139,10 @@ void THD::cleanup_after_query() rli_slave->cleanup_after_query(); #endif +#ifdef WITH_WSREP + wsrep_sync_wait_gtid= WSREP_GTID_UNDEFINED; +#endif /* WITH_WSREP */ + DBUG_VOID_RETURN; } diff --git a/sql/sql_class.h b/sql/sql_class.h index 6deabb04f3d..6e80eeb7096 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -2395,6 +2395,7 @@ public: size_t wsrep_TOI_pre_query_len; void* wsrep_apply_format; bool wsrep_apply_toi; /* applier processing in TOI */ + wsrep_gtid_t wsrep_sync_wait_gtid; #endif /* WITH_WSREP */ /** Internal parser state. diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc index c570c7b831d..71cff536b72 100644 --- a/sql/wsrep_mysqld.cc +++ b/sql/wsrep_mysqld.cc @@ -866,19 +866,24 @@ bool wsrep_start_replication() return true; } +bool wsrep_must_sync_wait (THD* thd, uint mask) +{ + return (thd->variables.wsrep_sync_wait & mask) && + thd->variables.wsrep_on && + !thd->in_active_multi_stmt_transaction() && + thd->wsrep_conflict_state != REPLAYING && + thd->wsrep_sync_wait_gtid.seqno == WSREP_SEQNO_UNDEFINED; +} + bool wsrep_sync_wait (THD* thd, uint mask) { - if ((thd->variables.wsrep_sync_wait & mask) && - thd->variables.wsrep_on && - !thd->in_active_multi_stmt_transaction() && - thd->wsrep_conflict_state != REPLAYING) + if (wsrep_must_sync_wait(thd, mask)) { WSREP_DEBUG("wsrep_sync_wait: thd->variables.wsrep_sync_wait = %u, mask = %u", thd->variables.wsrep_sync_wait, mask); // This allows autocommit SELECTs and a first SELECT after SET AUTOCOMMIT=0 // TODO: modify to check if thd has locked any rows. - wsrep_gtid_t gtid; - wsrep_status_t ret= wsrep->causal_read (wsrep, >id); + wsrep_status_t ret= wsrep->causal_read (wsrep, &thd->wsrep_sync_wait_gtid); if (unlikely(WSREP_OK != ret)) { diff --git a/sql/wsrep_mysqld.h b/sql/wsrep_mysqld.h index e6fe0c04fac..f109211751d 100644 --- a/sql/wsrep_mysqld.h +++ b/sql/wsrep_mysqld.h @@ -183,6 +183,7 @@ extern void wsrep_kill_mysql(THD *thd); /* new defines */ extern void wsrep_stop_replication(THD *thd); extern bool wsrep_start_replication(); +extern bool wsrep_must_sync_wait (THD* thd, uint mask = WSREP_SYNC_WAIT_BEFORE_READ); extern bool wsrep_sync_wait (THD* thd, uint mask = WSREP_SYNC_WAIT_BEFORE_READ); extern int wsrep_check_opts (int argc, char* const* argv); extern void wsrep_prepend_PATH (const char* path); From 0c7dffe9e18e249ca7930b29d7c3c6832c03a278 Mon Sep 17 00:00:00 2001 From: Daniele Sciascia Date: Thu, 22 Oct 2015 17:30:20 +0200 Subject: [PATCH 02/61] refs codership/mysql-wsrep#201 - Eliminates code duplication in query cache patch - Reduces the number of iterations in mysql-wsrep#201.test to shorten the execution time - Adds a new test case that exercises more scenarios --- .../r/galera_query_cache_sync_wait.result | 45 ++++++++++ .../t/galera_query_cache_sync_wait-master.opt | 1 + .../t/galera_query_cache_sync_wait.test | 90 +++++++++++++++++++ .../suite/galera/t/mysql-wsrep#201.test | 2 +- sql/sql_cache.cc | 22 ++--- 5 files changed, 148 insertions(+), 12 deletions(-) create mode 100644 mysql-test/suite/galera/r/galera_query_cache_sync_wait.result create mode 100644 mysql-test/suite/galera/t/galera_query_cache_sync_wait-master.opt create mode 100644 mysql-test/suite/galera/t/galera_query_cache_sync_wait.test diff --git a/mysql-test/suite/galera/r/galera_query_cache_sync_wait.result b/mysql-test/suite/galera/r/galera_query_cache_sync_wait.result new file mode 100644 index 00000000000..e9faff8be8b --- /dev/null +++ b/mysql-test/suite/galera/r/galera_query_cache_sync_wait.result @@ -0,0 +1,45 @@ +CREATE TABLE t1 (id INT PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +SET GLOBAL wsrep_provider_options = "repl.causal_read_timeout=PT1S"; +SET GLOBAL DEBUG = "d,sync.wsrep_apply_cb"; +SET SESSION wsrep_sync_wait = 7; +SELECT MAX(id) FROM t1; +MAX(id) +1 +INSERT INTO t1 VALUES (2); +SELECT MAX(id) FROM t1; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +SET GLOBAL DEBUG = ""; +SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb"; +FLUSH QUERY CACHE; +SET SESSION wsrep_sync_wait = 7; +SET GLOBAL DEBUG = "d,sync.wsrep_apply_cb"; +INSERT INTO t1 VALUES (3); +SELECT MAX(id) FROM t1; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +SET GLOBAL DEBUG = ""; +SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb"; +INSERT INTO t1 VALUES (4); +SET SESSION wsrep_sync_wait = 7; +SELECT MAX(id) FROM t1; +MAX(id) +4 +SET SESSION wsrep_sync_wait = 7; +FLUSH STATUS; +SELECT MAX(id) FROM t1; +MAX(id) +4 +SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'Qcache_hits'; +VARIABLE_VALUE = 1 +1 +SET GLOBAL DEBUG = "d,sync.wsrep_apply_cb"; +INSERT INTO t1 VALUES (5); +SET SESSION wsrep_sync_wait = 7; +SELECT MAX(id) FROM t1 ; +SET GLOBAL DEBUG = ""; +SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb"; +MAX(id) +5 +SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'Qcache_hits'; +VARIABLE_VALUE = 1 +1 diff --git a/mysql-test/suite/galera/t/galera_query_cache_sync_wait-master.opt b/mysql-test/suite/galera/t/galera_query_cache_sync_wait-master.opt new file mode 100644 index 00000000000..a00258bc48c --- /dev/null +++ b/mysql-test/suite/galera/t/galera_query_cache_sync_wait-master.opt @@ -0,0 +1 @@ +--query_cache_type=1 diff --git a/mysql-test/suite/galera/t/galera_query_cache_sync_wait.test b/mysql-test/suite/galera/t/galera_query_cache_sync_wait.test new file mode 100644 index 00000000000..0634eba3264 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_query_cache_sync_wait.test @@ -0,0 +1,90 @@ +--source include/galera_cluster.inc +--source include/have_innodb.inc +--source include/have_debug_sync.inc +--source include/have_query_cache.inc + +CREATE TABLE t1 (id INT PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); + +--connection node_2 +--let $wsrep_provider_options_orig = `SELECT @@wsrep_provider_options` +SET GLOBAL wsrep_provider_options = "repl.causal_read_timeout=PT1S"; +SET GLOBAL DEBUG = "d,sync.wsrep_apply_cb"; +SET SESSION wsrep_sync_wait = 7; +SELECT MAX(id) FROM t1; # first lookup miss + +# +# Query cache hit, wait timeout +# + +--connection node_1 +INSERT INTO t1 VALUES (2); + +--connection node_2 +--error ER_LOCK_WAIT_TIMEOUT +SELECT MAX(id) FROM t1; +SET GLOBAL DEBUG = ""; +SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb"; + +FLUSH QUERY CACHE; +SET SESSION wsrep_sync_wait = 7; +SET GLOBAL DEBUG = "d,sync.wsrep_apply_cb"; + +# +# Query cache miss, wait timeout +# + +--connection node_1 +INSERT INTO t1 VALUES (3); + +--connection node_2 +--error ER_LOCK_WAIT_TIMEOUT +SELECT MAX(id) FROM t1; +SET GLOBAL DEBUG = ""; +SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb"; + +# +# Query cache miss +# + +--connection node_1 +INSERT INTO t1 VALUES (4); + +--connection node_2 +SET SESSION wsrep_sync_wait = 7; +SELECT MAX(id) FROM t1; +SET SESSION wsrep_sync_wait = 7; + +# +# Query cache hit +# + +FLUSH STATUS; +SELECT MAX(id) FROM t1; +SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'Qcache_hits'; +SET GLOBAL DEBUG = "d,sync.wsrep_apply_cb"; + +# +# Query cache invalidated +# + +--connection node_1 +INSERT INTO t1 VALUES (5); + +--connection node_2 +SET SESSION wsrep_sync_wait = 7; +--send SELECT MAX(id) FROM t1 + +--connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2 +--connection node_2a +SET GLOBAL DEBUG = ""; +SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb"; + +--connection node_2 +--reap +SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'Qcache_hits'; + + +--disable_query_log +--eval SET GLOBAL wsrep_provider_options = "$wsrep_provider_options_orig" +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/mysql-wsrep#201.test b/mysql-test/suite/galera/t/mysql-wsrep#201.test index cc842afb6d0..e9327540195 100644 --- a/mysql-test/suite/galera/t/mysql-wsrep#201.test +++ b/mysql-test/suite/galera/t/mysql-wsrep#201.test @@ -12,7 +12,7 @@ SET SESSION wsrep_sync_wait = 7; --disable_query_log ---let $count = 10000 +--let $count = 500 while ($count) { --connection node_1 diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc index 557d16d1312..32188a2a1fe 100644 --- a/sql/sql_cache.cc +++ b/sql/sql_cache.cc @@ -1804,7 +1804,6 @@ Query_cache::send_result_to_client(THD *thd, char *org_sql, uint query_length) goto err; } } - /* Try to obtain an exclusive lock on the query cache. If the cache is disabled or if a full cache flush is in progress, the attempt to @@ -1904,6 +1903,13 @@ def_week_frmt: %lu, in_trans: %d, autocommit: %d", (int)flags.autocommit)); memcpy((uchar *)(sql + (tot_length - QUERY_CACHE_FLAGS_SIZE)), (uchar*) &flags, QUERY_CACHE_FLAGS_SIZE); + +#ifdef WITH_WSREP + bool once_more; + once_more= true; +lookup: +#endif /* WITH_WSREP */ + query_block = (Query_cache_block *) my_hash_search(&queries, (uchar*) sql, tot_length); /* Quick abort on unlocked data */ @@ -1917,21 +1923,15 @@ def_week_frmt: %lu, in_trans: %d, autocommit: %d", DBUG_PRINT("qcache", ("Query in query hash 0x%lx", (ulong)query_block)); #ifdef WITH_WSREP - if (WSREP_CLIENT(thd) && wsrep_must_sync_wait(thd)) { + if (once_more && WSREP_CLIENT(thd) && wsrep_must_sync_wait(thd)) + { unlock(); if (wsrep_sync_wait(thd)) goto err; if (try_lock(TRUE)) goto err; - query_block = (Query_cache_block *) my_hash_search(&queries, - (uchar*) sql, - tot_length); - if (query_block == 0 || - query_block->query()->result() == 0 || - query_block->query()->result()->type != Query_cache_block::RESULT) - { - goto err_unlock; - } + once_more= false; + goto lookup; } #endif /* WITH_WSREP */ From 484bbd332f0876cd7df30122bcb339b62a64c871 Mon Sep 17 00:00:00 2001 From: Daniele Sciascia Date: Wed, 4 Nov 2015 09:36:01 +0100 Subject: [PATCH 03/61] refs codership/mysql-wsrep#201 Manually merged query cache fixes from 97c02faf0a39dd189eeda4f75fb35bc5db69d541. --- sql/log_event.cc | 20 +++++++++++++++++++- sql/sql_parse.cc | 6 ++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/sql/log_event.cc b/sql/log_event.cc index 5e9ee6136a9..a2fb263d2dd 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -8556,7 +8556,18 @@ int Rows_log_event::do_apply_event(Relay_log_info const *rli) const_cast(rli)->m_table_map.set_table(ptr->table_id, ptr->table); #ifdef HAVE_QUERY_CACHE - query_cache.invalidate_locked_for_write(thd, rli->tables_to_lock); +#ifdef WITH_WSREP + /* + Moved invalidation right before the call to rows_event_stmt_cleanup(), + to avoid query cache being polluted with stale entries. + */ + if (! (WSREP(thd) && (thd->wsrep_exec_mode == REPL_RECV))) + { +#endif /* WITH_WSREP */ + query_cache.invalidate_locked_for_write(thd, rli->tables_to_lock); +#ifdef WITH_WSREP + } +#endif /* WITH_WSREP */ #endif } @@ -8749,6 +8760,13 @@ int Rows_log_event::do_apply_event(Relay_log_info const *rli) DBUG_RETURN(error); } +#if defined(WITH_WSREP) && defined(HAVE_QUERY_CACHE) + if (get_flags(STMT_END_F) && + WSREP(thd) && thd->wsrep_exec_mode == REPL_RECV) + { + query_cache.invalidate_locked_for_write(thd, rli->tables_to_lock); + } +#endif /* WITH_WSREP */ if (get_flags(STMT_END_F) && (error= rows_event_stmt_cleanup(rli, thd))) slave_rows_error_report(ERROR_LEVEL, thd->is_error() ? 0 : error, diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index dc3c318f5e0..885a5a2f42a 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -6544,6 +6544,12 @@ void mysql_parse(THD *thd, char *rawbuf, uint length, thd->lex->sql_command= SQLCOM_SELECT; status_var_increment(thd->status_var.com_stat[SQLCOM_SELECT]); thd->update_stats(); +#ifdef WITH_WSREP + if (WSREP_CLIENT(thd)) + { + thd->wsrep_sync_wait_gtid = WSREP_GTID_UNDEFINED; + } +#endif /* WITH_WSREP */ } DBUG_VOID_RETURN; } From 652e4c1d3333ef0649a504995e39b5c0c664c5ff Mon Sep 17 00:00:00 2001 From: Nirbhay Choubey Date: Wed, 10 Feb 2016 17:29:28 -0500 Subject: [PATCH 04/61] Fix for a build failure. --- sql/sql_cache.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc index 32188a2a1fe..8794cdb2a45 100644 --- a/sql/sql_cache.cc +++ b/sql/sql_cache.cc @@ -1928,7 +1928,7 @@ lookup: unlock(); if (wsrep_sync_wait(thd)) goto err; - if (try_lock(TRUE)) + if (try_lock(thd, Query_cache::TIMEOUT)) goto err; once_more= false; goto lookup; From 8a93a7c0b0436a1b863c3b3cc165dca9a690a064 Mon Sep 17 00:00:00 2001 From: Teemu Ollakka Date: Wed, 4 Nov 2015 16:19:48 +0200 Subject: [PATCH 05/61] refs codership/mysql-wsrep#226 Limit binlog recovery to found wsrep position Limit binlog recovery so that the wsrep position found from storage engines is not exceeded. This is required to have consistent position between wsrep position stored in innodb header and recoverd binlog. --- sql/log.cc | 31 ++++++++++++++++++++++++++++++- sql/wsrep_mysqld.cc | 24 ++++++++++++++++++++++++ sql/wsrep_mysqld.h | 2 +- 3 files changed, 55 insertions(+), 2 deletions(-) diff --git a/sql/log.cc b/sql/log.cc index f9756e6c450..cf0c066c750 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -7701,6 +7701,22 @@ int TC_LOG_BINLOG::recover(IO_CACHE *log, Format_description_log_event *fdle) HASH xids; MEM_ROOT mem_root; +#ifdef WITH_WSREP + /* + Read current wsrep position from storage engines to have consistent + end position for binlog scan. + */ + wsrep_uuid_t uuid; + wsrep_seqno_t seqno; + wsrep_get_SE_checkpoint(uuid, seqno); + char uuid_str[40]; + wsrep_uuid_print(&uuid, uuid_str, sizeof(uuid_str)); + WSREP_INFO("Binlog recovery, found wsrep position %s:%lld", uuid_str, + (long long)seqno); + const wsrep_seqno_t last_xid_seqno= seqno; + wsrep_seqno_t cur_xid_seqno= WSREP_SEQNO_UNDEFINED; +#endif /* WITH_WSREP */ + if (! fdle->is_valid() || my_hash_init(&xids, &my_charset_bin, TC_LOG_PAGE_SIZE/3, 0, sizeof(my_xid), 0, 0, MYF(0))) @@ -7712,7 +7728,12 @@ int TC_LOG_BINLOG::recover(IO_CACHE *log, Format_description_log_event *fdle) while ((ev= Log_event::read_log_event(log, 0, fdle, opt_master_verify_checksum)) - && ev->is_valid()) + && ev->is_valid() +#ifdef WITH_WSREP + && (last_xid_seqno == WSREP_SEQNO_UNDEFINED || + last_xid_seqno != cur_xid_seqno) +#endif + ) { if (ev->get_type_code() == XID_EVENT) { @@ -7721,10 +7742,18 @@ int TC_LOG_BINLOG::recover(IO_CACHE *log, Format_description_log_event *fdle) sizeof(xev->xid)); if (!x || my_hash_insert(&xids, x)) goto err2; +#ifdef WITH_WSREP + cur_xid_seqno= xev->xid; +#endif /* WITH_WSREP */ } delete ev; } +#ifdef WITH_WSREP + WSREP_INFO("Binlog recovery scan stopped at Xid event %lld", + (long long)cur_xid_seqno); +#endif /* WITH_WSREP */ + if (ha_recover(&xids)) goto err2; diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc index 71cff536b72..48114fcba34 100644 --- a/sql/wsrep_mysqld.cc +++ b/sql/wsrep_mysqld.cc @@ -207,6 +207,30 @@ void wsrep_get_SE_checkpoint(XID* xid) plugin_foreach(NULL, get_SE_checkpoint, MYSQL_STORAGE_ENGINE_PLUGIN, xid); } +void wsrep_get_SE_checkpoint(wsrep_uuid_t& uuid, wsrep_seqno_t& seqno) +{ + uuid= WSREP_UUID_UNDEFINED; + seqno= WSREP_SEQNO_UNDEFINED; + + XID xid; + memset(&xid, 0, sizeof(xid)); + xid.formatID= -1; + + wsrep_get_SE_checkpoint(&xid); + + if (xid.formatID == -1) return; // nil XID + + if (!wsrep_is_wsrep_xid(&xid)) + { + WSREP_WARN("Read non-wsrep XID from storage engines."); + return; + } + + uuid= *wsrep_xid_uuid(&xid); + seqno= wsrep_xid_seqno(&xid); +} + + static wsrep_cb_status_t wsrep_view_handler_cb (void* app_ctx, void* recv_ctx, diff --git a/sql/wsrep_mysqld.h b/sql/wsrep_mysqld.h index f109211751d..3fb5189937e 100644 --- a/sql/wsrep_mysqld.h +++ b/sql/wsrep_mysqld.h @@ -316,7 +316,7 @@ 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&); void wsrep_xid_init(xid_t*, const wsrep_uuid_t*, wsrep_seqno_t); const wsrep_uuid_t* wsrep_xid_uuid(const xid_t*); wsrep_seqno_t wsrep_xid_seqno(const xid_t*); From bd1d2b90a77f31c7d982f18902a39a2cadce0cc3 Mon Sep 17 00:00:00 2001 From: Daniele Sciascia Date: Fri, 6 Nov 2015 10:50:21 +0100 Subject: [PATCH 06/61] refs codership/mysql-wsrep#201 Removes MTR tests. --- .../r/galera_query_cache_sync_wait.result | 45 ---------- .../suite/galera/r/mysql-wsrep#201.result | 4 - .../t/galera_query_cache_sync_wait-master.opt | 1 - .../t/galera_query_cache_sync_wait.test | 90 ------------------- .../suite/galera/t/mysql-wsrep#201-master.opt | 1 - .../suite/galera/t/mysql-wsrep#201.test | 33 ------- 6 files changed, 174 deletions(-) delete mode 100644 mysql-test/suite/galera/r/galera_query_cache_sync_wait.result delete mode 100644 mysql-test/suite/galera/r/mysql-wsrep#201.result delete mode 100644 mysql-test/suite/galera/t/galera_query_cache_sync_wait-master.opt delete mode 100644 mysql-test/suite/galera/t/galera_query_cache_sync_wait.test delete mode 100644 mysql-test/suite/galera/t/mysql-wsrep#201-master.opt delete mode 100644 mysql-test/suite/galera/t/mysql-wsrep#201.test diff --git a/mysql-test/suite/galera/r/galera_query_cache_sync_wait.result b/mysql-test/suite/galera/r/galera_query_cache_sync_wait.result deleted file mode 100644 index e9faff8be8b..00000000000 --- a/mysql-test/suite/galera/r/galera_query_cache_sync_wait.result +++ /dev/null @@ -1,45 +0,0 @@ -CREATE TABLE t1 (id INT PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB; -INSERT INTO t1 VALUES (1); -SET GLOBAL wsrep_provider_options = "repl.causal_read_timeout=PT1S"; -SET GLOBAL DEBUG = "d,sync.wsrep_apply_cb"; -SET SESSION wsrep_sync_wait = 7; -SELECT MAX(id) FROM t1; -MAX(id) -1 -INSERT INTO t1 VALUES (2); -SELECT MAX(id) FROM t1; -ERROR HY000: Lock wait timeout exceeded; try restarting transaction -SET GLOBAL DEBUG = ""; -SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb"; -FLUSH QUERY CACHE; -SET SESSION wsrep_sync_wait = 7; -SET GLOBAL DEBUG = "d,sync.wsrep_apply_cb"; -INSERT INTO t1 VALUES (3); -SELECT MAX(id) FROM t1; -ERROR HY000: Lock wait timeout exceeded; try restarting transaction -SET GLOBAL DEBUG = ""; -SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb"; -INSERT INTO t1 VALUES (4); -SET SESSION wsrep_sync_wait = 7; -SELECT MAX(id) FROM t1; -MAX(id) -4 -SET SESSION wsrep_sync_wait = 7; -FLUSH STATUS; -SELECT MAX(id) FROM t1; -MAX(id) -4 -SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'Qcache_hits'; -VARIABLE_VALUE = 1 -1 -SET GLOBAL DEBUG = "d,sync.wsrep_apply_cb"; -INSERT INTO t1 VALUES (5); -SET SESSION wsrep_sync_wait = 7; -SELECT MAX(id) FROM t1 ; -SET GLOBAL DEBUG = ""; -SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb"; -MAX(id) -5 -SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'Qcache_hits'; -VARIABLE_VALUE = 1 -1 diff --git a/mysql-test/suite/galera/r/mysql-wsrep#201.result b/mysql-test/suite/galera/r/mysql-wsrep#201.result deleted file mode 100644 index 1c0998e35ac..00000000000 --- a/mysql-test/suite/galera/r/mysql-wsrep#201.result +++ /dev/null @@ -1,4 +0,0 @@ -CREATE TABLE t1 (id INT PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB; -INSERT INTO t1 VALUES (DEFAULT); -SET GLOBAL query_cache_size=1355776; -SET SESSION wsrep_sync_wait = 7; diff --git a/mysql-test/suite/galera/t/galera_query_cache_sync_wait-master.opt b/mysql-test/suite/galera/t/galera_query_cache_sync_wait-master.opt deleted file mode 100644 index a00258bc48c..00000000000 --- a/mysql-test/suite/galera/t/galera_query_cache_sync_wait-master.opt +++ /dev/null @@ -1 +0,0 @@ ---query_cache_type=1 diff --git a/mysql-test/suite/galera/t/galera_query_cache_sync_wait.test b/mysql-test/suite/galera/t/galera_query_cache_sync_wait.test deleted file mode 100644 index 0634eba3264..00000000000 --- a/mysql-test/suite/galera/t/galera_query_cache_sync_wait.test +++ /dev/null @@ -1,90 +0,0 @@ ---source include/galera_cluster.inc ---source include/have_innodb.inc ---source include/have_debug_sync.inc ---source include/have_query_cache.inc - -CREATE TABLE t1 (id INT PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB; -INSERT INTO t1 VALUES (1); - ---connection node_2 ---let $wsrep_provider_options_orig = `SELECT @@wsrep_provider_options` -SET GLOBAL wsrep_provider_options = "repl.causal_read_timeout=PT1S"; -SET GLOBAL DEBUG = "d,sync.wsrep_apply_cb"; -SET SESSION wsrep_sync_wait = 7; -SELECT MAX(id) FROM t1; # first lookup miss - -# -# Query cache hit, wait timeout -# - ---connection node_1 -INSERT INTO t1 VALUES (2); - ---connection node_2 ---error ER_LOCK_WAIT_TIMEOUT -SELECT MAX(id) FROM t1; -SET GLOBAL DEBUG = ""; -SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb"; - -FLUSH QUERY CACHE; -SET SESSION wsrep_sync_wait = 7; -SET GLOBAL DEBUG = "d,sync.wsrep_apply_cb"; - -# -# Query cache miss, wait timeout -# - ---connection node_1 -INSERT INTO t1 VALUES (3); - ---connection node_2 ---error ER_LOCK_WAIT_TIMEOUT -SELECT MAX(id) FROM t1; -SET GLOBAL DEBUG = ""; -SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb"; - -# -# Query cache miss -# - ---connection node_1 -INSERT INTO t1 VALUES (4); - ---connection node_2 -SET SESSION wsrep_sync_wait = 7; -SELECT MAX(id) FROM t1; -SET SESSION wsrep_sync_wait = 7; - -# -# Query cache hit -# - -FLUSH STATUS; -SELECT MAX(id) FROM t1; -SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'Qcache_hits'; -SET GLOBAL DEBUG = "d,sync.wsrep_apply_cb"; - -# -# Query cache invalidated -# - ---connection node_1 -INSERT INTO t1 VALUES (5); - ---connection node_2 -SET SESSION wsrep_sync_wait = 7; ---send SELECT MAX(id) FROM t1 - ---connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2 ---connection node_2a -SET GLOBAL DEBUG = ""; -SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb"; - ---connection node_2 ---reap -SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'Qcache_hits'; - - ---disable_query_log ---eval SET GLOBAL wsrep_provider_options = "$wsrep_provider_options_orig" -DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/mysql-wsrep#201-master.opt b/mysql-test/suite/galera/t/mysql-wsrep#201-master.opt deleted file mode 100644 index a00258bc48c..00000000000 --- a/mysql-test/suite/galera/t/mysql-wsrep#201-master.opt +++ /dev/null @@ -1 +0,0 @@ ---query_cache_type=1 diff --git a/mysql-test/suite/galera/t/mysql-wsrep#201.test b/mysql-test/suite/galera/t/mysql-wsrep#201.test deleted file mode 100644 index e9327540195..00000000000 --- a/mysql-test/suite/galera/t/mysql-wsrep#201.test +++ /dev/null @@ -1,33 +0,0 @@ ---source include/galera_cluster.inc ---source include/have_innodb.inc ---source include/have_query_cache.inc - -CREATE TABLE t1 (id INT PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB; -INSERT INTO t1 VALUES (DEFAULT); - ---connection node_2 ---let $qcache_size_orig = `SELECT @@GLOBAL.query_cache_size` -SET GLOBAL query_cache_size=1355776; -SET SESSION wsrep_sync_wait = 7; - ---disable_query_log - ---let $count = 500 -while ($count) -{ - --connection node_1 - INSERT INTO t1 VALUES (DEFAULT); - --let $val1 = `SELECT LAST_INSERT_ID()` - --connection node_2 - --let $val2 = `SELECT MAX(id) FROM t1` - --let $val3 = `SELECT $val1 != $val2` - if ($val3) - { - --echo $val1 $val2 - --die wsrep_sync_wait failed - } - --dec $count -} - ---eval SET GLOBAL query_cache_size = $qcache_size_orig -DROP TABLE t1; From 1ce821b509cdce915d8dd76b1e080bd26fa2a296 Mon Sep 17 00:00:00 2001 From: sjaakola Date: Thu, 12 Nov 2015 10:33:04 +0200 Subject: [PATCH 07/61] Refs codership/mysql-wsrep#221 - disabling certain IB atomic builtins, which caused complete hangs --- storage/innobase/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/storage/innobase/CMakeLists.txt b/storage/innobase/CMakeLists.txt index cc494a7cd7a..603455196fc 100644 --- a/storage/innobase/CMakeLists.txt +++ b/storage/innobase/CMakeLists.txt @@ -119,12 +119,16 @@ IF(NOT CMAKE_CROSSCOMPILING) ENDIF() IF(HAVE_IB_GCC_ATOMIC_BUILTINS) +IF(NOT WITH_WSREP) ADD_DEFINITIONS(-DHAVE_IB_GCC_ATOMIC_BUILTINS=1) ENDIF() +ENDIF() IF(HAVE_IB_GCC_ATOMIC_TEST_AND_SET) +IF(NOT WITH_WSREP) ADD_DEFINITIONS(-DHAVE_IB_GCC_ATOMIC_TEST_AND_SET=1) ENDIF() +ENDIF() IF(HAVE_IB_GCC_SYNC_SYNCHRONISE) ADD_DEFINITIONS(-DHAVE_IB_GCC_SYNC_SYNCHRONISE=1) From 403a8bf8dfcf54bb24f7e376f43381c0d802810f Mon Sep 17 00:00:00 2001 From: Philip Stoev Date: Mon, 16 Nov 2015 04:07:08 -0800 Subject: [PATCH 08/61] Bump WSREP_PATCH_VERSION in cmake/wsrep.cmake to 13 --- cmake/wsrep.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/wsrep.cmake b/cmake/wsrep.cmake index 7740a4608f6..8c5d9ee5212 100644 --- a/cmake/wsrep.cmake +++ b/cmake/wsrep.cmake @@ -18,7 +18,7 @@ # so WSREP_VERSION is produced regardless # Set the patch version -SET(WSREP_PATCH_VERSION "12") +SET(WSREP_PATCH_VERSION "13") # MariaDB addition: Revision number of the last revision merged from # codership branch visible in @@visible_comment. From a6d0903764d316af98ec0462fd136fd1ca975a08 Mon Sep 17 00:00:00 2001 From: Philip Stoev Date: Mon, 11 Jan 2016 12:03:35 +0200 Subject: [PATCH 09/61] Bump WSREP_PATCH_VERSION in cmake/wsrep.cmake to 14 --- cmake/wsrep.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/wsrep.cmake b/cmake/wsrep.cmake index 8c5d9ee5212..7da525c9fea 100644 --- a/cmake/wsrep.cmake +++ b/cmake/wsrep.cmake @@ -18,7 +18,7 @@ # so WSREP_VERSION is produced regardless # Set the patch version -SET(WSREP_PATCH_VERSION "13") +SET(WSREP_PATCH_VERSION "14") # MariaDB addition: Revision number of the last revision merged from # codership branch visible in @@visible_comment. From b83de1151aab6dcc9f300159e31198364000de70 Mon Sep 17 00:00:00 2001 From: Nirbhay Choubey Date: Wed, 10 Feb 2016 18:04:08 -0500 Subject: [PATCH 10/61] Update WSREP_PATCH_REVNO. --- cmake/wsrep.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/wsrep.cmake b/cmake/wsrep.cmake index 7da525c9fea..6d92537e40f 100644 --- a/cmake/wsrep.cmake +++ b/cmake/wsrep.cmake @@ -23,7 +23,7 @@ SET(WSREP_PATCH_VERSION "14") # MariaDB addition: Revision number of the last revision merged from # codership branch visible in @@visible_comment. # Branch : https://github.com/codership/mysql-wsrep/tree/5.5 -SET(WSREP_PATCH_REVNO "4f81026") # Should be updated on every merge. +SET(WSREP_PATCH_REVNO "9949137") # Should be updated on every merge. # MariaDB: Obtain patch revision number: # Update WSREP_PATCH_REVNO if WSREP_REV environment variable is set. From 02259623b9e4902a1188d303297e557d893dac40 Mon Sep 17 00:00:00 2001 From: Nirbhay Choubey Date: Tue, 16 Feb 2016 17:14:11 -0500 Subject: [PATCH 11/61] Update global_suppressions for galera suite to include new warning. --- mysql-test/suite/galera/suite.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mysql-test/suite/galera/suite.pm b/mysql-test/suite/galera/suite.pm index 8fcc9cfa99e..fdaf64580c7 100644 --- a/mysql-test/suite/galera/suite.pm +++ b/mysql-test/suite/galera/suite.pm @@ -25,7 +25,8 @@ return "No my_print_defaults" unless $epath; push @::global_suppressions, ( qr(WSREP: wsrep_sst_receive_address is set to '127.0.0.1), - qr(WSREP: Could not open saved state file for reading: ), + qr(WSREP: Could not open saved state file for reading: .*), + qr(WSREP: Could not open state file for reading: .*), qr(WSREP: Gap in state sequence. Need state transfer.), qr(WSREP: Failed to prepare for incremental state transfer:), qr(WSREP:.*down context.*), From 3042d655e2c20dccf00fba6a64f72385330d2b7a Mon Sep 17 00:00:00 2001 From: Nirbhay Choubey Date: Wed, 17 Feb 2016 15:50:01 -0500 Subject: [PATCH 12/61] MDEV-9577: sys_vars.ignore_db_dirs_basic fails under Valgrind Ensure that the command line argument is of sufficient length before moving past the leading long option marker "--". --- sql/wsrep_check_opts.cc | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/sql/wsrep_check_opts.cc b/sql/wsrep_check_opts.cc index 75894061d3f..188f0696bff 100644 --- a/sql/wsrep_check_opts.cc +++ b/sql/wsrep_check_opts.cc @@ -151,7 +151,20 @@ find_opts (argv_copy& a, struct opt* const opts) { for (int i = 0; i < a.argc_; ++i) { - char* ptr = a.argv_[i] + 2; // we're interested only in long options + char *ptr; + + /* + We're interested only in long options, ensure that the arg is of + sufficient length. + */ + if (strlen(a.argv_[i]) > 2) + { + ptr= a.argv_[i] + 2; + } + else + { + continue; + } struct opt* opt = opts; for (; 0 != opt->name; ++opt) From 4bdf0258b6119e6464ed7846e7e4f866dd9f9ed9 Mon Sep 17 00:00:00 2001 From: sjaakola Date: Mon, 15 Feb 2016 23:33:55 +0200 Subject: [PATCH 13/61] refs MW-246 - skipping desync and resync before and after DDL execution in RSU mode, if wsrep_desync is set upfront --- sql/wsrep_mysqld.cc | 48 ++++++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc index 31a642e3624..e622389de7e 100644 --- a/sql/wsrep_mysqld.cc +++ b/sql/wsrep_mysqld.cc @@ -1303,16 +1303,19 @@ static int wsrep_RSU_begin(THD *thd, char *db_, char *table_) WSREP_DEBUG("RSU BEGIN: %lld, %d : %s", (long long)wsrep_thd_trx_seqno(thd), thd->wsrep_exec_mode, thd->query() ); - ret = wsrep->desync(wsrep); - if (ret != WSREP_OK) + if (!wsrep_desync) { - WSREP_WARN("RSU desync failed %d for schema: %s, query: %s", - ret, - (thd->db ? thd->db : "(null)"), - thd->query()); - my_error(ER_LOCK_DEADLOCK, MYF(0)); - return(ret); + ret = wsrep->desync(wsrep); + if (ret != WSREP_OK) + { + WSREP_WARN("RSU desync failed %d for schema: %s, query: %s", + ret, (thd->db ? thd->db : "(null)"), thd->query()); + my_error(ER_LOCK_DEADLOCK, MYF(0)); + return(ret); + } } + else + WSREP_DEBUG("RSU desync skipped: %d", wsrep_desync); mysql_mutex_lock(&LOCK_wsrep_replaying); wsrep_replaying++; mysql_mutex_unlock(&LOCK_wsrep_replaying); @@ -1327,13 +1330,14 @@ static int wsrep_RSU_begin(THD *thd, char *db_, char *table_) wsrep_replaying--; mysql_mutex_unlock(&LOCK_wsrep_replaying); - ret = wsrep->resync(wsrep); - if (ret != WSREP_OK) + if (!wsrep_desync) { - WSREP_WARN("resync failed %d for schema: %s, query: %s", - ret, - (thd->db ? thd->db : "(null)"), - thd->query()); + ret = wsrep->resync(wsrep); + if (ret != WSREP_OK) + { + WSREP_WARN("resync failed %d for schema: %s, query: %s", + ret, (thd->db ? thd->db : "(null)"), thd->query()); + } } my_error(ER_LOCK_DEADLOCK, MYF(0)); return(1); @@ -1370,14 +1374,18 @@ static void wsrep_RSU_end(THD *thd) (thd->db ? thd->db : "(null)"), thd->query()); } - ret = wsrep->resync(wsrep); - if (ret != WSREP_OK) + if (!wsrep_desync) { - WSREP_WARN("resync failed %d for schema: %s, query: %s", ret, - (thd->db ? thd->db : "(null)"), - thd->query()); - return; + ret = wsrep->resync(wsrep); + if (ret != WSREP_OK) + { + WSREP_WARN("resync failed %d for schema: %s, query: %s", ret, + (thd->db ? thd->db : "(null)"), thd->query()); + return; + } } + else + WSREP_DEBUG("RSU resync skipped: %d", wsrep_desync); thd->variables.wsrep_on = 1; } From 13627d49a90f3424ea1e61524841a789f08a0d3b Mon Sep 17 00:00:00 2001 From: sjaakola Date: Tue, 16 Feb 2016 11:55:03 +0200 Subject: [PATCH 14/61] refs MW-246 - created mtr test for testing explicit desyncing with RSU mode DDL --- .../suite/galera/r/mysql-wsrep#247.result | 11 +++++++++ .../suite/galera/t/mysql-wsrep#247.test | 23 +++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 mysql-test/suite/galera/r/mysql-wsrep#247.result create mode 100644 mysql-test/suite/galera/t/mysql-wsrep#247.test diff --git a/mysql-test/suite/galera/r/mysql-wsrep#247.result b/mysql-test/suite/galera/r/mysql-wsrep#247.result new file mode 100644 index 00000000000..1b00f511f03 --- /dev/null +++ b/mysql-test/suite/galera/r/mysql-wsrep#247.result @@ -0,0 +1,11 @@ +SET GLOBAL wsrep_desync=1; +SET wsrep_OSU_method=RSU; +CREATE TABLE t1 (i int primary key); +SHOW VARIABLES LIKE 'wsrep_desync'; +Variable_name Value +wsrep_desync ON +SET GLOBAL wsrep_desync=0; +DROP TABLE t1; +SHOW VARIABLES LIKE 'wsrep_desync'; +Variable_name Value +wsrep_desync OFF diff --git a/mysql-test/suite/galera/t/mysql-wsrep#247.test b/mysql-test/suite/galera/t/mysql-wsrep#247.test new file mode 100644 index 00000000000..a2db2f8e01c --- /dev/null +++ b/mysql-test/suite/galera/t/mysql-wsrep#247.test @@ -0,0 +1,23 @@ +# +# codership/mysql-wsrep/247 MW-246 - +# DDL with RSU fails if node is desynced upfont +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +--connection node_1 + +SET GLOBAL wsrep_desync=1; + +SET wsrep_OSU_method=RSU; + +CREATE TABLE t1 (i int primary key); + +SHOW VARIABLES LIKE 'wsrep_desync'; + +SET GLOBAL wsrep_desync=0; + +DROP TABLE t1; +SHOW VARIABLES LIKE 'wsrep_desync'; + From 2438afbfde58d6bdfd4c40e83a4732254a26afbb Mon Sep 17 00:00:00 2001 From: Philip Stoev Date: Tue, 16 Feb 2016 03:12:58 -0800 Subject: [PATCH 15/61] Galera MTR tests: MW-246 codership/mysql-wsrep#247 Additional tests around RSU and wsrep_desync --- .../galera/r/galera_rsu_wsrep_desync.result | 40 ++++++++++ .../galera/t/galera_rsu_wsrep_desync.test | 74 +++++++++++++++++++ 2 files changed, 114 insertions(+) create mode 100644 mysql-test/suite/galera/r/galera_rsu_wsrep_desync.result create mode 100644 mysql-test/suite/galera/t/galera_rsu_wsrep_desync.test diff --git a/mysql-test/suite/galera/r/galera_rsu_wsrep_desync.result b/mysql-test/suite/galera/r/galera_rsu_wsrep_desync.result new file mode 100644 index 00000000000..d160a632cd4 --- /dev/null +++ b/mysql-test/suite/galera/r/galera_rsu_wsrep_desync.result @@ -0,0 +1,40 @@ +CREATE TABLE t1 (f1 INTEGER) Engine=InnoDB; +SET GLOBAL wsrep_desync=1; +SET wsrep_OSU_method=RSU; +SET DEBUG_SYNC = 'alter_table_before_open_tables WAIT_FOR continue'; +ALTER TABLE t1 ADD COLUMN f2 INTEGER;; +SET GLOBAL wsrep_desync=0; +SET DEBUG_SYNC= 'now SIGNAL continue'; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) DEFAULT NULL, + `f2` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +SHOW VARIABLES LIKE 'wsrep_desync'; +Variable_name Value +wsrep_desync OFF +SET wsrep_OSU_method=TOI; +DROP TABLE t1; +CREATE TABLE t1 (f1 INTEGER) Engine=InnoDB; +SET GLOBAL wsrep_desync=0; +Warnings: +Warning 1231 'wsrep_desync' is already OFF. +SET wsrep_OSU_method=RSU; +SET DEBUG_SYNC = 'alter_table_before_open_tables WAIT_FOR continue'; +ALTER TABLE t1 ADD COLUMN f2 INTEGER;; +SET GLOBAL wsrep_desync=1; +ERROR HY000: Operation 'desync' failed for SET GLOBAL wsrep_desync=1 +SET GLOBAL wsrep_desync=0; +SET DEBUG_SYNC= 'now SIGNAL continue'; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) DEFAULT NULL, + `f2` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +SET wsrep_OSU_method=TOI; +DROP TABLE t1; +CALL mtr.add_suppression("Protocol violation"); +CALL mtr.add_suppression("desync failed"); +CALL mtr.add_suppression("Protocol violation"); diff --git a/mysql-test/suite/galera/t/galera_rsu_wsrep_desync.test b/mysql-test/suite/galera/t/galera_rsu_wsrep_desync.test new file mode 100644 index 00000000000..0aef7317d7a --- /dev/null +++ b/mysql-test/suite/galera/t/galera_rsu_wsrep_desync.test @@ -0,0 +1,74 @@ +# +# Test manipulating wsrep_desync while an RSU operation is in progress +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc +--source include/have_debug_sync.inc + +# First, test wsrep_desync 1 > 0 during DDL + +--connection node_1 +CREATE TABLE t1 (f1 INTEGER) Engine=InnoDB; + +SET GLOBAL wsrep_desync=1; +SET wsrep_OSU_method=RSU; + +SET DEBUG_SYNC = 'alter_table_before_open_tables WAIT_FOR continue'; +--send ALTER TABLE t1 ADD COLUMN f2 INTEGER; + +--connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1 +--connection node_1a + +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE = 'debug sync point: alter_table_before_open_tables' +--source include/wait_condition.inc + +SET GLOBAL wsrep_desync=0; +SET DEBUG_SYNC= 'now SIGNAL continue'; + +--connection node_1 +--reap + +SHOW CREATE TABLE t1; +SHOW VARIABLES LIKE 'wsrep_desync'; +SET wsrep_OSU_method=TOI; + +DROP TABLE t1; + +# Next, test wsrep_desync 0 > 1 during DDL, currently not allowed + +--connection node_1 +CREATE TABLE t1 (f1 INTEGER) Engine=InnoDB; + +SET GLOBAL wsrep_desync=0; +SET wsrep_OSU_method=RSU; + +SET DEBUG_SYNC = 'alter_table_before_open_tables WAIT_FOR continue'; +--send ALTER TABLE t1 ADD COLUMN f2 INTEGER; + +--connection node_1a + +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE = 'debug sync point: alter_table_before_open_tables' +--source include/wait_condition.inc + +# This transition is currently not allowed +--error ER_CANNOT_USER +SET GLOBAL wsrep_desync=1; +SET GLOBAL wsrep_desync=0; + +SET DEBUG_SYNC= 'now SIGNAL continue'; + +--connection node_1 +--reap + +SHOW CREATE TABLE t1; +SET wsrep_OSU_method=TOI; +DROP TABLE t1; + +CALL mtr.add_suppression("Protocol violation"); +CALL mtr.add_suppression("desync failed"); + +--connection node_2 +CALL mtr.add_suppression("Protocol violation"); + + From a6d93b20d7f3bdc2eef73a011db70cbd2179e52d Mon Sep 17 00:00:00 2001 From: Philip Stoev Date: Tue, 16 Feb 2016 23:42:42 -0800 Subject: [PATCH 16/61] Galera MTR Tests: MW-246 codership/mysql-wsrep#247 Stability fix for galera.mysql-wsrep#247.test --- mysql-test/suite/galera/t/mysql-wsrep#247.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/suite/galera/t/mysql-wsrep#247.test b/mysql-test/suite/galera/t/mysql-wsrep#247.test index a2db2f8e01c..8bcd58607a1 100644 --- a/mysql-test/suite/galera/t/mysql-wsrep#247.test +++ b/mysql-test/suite/galera/t/mysql-wsrep#247.test @@ -17,7 +17,7 @@ CREATE TABLE t1 (i int primary key); SHOW VARIABLES LIKE 'wsrep_desync'; SET GLOBAL wsrep_desync=0; - +--sleep 1 DROP TABLE t1; SHOW VARIABLES LIKE 'wsrep_desync'; From 17b5cb617263060f583382093a2e32adb0d7235f Mon Sep 17 00:00:00 2001 From: Nirbhay Choubey Date: Wed, 17 Feb 2016 22:56:38 -0500 Subject: [PATCH 17/61] codership/mysql-wsrep#247: Fix test case --- mysql-test/suite/galera/r/galera_rsu_wsrep_desync.result | 2 ++ mysql-test/suite/galera/t/galera_rsu_wsrep_desync.test | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/mysql-test/suite/galera/r/galera_rsu_wsrep_desync.result b/mysql-test/suite/galera/r/galera_rsu_wsrep_desync.result index d160a632cd4..62e327ffdee 100644 --- a/mysql-test/suite/galera/r/galera_rsu_wsrep_desync.result +++ b/mysql-test/suite/galera/r/galera_rsu_wsrep_desync.result @@ -16,6 +16,7 @@ Variable_name Value wsrep_desync OFF SET wsrep_OSU_method=TOI; DROP TABLE t1; +SET DEBUG_SYNC= 'RESET'; CREATE TABLE t1 (f1 INTEGER) Engine=InnoDB; SET GLOBAL wsrep_desync=0; Warnings: @@ -35,6 +36,7 @@ t1 CREATE TABLE `t1` ( ) ENGINE=InnoDB DEFAULT CHARSET=latin1 SET wsrep_OSU_method=TOI; DROP TABLE t1; +SET DEBUG_SYNC= 'RESET'; CALL mtr.add_suppression("Protocol violation"); CALL mtr.add_suppression("desync failed"); CALL mtr.add_suppression("Protocol violation"); diff --git a/mysql-test/suite/galera/t/galera_rsu_wsrep_desync.test b/mysql-test/suite/galera/t/galera_rsu_wsrep_desync.test index 0aef7317d7a..36ec8563cbe 100644 --- a/mysql-test/suite/galera/t/galera_rsu_wsrep_desync.test +++ b/mysql-test/suite/galera/t/galera_rsu_wsrep_desync.test @@ -34,6 +34,7 @@ SHOW VARIABLES LIKE 'wsrep_desync'; SET wsrep_OSU_method=TOI; DROP TABLE t1; +SET DEBUG_SYNC= 'RESET'; # Next, test wsrep_desync 0 > 1 during DDL, currently not allowed @@ -62,8 +63,11 @@ SET DEBUG_SYNC= 'now SIGNAL continue'; --reap SHOW CREATE TABLE t1; + +# Restore old state SET wsrep_OSU_method=TOI; DROP TABLE t1; +SET DEBUG_SYNC= 'RESET'; CALL mtr.add_suppression("Protocol violation"); CALL mtr.add_suppression("desync failed"); From d01328d73b65ec3c628646b1dd51a5d601ee74be Mon Sep 17 00:00:00 2001 From: Teemu Ollakka Date: Sun, 13 Sep 2015 18:57:20 +0300 Subject: [PATCH 18/61] Helpers to deal with galera dbug sync points. --- mysql-test/include/galera_clear_sync_point.inc | 1 + mysql-test/include/galera_set_sync_point.inc | 1 + mysql-test/include/galera_signal_sync_point.inc | 1 + mysql-test/include/galera_wait_sync_point.inc | 5 +++++ mysql-test/suite/galera/r/galera_ftwrl_drain.result | 2 ++ .../suite/galera/r/galera_transaction_replay.result | 2 ++ mysql-test/suite/galera/t/galera_ftwrl_drain.test | 11 ++++++----- .../suite/galera/t/galera_ist_restart_joiner.test | 4 +++- .../suite/galera/t/galera_transaction_replay.test | 10 +++++----- .../galera_3nodes/r/galera_ist_gcache_rollover.result | 2 +- .../galera_3nodes/t/galera_ist_gcache_rollover.test | 7 ++++--- 11 files changed, 31 insertions(+), 15 deletions(-) create mode 100644 mysql-test/include/galera_clear_sync_point.inc create mode 100644 mysql-test/include/galera_set_sync_point.inc create mode 100644 mysql-test/include/galera_signal_sync_point.inc create mode 100644 mysql-test/include/galera_wait_sync_point.inc diff --git a/mysql-test/include/galera_clear_sync_point.inc b/mysql-test/include/galera_clear_sync_point.inc new file mode 100644 index 00000000000..589522a55b0 --- /dev/null +++ b/mysql-test/include/galera_clear_sync_point.inc @@ -0,0 +1 @@ +SET GLOBAL wsrep_provider_options = 'dbug='; diff --git a/mysql-test/include/galera_set_sync_point.inc b/mysql-test/include/galera_set_sync_point.inc new file mode 100644 index 00000000000..5fe4e8c38c0 --- /dev/null +++ b/mysql-test/include/galera_set_sync_point.inc @@ -0,0 +1 @@ +--eval SET GLOBAL wsrep_provider_options = 'dbug=d,$galera_sync_point' diff --git a/mysql-test/include/galera_signal_sync_point.inc b/mysql-test/include/galera_signal_sync_point.inc new file mode 100644 index 00000000000..eaa5cdd43f5 --- /dev/null +++ b/mysql-test/include/galera_signal_sync_point.inc @@ -0,0 +1 @@ +--eval SET GLOBAL wsrep_provider_options = 'signal=$galera_sync_point' diff --git a/mysql-test/include/galera_wait_sync_point.inc b/mysql-test/include/galera_wait_sync_point.inc new file mode 100644 index 00000000000..f7019ae3a19 --- /dev/null +++ b/mysql-test/include/galera_wait_sync_point.inc @@ -0,0 +1,5 @@ +let $wait_timeout = 10; +SET SESSION wsrep_on = 0; +--let $wait_condition = SELECT 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_debug_sync_waiters' AND VARIABLE_VALUE = '$galera_sync_point' +--source include/wait_condition.inc +SET SESSION wsrep_on = 1; diff --git a/mysql-test/suite/galera/r/galera_ftwrl_drain.result b/mysql-test/suite/galera/r/galera_ftwrl_drain.result index a4879838d11..d704699925b 100644 --- a/mysql-test/suite/galera/r/galera_ftwrl_drain.result +++ b/mysql-test/suite/galera/r/galera_ftwrl_drain.result @@ -2,6 +2,8 @@ CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB; SET GLOBAL wsrep_provider_options = 'dbug=d,apply_monitor_slave_enter_sync'; INSERT INTO t1 VALUES (1); SET SESSION wsrep_sync_wait = 0; +SET SESSION wsrep_on = 0; +SET SESSION wsrep_on = 1; SELECT COUNT(*) = 0 FROM t1; COUNT(*) = 0 1 diff --git a/mysql-test/suite/galera/r/galera_transaction_replay.result b/mysql-test/suite/galera/r/galera_transaction_replay.result index 54ea8db699d..bfafa506fe6 100644 --- a/mysql-test/suite/galera/r/galera_transaction_replay.result +++ b/mysql-test/suite/galera/r/galera_transaction_replay.result @@ -10,6 +10,8 @@ f1 f2 SET GLOBAL wsrep_provider_options = 'dbug=d,commit_monitor_enter_sync'; COMMIT;; SET SESSION wsrep_sync_wait = 0; +SET SESSION wsrep_on = 0; +SET SESSION wsrep_on = 1; UPDATE t1 SET f2 = 'c' WHERE f1 = 2; SET GLOBAL wsrep_provider_options = 'dbug='; SET GLOBAL wsrep_provider_options = 'signal=commit_monitor_enter_sync'; diff --git a/mysql-test/suite/galera/t/galera_ftwrl_drain.test b/mysql-test/suite/galera/t/galera_ftwrl_drain.test index f022a9437c2..690e890cdea 100644 --- a/mysql-test/suite/galera/t/galera_ftwrl_drain.test +++ b/mysql-test/suite/galera/t/galera_ftwrl_drain.test @@ -18,7 +18,9 @@ CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB; --connection node_2 -SET GLOBAL wsrep_provider_options = 'dbug=d,apply_monitor_slave_enter_sync'; + +--let $galera_sync_point = apply_monitor_slave_enter_sync +--source include/galera_set_sync_point.inc --connection node_1 INSERT INTO t1 VALUES (1); @@ -27,8 +29,7 @@ INSERT INTO t1 VALUES (1); SET SESSION wsrep_sync_wait = 0; # Wait until applier has blocked ---let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_debug_sync_waiters' AND VARIABLE_VALUE = 'apply_monitor_slave_enter_sync' ---source include/wait_condition.inc +--source include/galera_wait_sync_point.inc SELECT COUNT(*) = 0 FROM t1; @@ -41,8 +42,8 @@ SELECT COUNT(*) = 0 FROM t1; --let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE = 'Init' AND INFO = 'FLUSH TABLES WITH READ LOCK' --source include/wait_condition.inc -SET GLOBAL wsrep_provider_options = 'dbug='; -SET GLOBAL wsrep_provider_options = 'signal=apply_monitor_slave_enter_sync'; +--source include/galera_clear_sync_point.inc +--source include/galera_signal_sync_point.inc --connection node_2a --reap diff --git a/mysql-test/suite/galera/t/galera_ist_restart_joiner.test b/mysql-test/suite/galera/t/galera_ist_restart_joiner.test index 69446f0f86a..eae28bdbcd7 100644 --- a/mysql-test/suite/galera/t/galera_ist_restart_joiner.test +++ b/mysql-test/suite/galera/t/galera_ist_restart_joiner.test @@ -27,7 +27,9 @@ UPDATE t1 SET f2 = 'c' WHERE f1 > 2; --connection node_2 # Make sure IST will block ... -SET GLOBAL wsrep_provider_options = 'dbug=d,recv_IST_after_apply_trx'; +--let $galera_sync_point = recv_IST_after_apply_trx +--source include/galera_set_sync_point.inc + SET SESSION wsrep_sync_wait = 0; diff --git a/mysql-test/suite/galera/t/galera_transaction_replay.test b/mysql-test/suite/galera/t/galera_transaction_replay.test index 632aa5cc0d5..bd5288a51c6 100644 --- a/mysql-test/suite/galera/t/galera_transaction_replay.test +++ b/mysql-test/suite/galera/t/galera_transaction_replay.test @@ -23,7 +23,8 @@ SELECT * FROM t1 WHERE f1 = 2 FOR UPDATE; # Block the commit --connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1 -SET GLOBAL wsrep_provider_options = 'dbug=d,commit_monitor_enter_sync'; +--let $galera_sync_point = commit_monitor_enter_sync +--source include/galera_set_sync_point.inc --connection node_1 --send COMMIT; @@ -31,8 +32,7 @@ SET GLOBAL wsrep_provider_options = 'dbug=d,commit_monitor_enter_sync'; # Wait until commit is blocked --connection node_1a SET SESSION wsrep_sync_wait = 0; ---let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_debug_sync_waiters' AND VARIABLE_VALUE = 'commit_monitor_enter_sync' ---source include/wait_condition.inc +--source include/galera_wait_sync_point.inc # Issue a conflicting update on node #2 --connection node_2 @@ -48,8 +48,8 @@ UPDATE t1 SET f2 = 'c' WHERE f1 = 2; # Unblock the commit --connection node_1a -SET GLOBAL wsrep_provider_options = 'dbug='; -SET GLOBAL wsrep_provider_options = 'signal=commit_monitor_enter_sync'; +--source include/galera_clear_sync_point.inc +--source include/galera_signal_sync_point.inc # Commit succeeds --connection node_1 diff --git a/mysql-test/suite/galera_3nodes/r/galera_ist_gcache_rollover.result b/mysql-test/suite/galera_3nodes/r/galera_ist_gcache_rollover.result index 1ecea5db5ab..6c66bf4a891 100644 --- a/mysql-test/suite/galera_3nodes/r/galera_ist_gcache_rollover.result +++ b/mysql-test/suite/galera_3nodes/r/galera_ist_gcache_rollover.result @@ -16,8 +16,8 @@ CREATE TABLE t2 (f1 LONGTEXT); INSERT INTO t2 VALUES (REPEAT('x', 512 * 1024)); INSERT INTO t2 VALUES (REPEAT('x', 512 * 1024)); INSERT INTO t2 VALUES (REPEAT('x', 512 * 1024)); -SET GLOBAL wsrep_provider_options = 'signal=ist_sender_send_after_get_buffers'; SET GLOBAL wsrep_provider_options = 'dbug='; +SET GLOBAL wsrep_provider_options = 'signal=ist_sender_send_after_get_buffers'; INSERT INTO t1 VALUES (51), (52), (53), (54), (55); SELECT COUNT(*) = 30 FROM t1; COUNT(*) = 30 diff --git a/mysql-test/suite/galera_3nodes/t/galera_ist_gcache_rollover.test b/mysql-test/suite/galera_3nodes/t/galera_ist_gcache_rollover.test index 0668c246624..7d8bbb39e35 100644 --- a/mysql-test/suite/galera_3nodes/t/galera_ist_gcache_rollover.test +++ b/mysql-test/suite/galera_3nodes/t/galera_ist_gcache_rollover.test @@ -38,7 +38,8 @@ INSERT INTO t1 VALUES (11), (12), (13), (14), (15); INSERT INTO t1 VALUES (21), (22), (23), (24), (25); # Make sure IST will block ... -SET GLOBAL wsrep_provider_options = 'dbug=d,ist_sender_send_after_get_buffers'; +--let $galera_sync_point = ist_sender_send_after_get_buffers +--source include/galera_set_sync_point.inc # ... and restart providers to force IST --connection node_2 @@ -70,8 +71,8 @@ INSERT INTO t2 VALUES (REPEAT('x', 512 * 1024)); INSERT INTO t2 VALUES (REPEAT('x', 512 * 1024)); # Unlock IST and wait for it to complete -SET GLOBAL wsrep_provider_options = 'signal=ist_sender_send_after_get_buffers'; -SET GLOBAL wsrep_provider_options = 'dbug='; +--source include/galera_clear_sync_point.inc +--source include/galera_signal_sync_point.inc INSERT INTO t1 VALUES (51), (52), (53), (54), (55); From 2f870f53767f225fa20a7b04d5f16712370904c8 Mon Sep 17 00:00:00 2001 From: Teemu Ollakka Date: Tue, 15 Sep 2015 13:20:55 +0300 Subject: [PATCH 19/61] Restore original value of wsrep_on after waiting for sync point. --- mysql-test/include/galera_wait_sync_point.inc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mysql-test/include/galera_wait_sync_point.inc b/mysql-test/include/galera_wait_sync_point.inc index f7019ae3a19..cf3a4980186 100644 --- a/mysql-test/include/galera_wait_sync_point.inc +++ b/mysql-test/include/galera_wait_sync_point.inc @@ -1,5 +1,6 @@ -let $wait_timeout = 10; +--let $wait_timeout = 10 +--let $wsrep_on_orig = `SELECT @@wsrep_on` SET SESSION wsrep_on = 0; --let $wait_condition = SELECT 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_debug_sync_waiters' AND VARIABLE_VALUE = '$galera_sync_point' --source include/wait_condition.inc -SET SESSION wsrep_on = 1; +--eval SET SESSION wsrep_on = $wsrep_on_orig From 7ce84cf76433849959deff9255294d797319f64e Mon Sep 17 00:00:00 2001 From: Philip Stoev Date: Tue, 29 Sep 2015 23:29:54 -0700 Subject: [PATCH 20/61] Galera MTR Tests: stability fixes Conflicts: mysql-test/include/mtr_check.sql mysql-test/suite/galera/r/galera_log_bin.result mysql-test/suite/galera/t/galera_log_bin.test --- mysql-test/include/mtr_check.sql | 5 +++ .../suite/galera/r/galera_log_bin.result | 37 ++++++++++--------- .../r/galera_sst_mysqldump_with_key.result | 2 + mysql-test/suite/galera/t/galera_log_bin.test | 7 +++- .../t/galera_sst_mysqldump_with_key.test | 7 ++++ 5 files changed, 38 insertions(+), 20 deletions(-) diff --git a/mysql-test/include/mtr_check.sql b/mysql-test/include/mtr_check.sql index edc15850d97..6e3908aa841 100644 --- a/mysql-test/include/mtr_check.sql +++ b/mysql-test/include/mtr_check.sql @@ -41,6 +41,11 @@ BEGIN -- except those that was created during bootstrap SELECT * FROM INFORMATION_SCHEMA.SCHEMATA; + -- and the mtr_wsrep_notify schema which is populated by the std_data/wsrep_notify.sh script + -- and the suite/galera/t/galera_var_notify_cmd.test + -- and the wsrep_schema schema that may be created by Galera + SELECT * FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME NOT IN ('mtr_wsrep_notify', 'wsrep_schema'); + -- The test database should not contain any tables SELECT table_name AS tables_in_test FROM INFORMATION_SCHEMA.TABLES WHERE table_schema='test'; diff --git a/mysql-test/suite/galera/r/galera_log_bin.result b/mysql-test/suite/galera/r/galera_log_bin.result index 845326e6912..7243ff21722 100644 --- a/mysql-test/suite/galera/r/galera_log_bin.result +++ b/mysql-test/suite/galera/r/galera_log_bin.result @@ -16,19 +16,19 @@ Log_name Pos Event_type Server_id End_log_pos Info mysqld-bin.000002 353 Gtid 1 391 GTID 0-1-1 mysqld-bin.000002 391 Query 1 504 use `test`; CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB mysqld-bin.000002 504 Gtid 1 542 BEGIN GTID 0-1-2 -mysqld-bin.000002 542 Table_map 1 583 table_id: 100 (test.t1) -mysqld-bin.000002 583 Write_rows_v1 1 617 table_id: 100 flags: STMT_END_F -mysqld-bin.000002 617 Xid 1 644 COMMIT /* xid=2 */ +mysqld-bin.000002 542 Table_map 1 583 table_id: # (test.t1) +mysqld-bin.000002 583 Write_rows_v1 1 617 table_id: # flags: STMT_END_F +mysqld-bin.000002 617 Xid 1 644 COMMIT /* xid=# */ mysqld-bin.000002 644 Gtid 1 682 GTID 0-1-3 mysqld-bin.000002 682 Query 1 783 use `test`; CREATE TABLE t2 (id INT) ENGINE=InnoDB mysqld-bin.000002 783 Gtid 1 821 BEGIN GTID 0-1-4 -mysqld-bin.000002 821 Table_map 1 862 table_id: 101 (test.t2) -mysqld-bin.000002 862 Write_rows_v1 1 896 table_id: 101 flags: STMT_END_F -mysqld-bin.000002 896 Xid 1 923 COMMIT /* xid=4 */ +mysqld-bin.000002 821 Table_map 1 862 table_id: # (test.t2) +mysqld-bin.000002 862 Write_rows_v1 1 896 table_id: # flags: STMT_END_F +mysqld-bin.000002 896 Xid 1 923 COMMIT /* xid=# */ mysqld-bin.000002 923 Gtid 1 961 BEGIN GTID 0-1-5 -mysqld-bin.000002 961 Table_map 1 1002 table_id: 101 (test.t2) -mysqld-bin.000002 1002 Write_rows_v1 1 1036 table_id: 101 flags: STMT_END_F -mysqld-bin.000002 1036 Xid 1 1063 COMMIT /* xid=5 */ +mysqld-bin.000002 961 Table_map 1 1002 table_id: # (test.t2) +mysqld-bin.000002 1002 Write_rows_v1 1 1036 table_id: # flags: STMT_END_F +mysqld-bin.000002 1036 Xid 1 1063 COMMIT /* xid=# */ mysqld-bin.000002 1063 Gtid 1 1101 GTID 0-1-6 mysqld-bin.000002 1101 Query 1 1200 use `test`; ALTER TABLE t1 ADD COLUMN f2 INTEGER SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; @@ -39,20 +39,21 @@ Log_name Pos Event_type Server_id End_log_pos Info mysqld-bin.000003 313 Gtid 1 351 GTID 0-1-1 mysqld-bin.000003 351 Query 1 464 use `test`; CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB mysqld-bin.000003 464 Gtid 1 502 BEGIN GTID 0-1-2 -mysqld-bin.000003 502 Table_map 1 543 table_id: 82 (test.t1) -mysqld-bin.000003 543 Write_rows_v1 1 577 table_id: 82 flags: STMT_END_F -mysqld-bin.000003 577 Xid 1 604 COMMIT /* xid=2 */ +mysqld-bin.000003 502 Table_map 1 543 table_id: # (test.t1) +mysqld-bin.000003 543 Write_rows_v1 1 577 table_id: # flags: STMT_END_F +mysqld-bin.000003 577 Xid 1 604 COMMIT /* xid=# */ mysqld-bin.000003 604 Gtid 1 642 GTID 0-1-3 mysqld-bin.000003 642 Query 1 743 use `test`; CREATE TABLE t2 (id INT) ENGINE=InnoDB mysqld-bin.000003 743 Gtid 1 781 BEGIN GTID 0-1-4 -mysqld-bin.000003 781 Table_map 1 822 table_id: 83 (test.t2) -mysqld-bin.000003 822 Write_rows_v1 1 856 table_id: 83 flags: STMT_END_F -mysqld-bin.000003 856 Xid 1 883 COMMIT /* xid=4 */ +mysqld-bin.000003 781 Table_map 1 822 table_id: # (test.t2) +mysqld-bin.000003 822 Write_rows_v1 1 856 table_id: # flags: STMT_END_F +mysqld-bin.000003 856 Xid 1 883 COMMIT /* xid=# */ mysqld-bin.000003 883 Gtid 1 921 BEGIN GTID 0-1-5 -mysqld-bin.000003 921 Table_map 1 962 table_id: 83 (test.t2) -mysqld-bin.000003 962 Write_rows_v1 1 996 table_id: 83 flags: STMT_END_F -mysqld-bin.000003 996 Xid 1 1023 COMMIT /* xid=5 */ +mysqld-bin.000003 921 Table_map 1 962 table_id: # (test.t2) +mysqld-bin.000003 962 Write_rows_v1 1 996 table_id: # flags: STMT_END_F +mysqld-bin.000003 996 Xid 1 1023 COMMIT /* xid=# */ mysqld-bin.000003 1023 Gtid 1 1061 GTID 0-1-6 mysqld-bin.000003 1061 Query 1 1160 use `test`; ALTER TABLE t1 ADD COLUMN f2 INTEGER DROP TABLE t1; DROP TABLE t2; +RESET MASTER; diff --git a/mysql-test/suite/galera/r/galera_sst_mysqldump_with_key.result b/mysql-test/suite/galera/r/galera_sst_mysqldump_with_key.result index 93557cc91d4..7d30b356aa9 100644 --- a/mysql-test/suite/galera/r/galera_sst_mysqldump_with_key.result +++ b/mysql-test/suite/galera/r/galera_sst_mysqldump_with_key.result @@ -104,3 +104,5 @@ CALL mtr.add_suppression("Can't open and lock privilege tables"); CALL mtr.add_suppression("Info table is not ready to be used"); CALL mtr.add_suppression("Native table .* has the wrong structure"); DROP USER sslsst; +SET GLOBAL general_log = ON; +SET GLOBAL slow_query_log = ON; diff --git a/mysql-test/suite/galera/t/galera_log_bin.test b/mysql-test/suite/galera/t/galera_log_bin.test index 7d592d63ee3..b0f215c85e5 100644 --- a/mysql-test/suite/galera/t/galera_log_bin.test +++ b/mysql-test/suite/galera/t/galera_log_bin.test @@ -22,15 +22,18 @@ SELECT COUNT(*) = 2 FROM t2; ALTER TABLE t1 ADD COLUMN f2 INTEGER; FLUSH LOGS; -# Use pos 120 in order to skip the header that contains the MySQL version number. -# Otherwise, version number changes will cause the test to break + +--replace_regex /table_id: [0-9]+/table_id: #/ /xid=[0-9]+/xid=#/ SHOW BINLOG EVENTS IN 'mysqld-bin.000002' LIMIT 4,18; --connection node_2 SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; +--replace_regex /table_id: [0-9]+/table_id: #/ /xid=[0-9]+/xid=#/ SHOW BINLOG EVENTS IN 'mysqld-bin.000003' LIMIT 3,19; DROP TABLE t1; DROP TABLE t2; +--connection node_1 +RESET MASTER; diff --git a/mysql-test/suite/galera/t/galera_sst_mysqldump_with_key.test b/mysql-test/suite/galera/t/galera_sst_mysqldump_with_key.test index 0b3edeb75ff..c813e04169f 100644 --- a/mysql-test/suite/galera/t/galera_sst_mysqldump_with_key.test +++ b/mysql-test/suite/galera/t/galera_sst_mysqldump_with_key.test @@ -20,3 +20,10 @@ SET GLOBAL wsrep_sst_auth = 'sslsst:'; --source suite/galera/include/galera_sst_restore.inc DROP USER sslsst; + +--connection node_2 +# We have to manually restore global_log and slow_query_log due to mysql-wsrep#108 +# Otherwise MTR's check_testcases complains + +SET GLOBAL general_log = ON; +SET GLOBAL slow_query_log = ON; From 00b058aca3ab48e15c056d689ced936b8c71ea64 Mon Sep 17 00:00:00 2001 From: Teemu Ollakka Date: Thu, 1 Oct 2015 17:05:48 +0300 Subject: [PATCH 21/61] refs codership/mysql-wsrep#202 Added schema info into wsrep messages Added schema info to wsrep messages above debug level. --- sql/sp.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sql/sp.cc b/sql/sp.cc index 4a0e890e0cb..c247101ca7f 100644 --- a/sql/sp.cc +++ b/sql/sp.cc @@ -2301,11 +2301,11 @@ int wsrep_create_sp(THD *thd, uchar** buf, size_t* buf_len) sp->m_chistics, &(thd->lex->definer->user), &(thd->lex->definer->host), saved_mode)) - { - WSREP_WARN("SP create string failed: schema: %s, query: %s", - (thd->db ? thd->db : "(null)"), thd->query()); - return 1; - } + { + WSREP_WARN("SP create string failed: schema: %s, query: %s", + (thd->db ? thd->db : "(null)"), thd->query()); + return 1; + } return wsrep_to_buf_helper(thd, log_query.ptr(), log_query.length(), buf, buf_len); } #endif /* WITH_WSREP */ From 0ec457b0de083e45b815a04f4f6de0bcc002ffc6 Mon Sep 17 00:00:00 2001 From: Daniele Sciascia Date: Fri, 2 Oct 2015 10:16:55 +0200 Subject: [PATCH 22/61] refs codership/galera#308 - Moves call wsrep_free_status() to THD::cleanup_after_query(). Wsrep status variables were previously freed only on SHOW STATUS. - Removes valgrind suppression from mysql-test/valgrind. --- mysql-test/valgrind.supp | 22 ---------------------- sql/sql_class.cc | 4 ++++ sql/sql_parse.cc | 3 --- 3 files changed, 4 insertions(+), 25 deletions(-) diff --git a/mysql-test/valgrind.supp b/mysql-test/valgrind.supp index 09f5514f3b3..b0c6533df0b 100644 --- a/mysql-test/valgrind.supp +++ b/mysql-test/valgrind.supp @@ -1283,28 +1283,6 @@ fun:dlopen@@GLIBC_2.2.5 } -{ - GitHub codership/galera#308 - Memcheck:Leak - match-leak-kinds: definite - fun:malloc - fun:_ZNK6galera13ReplicatorSMM9stats_getEv - fun:_ZL28export_wsrep_status_to_mysqlP3THD - fun:_Z17wsrep_show_statusP3THDP17st_mysql_show_varPc - fun:_ZL17show_status_arrayP3THDPKcP17st_mysql_show_var13enum_var_typeP17system_status_varS2_P5TABLEbP4Item - fun:_Z11fill_statusP3THDP10TABLE_LISTP4Item - fun:_ZL13do_fill_tableP3THDP10TABLE_LISTP13st_join_table - fun:_Z24get_schema_tables_resultP4JOIN23enum_schema_table_state - fun:_ZN4JOIN14prepare_resultEPP4ListI4ItemE - fun:_ZN4JOIN4execEv - fun:_ZL20mysql_execute_selectP3THDP13st_select_lexb - fun:_Z12mysql_selectP3THDP10TABLE_LISTjR4ListI4ItemEPS4_P10SQL_I_ListI8st_orderESB_S7_yP13select_resultP18st_select_lex_unitP13st_select_lex - fun:_Z13handle_selectP3THDP13select_resultm - fun:_ZL21execute_sqlcom_selectP3THDP10TABLE_LIST - fun:_Z21mysql_execute_commandP3THD - fun:_Z11mysql_parseP3THDPcjP12Parser_state -} - { GitHub codership/mysql-wsrep#176 Memcheck:Leak diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 6c7282c3505..5534cdde596 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -2361,6 +2361,10 @@ void THD::cleanup_after_query() rgi_slave->cleanup_after_query(); #endif +#ifdef WITH_WSREP + wsrep_free_status(this); +#endif /* WITH_WSREP */ + DBUG_VOID_RETURN; } diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 802721901a8..99a1af749f9 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2774,9 +2774,6 @@ mysql_execute_command(THD *thd) case SQLCOM_SHOW_STATUS: { execute_show_status(thd, all_tables); -#ifdef WITH_WSREP - wsrep_free_status(thd); -#endif /* WITH_WSREP */ break; } case SQLCOM_SHOW_EXPLAIN: From c0dac420e5d5cfd14d1f6fea12288da4d29617ca Mon Sep 17 00:00:00 2001 From: Daniele Sciascia Date: Mon, 5 Oct 2015 09:42:03 +0200 Subject: [PATCH 23/61] refs codership/mysql-wsrep#31 - Removes useless call to wsrep_xid_init() in wsrep_apply_events(). Transaction's xid is already initialized at that point. - Adds call to wsrep_set_SE_checkpoint() for committing TOI events in the applier side. - Includes test case that reproduced the issue. --- .../suite/galera/r/mysql-wsrep#31.result | 10 +++++ mysql-test/suite/galera/t/mysql-wsrep#31.test | 39 +++++++++++++++++++ sql/wsrep_applier.cc | 19 +++++---- 3 files changed, 58 insertions(+), 10 deletions(-) create mode 100644 mysql-test/suite/galera/r/mysql-wsrep#31.result create mode 100644 mysql-test/suite/galera/t/mysql-wsrep#31.test diff --git a/mysql-test/suite/galera/r/mysql-wsrep#31.result b/mysql-test/suite/galera/r/mysql-wsrep#31.result new file mode 100644 index 00000000000..a21bb3eccfd --- /dev/null +++ b/mysql-test/suite/galera/r/mysql-wsrep#31.result @@ -0,0 +1,10 @@ +CREATE TABLE t1 (f1 CHAR(255)) ENGINE=InnoDB; +INSERT INTO t1 VALUES('test'); +CREATE DATABASE db; +Shutting down server 2 ... +Recovering server 2 ... +Performing --wsrep-recover ... +Restarting server ... +Using --wsrep-start-position when starting mysqld ... +DROP TABLE t1; +DROP DATABASE db; diff --git a/mysql-test/suite/galera/t/mysql-wsrep#31.test b/mysql-test/suite/galera/t/mysql-wsrep#31.test new file mode 100644 index 00000000000..b6b6d1ebb4d --- /dev/null +++ b/mysql-test/suite/galera/t/mysql-wsrep#31.test @@ -0,0 +1,39 @@ +--source include/galera_cluster.inc +--source include/have_innodb.inc + +--connection node_1 + +CREATE TABLE t1 (f1 CHAR(255)) ENGINE=InnoDB; +INSERT INTO t1 VALUES('test'); +CREATE DATABASE db; + +--connection node_2 +--let $expected_position_uuid = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_uuid'` +--let $expected_position_seqno = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` + +--let $expected_position = $expected_position_uuid:$expected_position_seqno + +--echo Shutting down server 2 ... +--source include/shutdown_mysqld.inc + +--echo Recovering server 2 ... +--let $galera_wsrep_recover_server_id=2 +--source suite/galera/include/galera_wsrep_recover.inc + +if ($galera_wsrep_start_position != $expected_position) +{ + die(Expected position: $expected_position, found $galera_wsrep_start_position); +} + +--echo Restarting server ... +--source include/start_mysqld.inc + +--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size' +--source include/wait_condition.inc +--source include/galera_wait_ready.inc + +--connection node_1 +DROP TABLE t1; +DROP DATABASE db; + + diff --git a/sql/wsrep_applier.cc b/sql/wsrep_applier.cc index 4d95b38a371..5cfc9981342 100644 --- a/sql/wsrep_applier.cc +++ b/sql/wsrep_applier.cc @@ -150,9 +150,6 @@ static wsrep_cb_status_t wsrep_apply_events(THD* thd, /* Use the original server id for logging. */ thd->set_server_id(ev->server_id); thd->set_time(); // time the query - wsrep_xid_init(&thd->transaction.xid_state.xid, - thd->wsrep_trx_meta.gtid.uuid, - thd->wsrep_trx_meta.gtid.seqno); thd->lex->current_select= 0; if (!ev->when) { @@ -281,8 +278,7 @@ wsrep_cb_status_t wsrep_apply_cb(void* const ctx, return rcode; } -static wsrep_cb_status_t wsrep_commit(THD* const thd, - wsrep_seqno_t const global_seqno) +static wsrep_cb_status_t wsrep_commit(THD* const thd) { #ifdef WSREP_PROC_INFO snprintf(thd->wsrep_info, sizeof(thd->wsrep_info) - 1, @@ -301,7 +297,11 @@ static wsrep_cb_status_t wsrep_commit(THD* const thd, #ifdef GTID_SUPPORT thd->variables.gtid_next.set_automatic(); #endif /* GTID_SUPPORT */ - // TODO: mark snapshot with global_seqno. + if (thd->wsrep_apply_toi) + { + wsrep_set_SE_checkpoint(thd->wsrep_trx_meta.gtid.uuid, + thd->wsrep_trx_meta.gtid.seqno); + } } #ifdef WSREP_PROC_INFO @@ -315,8 +315,7 @@ static wsrep_cb_status_t wsrep_commit(THD* const thd, return rcode; } -static wsrep_cb_status_t wsrep_rollback(THD* const thd, - wsrep_seqno_t const global_seqno) +static wsrep_cb_status_t wsrep_rollback(THD* const thd) { #ifdef WSREP_PROC_INFO snprintf(thd->wsrep_info, sizeof(thd->wsrep_info) - 1, @@ -353,9 +352,9 @@ wsrep_cb_status_t wsrep_commit_cb(void* const ctx, wsrep_cb_status_t rcode; if (commit) - rcode = wsrep_commit(thd, meta->gtid.seqno); + rcode = wsrep_commit(thd); else - rcode = wsrep_rollback(thd, meta->gtid.seqno); + rcode = wsrep_rollback(thd); wsrep_set_apply_format(thd, NULL); thd->mdl_context.release_transactional_locks(); From 267d429b5a0628e73fdbd95d1934e093adcdb296 Mon Sep 17 00:00:00 2001 From: Daniele Sciascia Date: Mon, 5 Oct 2015 11:01:04 +0200 Subject: [PATCH 24/61] refs codership/mysql-wsrep#31 - Erronously removed call to wsrep_xid_init() in previous commit. --- sql/wsrep_applier.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sql/wsrep_applier.cc b/sql/wsrep_applier.cc index 5cfc9981342..520e63f3077 100644 --- a/sql/wsrep_applier.cc +++ b/sql/wsrep_applier.cc @@ -150,6 +150,9 @@ static wsrep_cb_status_t wsrep_apply_events(THD* thd, /* Use the original server id for logging. */ thd->set_server_id(ev->server_id); thd->set_time(); // time the query + wsrep_xid_init(&thd->transaction.xid_state.xid, + thd->wsrep_trx_meta.gtid.uuid, + thd->wsrep_trx_meta.gtid.seqno); thd->lex->current_select= 0; if (!ev->when) { From 1d2167685328200a5112aebd05c7232c625c1f09 Mon Sep 17 00:00:00 2001 From: Daniele Sciascia Date: Thu, 15 Oct 2015 15:13:29 +0200 Subject: [PATCH 25/61] refs codership/mysql-wsrep#184 Fixes a deadlock between applier and its victim transaction. The deadlock would manifest when a BF victim was waiting for some lock and was signaled to rollback, and the same time its wait timeout expired. In such cases the victim would return from lock_wait_suspend_thread() with error DB_LOCK_WAIT_TIMEOUT, as opposed to DB_DEADLOCK. As a result only the last statement of the victim would rollback, and eventually it would deadlock with the applier. --- storage/innobase/lock/lock0wait.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/storage/innobase/lock/lock0wait.cc b/storage/innobase/lock/lock0wait.cc index 579b95a5ebd..29dfffcd496 100644 --- a/storage/innobase/lock/lock0wait.cc +++ b/storage/innobase/lock/lock0wait.cc @@ -394,7 +394,8 @@ lock_wait_suspend_thread( if (lock_wait_timeout < 100000000 && wait_time > (double) lock_wait_timeout) { #ifdef WITH_WSREP - if (!wsrep_is_BF_lock_timeout(trx)) { + if (!wsrep_is_BF_lock_timeout(trx) + && trx->error_state != DB_DEADLOCK) { #endif /* WITH_WSREP */ trx->error_state = DB_LOCK_WAIT_TIMEOUT; From 2c56142b770d9f8db24cc286ee768cc3edbfdd56 Mon Sep 17 00:00:00 2001 From: Nirbhay Choubey Date: Mon, 22 Feb 2016 16:36:05 -0500 Subject: [PATCH 26/61] refs codership/mysql-wsrep#184 Merge fix to XtraDB engine. --- storage/xtradb/lock/lock0wait.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/storage/xtradb/lock/lock0wait.cc b/storage/xtradb/lock/lock0wait.cc index 579b95a5ebd..29dfffcd496 100644 --- a/storage/xtradb/lock/lock0wait.cc +++ b/storage/xtradb/lock/lock0wait.cc @@ -394,7 +394,8 @@ lock_wait_suspend_thread( if (lock_wait_timeout < 100000000 && wait_time > (double) lock_wait_timeout) { #ifdef WITH_WSREP - if (!wsrep_is_BF_lock_timeout(trx)) { + if (!wsrep_is_BF_lock_timeout(trx) + && trx->error_state != DB_DEADLOCK) { #endif /* WITH_WSREP */ trx->error_state = DB_LOCK_WAIT_TIMEOUT; From 8c89e843db9e324ee5ad7607ef7e6dacee42b546 Mon Sep 17 00:00:00 2001 From: Daniele Sciascia Date: Fri, 16 Oct 2015 10:22:30 +0200 Subject: [PATCH 27/61] refs codership/galera#308 - Moves cleanup of status vars to function export_wsrep_status_to_mysql(). --- sql/sql_class.cc | 4 ---- sql/wsrep_var.cc | 5 +++++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 5534cdde596..6c7282c3505 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -2361,10 +2361,6 @@ void THD::cleanup_after_query() rgi_slave->cleanup_after_query(); #endif -#ifdef WITH_WSREP - wsrep_free_status(this); -#endif /* WITH_WSREP */ - DBUG_VOID_RETURN; } diff --git a/sql/wsrep_var.cc b/sql/wsrep_var.cc index a3366000fc5..7e64b654c92 100644 --- a/sql/wsrep_var.cc +++ b/sql/wsrep_var.cc @@ -567,6 +567,11 @@ static void export_wsrep_status_to_mysql(THD* thd) { int wsrep_status_len, i; + if (thd->wsrep_status_vars) + { + wsrep->stats_free(wsrep, thd->wsrep_status_vars); + } + thd->wsrep_status_vars = wsrep->stats_get(wsrep); if (!thd->wsrep_status_vars) { From cf4362013649d67d59201d8a1b00fe5111c42913 Mon Sep 17 00:00:00 2001 From: Daniele Sciascia Date: Fri, 16 Oct 2015 11:51:11 +0200 Subject: [PATCH 28/61] refs codership/galera#308 - Avoid calling wsrep->stats_free() directly, instead, use wsrep_free_status(). --- sql/sql_class.cc | 2 +- sql/wsrep_var.cc | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 6c7282c3505..7705ac45ffa 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -1837,7 +1837,7 @@ THD::~THD() mysql_mutex_unlock(&LOCK_wsrep_thd); mysql_mutex_destroy(&LOCK_wsrep_thd); if (wsrep_rgi) delete wsrep_rgi; - if (wsrep_status_vars) wsrep->stats_free(wsrep, wsrep_status_vars); + wsrep_free_status(this); #endif /* Close connection */ #ifndef EMBEDDED_LIBRARY diff --git a/sql/wsrep_var.cc b/sql/wsrep_var.cc index 7e64b654c92..7ac68df66bd 100644 --- a/sql/wsrep_var.cc +++ b/sql/wsrep_var.cc @@ -567,10 +567,7 @@ static void export_wsrep_status_to_mysql(THD* thd) { int wsrep_status_len, i; - if (thd->wsrep_status_vars) - { - wsrep->stats_free(wsrep, thd->wsrep_status_vars); - } + wsrep_free_status(thd); thd->wsrep_status_vars = wsrep->stats_get(wsrep); From 5ad30e8ad1c1f71dcc54be1f79680a3253101926 Mon Sep 17 00:00:00 2001 From: Teemu Ollakka Date: Fri, 16 Oct 2015 15:57:22 +0300 Subject: [PATCH 29/61] MTR test for checking correctness of fragmentation over CCs --- .../suite/galera/r/galera_gcs_fragment.result | 25 ++++++++ .../suite/galera/t/galera_gcs_fragment.cnf | 5 ++ .../suite/galera/t/galera_gcs_fragment.test | 64 +++++++++++++++++++ 3 files changed, 94 insertions(+) create mode 100644 mysql-test/suite/galera/r/galera_gcs_fragment.result create mode 100644 mysql-test/suite/galera/t/galera_gcs_fragment.cnf create mode 100644 mysql-test/suite/galera/t/galera_gcs_fragment.test diff --git a/mysql-test/suite/galera/r/galera_gcs_fragment.result b/mysql-test/suite/galera/r/galera_gcs_fragment.result new file mode 100644 index 00000000000..63181f23451 --- /dev/null +++ b/mysql-test/suite/galera/r/galera_gcs_fragment.result @@ -0,0 +1,25 @@ +CREATE TABLE t1 (f1 INT PRIMARY KEY, f2 TEXT); +SET GLOBAL wsrep_cluster_address=''; +SET SESSION wsrep_sync_wait=0; +SET GLOBAL wsrep_provider_options = 'dbug=d,gcs_core_after_frag_send'; +SET SESSION wsrep_retry_autocommit=0; +INSERT INTO t1 VALUES (1, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); +SET SESSION wsrep_on = 0; +SET SESSION wsrep_on = 1; +SET GLOBAL wsrep_provider_options = 'dbug='; +SET GLOBAL wsrep_cluster_address = 'gcomm://127.0.0.1:13001'; +SET SESSION wsrep_on = 0; +SET SESSION wsrep_on = 1; +INSERT INTO t1 VALUES (2, "bbbbbaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); +SET GLOBAL wsrep_provider_options = 'signal=gcs_core_after_frag_send'; +ERROR 40001: Deadlock found when trying to get lock; try restarting transaction +INSERT INTO t1 VALUES (3, "cccccaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); +SELECT * FROM t1; +f1 f2 +2 bbbbbaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +3 cccccaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +SELECT * FROM t1; +f1 f2 +2 bbbbbaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +3 cccccaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/galera_gcs_fragment.cnf b/mysql-test/suite/galera/t/galera_gcs_fragment.cnf new file mode 100644 index 00000000000..aae3fee5904 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_gcs_fragment.cnf @@ -0,0 +1,5 @@ +!include ../galera_2nodes.cnf +[mysqld.1] +wsrep_provider_options='base_port=@mysqld.1.#galera_port;gcs.max_packet_size=64' +[mysqld.2] +wsrep_provider_options='base_port=@mysqld.2.#galera_port;gcs.max_packet_size=64' diff --git a/mysql-test/suite/galera/t/galera_gcs_fragment.test b/mysql-test/suite/galera/t/galera_gcs_fragment.test new file mode 100644 index 00000000000..a0c0362b7ba --- /dev/null +++ b/mysql-test/suite/galera/t/galera_gcs_fragment.test @@ -0,0 +1,64 @@ +# Test fragmentation over configuration changes +--source include/galera_cluster.inc +--source include/have_innodb.inc + +# Prepare table +CREATE TABLE t1 (f1 INT PRIMARY KEY, f2 TEXT); + +# Stop node2 + +# Disconnect node_2 from group +--connection node_2 +--let $wsrep_cluster_address_orig = `select @@wsrep_cluster_address` +SET GLOBAL wsrep_cluster_address=''; + +# Connection for sync points +--connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1 +SET SESSION wsrep_sync_wait=0; + +# Set breakpoint in gcs after first fragment send + +--let $galera_sync_point = gcs_core_after_frag_send +--source include/galera_set_sync_point.inc + +--connection node_1 +SET SESSION wsrep_retry_autocommit=0; +--send INSERT INTO t1 VALUES (1, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") + +--connection node_1a +--source include/galera_wait_sync_point.inc +--source include/galera_clear_sync_point.inc + + +# Restart node_2, wait until it joins the group and then make INSERT +--connection node_2 +--eval SET GLOBAL wsrep_cluster_address = '$wsrep_cluster_address_orig' +SET SESSION wsrep_on = 0; +--source include/galera_wait_ready.inc +SET SESSION wsrep_on = 1; + +INSERT INTO t1 VALUES (2, "bbbbbaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); + +# Signal node_1 to continue +--connection node_1a +--source include/galera_signal_sync_point.inc + +# Deadlock error should be returned since write set send was +# interrupted by gcs +--connection node_1 +--error ER_LOCK_DEADLOCK +--reap + +# Do additional insert to verify that node_1 remain operational +INSERT INTO t1 VALUES (3, "cccccaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); + + +# Nodes node_1 and node_2 should now contain rows 2 and 3 +SELECT * FROM t1; + +--connection node_2 +SELECT * FROM t1; + +--connection node_1 + +DROP TABLE t1; \ No newline at end of file From 251c53a8a7368a5a71f39f92358eabb53097381c Mon Sep 17 00:00:00 2001 From: Daniele Sciascia Date: Mon, 19 Oct 2015 11:17:13 +0200 Subject: [PATCH 30/61] refs codership/mysql-wsrep#184 - Adds runtime check wsrep_on(), to not interfere with default innodb behavior. --- storage/innobase/lock/lock0wait.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/storage/innobase/lock/lock0wait.cc b/storage/innobase/lock/lock0wait.cc index 29dfffcd496..7f946b62be7 100644 --- a/storage/innobase/lock/lock0wait.cc +++ b/storage/innobase/lock/lock0wait.cc @@ -394,8 +394,9 @@ lock_wait_suspend_thread( if (lock_wait_timeout < 100000000 && wait_time > (double) lock_wait_timeout) { #ifdef WITH_WSREP - if (!wsrep_is_BF_lock_timeout(trx) - && trx->error_state != DB_DEADLOCK) { + if (!wsrep_on(trx->mysql_thd) || + (!wsrep_is_BF_lock_timeout(trx) && + trx->error_state != DB_DEADLOCK)) { #endif /* WITH_WSREP */ trx->error_state = DB_LOCK_WAIT_TIMEOUT; From c1ea0570af88ed12f55fc20c54262b3688b9981d Mon Sep 17 00:00:00 2001 From: Nirbhay Choubey Date: Mon, 22 Feb 2016 16:51:45 -0500 Subject: [PATCH 31/61] refs codership/mysql-wsrep#184 Merge fix to XtraDB engine. --- storage/xtradb/lock/lock0wait.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/storage/xtradb/lock/lock0wait.cc b/storage/xtradb/lock/lock0wait.cc index 29dfffcd496..7f946b62be7 100644 --- a/storage/xtradb/lock/lock0wait.cc +++ b/storage/xtradb/lock/lock0wait.cc @@ -394,8 +394,9 @@ lock_wait_suspend_thread( if (lock_wait_timeout < 100000000 && wait_time > (double) lock_wait_timeout) { #ifdef WITH_WSREP - if (!wsrep_is_BF_lock_timeout(trx) - && trx->error_state != DB_DEADLOCK) { + if (!wsrep_on(trx->mysql_thd) || + (!wsrep_is_BF_lock_timeout(trx) && + trx->error_state != DB_DEADLOCK)) { #endif /* WITH_WSREP */ trx->error_state = DB_LOCK_WAIT_TIMEOUT; From ace86a2375c3f47badf49796eda14959b0487269 Mon Sep 17 00:00:00 2001 From: Daniele Sciascia Date: Tue, 20 Oct 2015 17:54:14 +0200 Subject: [PATCH 32/61] refs codership/mysql-wsrep#201 - Fixes query cache so that it is aware of wsrep_sync_wait. Query cache would return (possibly stale) results to the client, regardless of the value of wsrep_sync_wait. - Includes the test case that reproduced the issue. --- .../suite/galera/r/mysql-wsrep#201.result | 4 +++ .../suite/galera/t/mysql-wsrep#201-master.opt | 1 + .../suite/galera/t/mysql-wsrep#201.test | 33 +++++++++++++++++++ sql/sql_cache.cc | 20 +++++++++++ sql/sql_class.cc | 6 ++++ sql/sql_class.h | 2 +- sql/wsrep_mysqld.cc | 17 ++++++---- sql/wsrep_mysqld.h | 1 + 8 files changed, 77 insertions(+), 7 deletions(-) create mode 100644 mysql-test/suite/galera/r/mysql-wsrep#201.result create mode 100644 mysql-test/suite/galera/t/mysql-wsrep#201-master.opt create mode 100644 mysql-test/suite/galera/t/mysql-wsrep#201.test diff --git a/mysql-test/suite/galera/r/mysql-wsrep#201.result b/mysql-test/suite/galera/r/mysql-wsrep#201.result new file mode 100644 index 00000000000..1c0998e35ac --- /dev/null +++ b/mysql-test/suite/galera/r/mysql-wsrep#201.result @@ -0,0 +1,4 @@ +CREATE TABLE t1 (id INT PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (DEFAULT); +SET GLOBAL query_cache_size=1355776; +SET SESSION wsrep_sync_wait = 7; diff --git a/mysql-test/suite/galera/t/mysql-wsrep#201-master.opt b/mysql-test/suite/galera/t/mysql-wsrep#201-master.opt new file mode 100644 index 00000000000..a00258bc48c --- /dev/null +++ b/mysql-test/suite/galera/t/mysql-wsrep#201-master.opt @@ -0,0 +1 @@ +--query_cache_type=1 diff --git a/mysql-test/suite/galera/t/mysql-wsrep#201.test b/mysql-test/suite/galera/t/mysql-wsrep#201.test new file mode 100644 index 00000000000..cc842afb6d0 --- /dev/null +++ b/mysql-test/suite/galera/t/mysql-wsrep#201.test @@ -0,0 +1,33 @@ +--source include/galera_cluster.inc +--source include/have_innodb.inc +--source include/have_query_cache.inc + +CREATE TABLE t1 (id INT PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (DEFAULT); + +--connection node_2 +--let $qcache_size_orig = `SELECT @@GLOBAL.query_cache_size` +SET GLOBAL query_cache_size=1355776; +SET SESSION wsrep_sync_wait = 7; + +--disable_query_log + +--let $count = 10000 +while ($count) +{ + --connection node_1 + INSERT INTO t1 VALUES (DEFAULT); + --let $val1 = `SELECT LAST_INSERT_ID()` + --connection node_2 + --let $val2 = `SELECT MAX(id) FROM t1` + --let $val3 = `SELECT $val1 != $val2` + if ($val3) + { + --echo $val1 $val2 + --die wsrep_sync_wait failed + } + --dec $count +} + +--eval SET GLOBAL query_cache_size = $qcache_size_orig +DROP TABLE t1; diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc index e1efb1e85d6..0d3497ad964 100644 --- a/sql/sql_cache.cc +++ b/sql/sql_cache.cc @@ -1846,6 +1846,7 @@ Query_cache::send_result_to_client(THD *thd, char *org_sql, uint query_length) goto err; } } + /* Try to obtain an exclusive lock on the query cache. If the cache is disabled or if a full cache flush is in progress, the attempt to @@ -1957,6 +1958,25 @@ def_week_frmt: %lu, in_trans: %d, autocommit: %d", } DBUG_PRINT("qcache", ("Query in query hash 0x%lx", (ulong)query_block)); +#ifdef WITH_WSREP + if (WSREP_CLIENT(thd) && wsrep_must_sync_wait(thd)) { + unlock(); + if (wsrep_sync_wait(thd)) + goto err; + if (try_lock(TRUE)) + goto err; + query_block = (Query_cache_block *) my_hash_search(&queries, + (uchar*) sql, + tot_length); + if (query_block == 0 || + query_block->query()->result() == 0 || + query_block->query()->result()->type != Query_cache_block::RESULT) + { + goto err_unlock; + } + } +#endif /* WITH_WSREP */ + /* Now lock and test that nothing changed while blocks was unlocked */ BLOCK_LOCK_RD(query_block); diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 7705ac45ffa..fa26494f35b 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -1213,6 +1213,7 @@ THD::THD() wsrep_mysql_replicated = 0; wsrep_TOI_pre_query = NULL; wsrep_TOI_pre_query_len = 0; + wsrep_sync_wait_gtid= WSREP_GTID_UNDEFINED; #endif /* Call to init() below requires fully initialized Open_tables_state. */ reset_open_tables_state(this); @@ -1628,6 +1629,7 @@ void THD::init(void) wsrep_mysql_replicated = 0; wsrep_TOI_pre_query = NULL; wsrep_TOI_pre_query_len = 0; + wsrep_sync_wait_gtid= WSREP_GTID_UNDEFINED; /* @@wsrep_causal_reads is now being handled via wsrep_sync_wait, update it @@ -2361,6 +2363,10 @@ void THD::cleanup_after_query() rgi_slave->cleanup_after_query(); #endif +#ifdef WITH_WSREP + wsrep_sync_wait_gtid= WSREP_GTID_UNDEFINED; +#endif /* WITH_WSREP */ + DBUG_VOID_RETURN; } diff --git a/sql/sql_class.h b/sql/sql_class.h index 431edc3b38c..aee4d1dc359 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -2787,7 +2787,6 @@ public: query_id_t first_query_id; } binlog_evt_union; - /** Internal parser state. Note that since the parser is not re-entrant, we keep only one parser @@ -3865,6 +3864,7 @@ public: void* wsrep_apply_format; bool wsrep_apply_toi; /* applier processing in TOI */ bool wsrep_skip_append_keys; + wsrep_gtid_t wsrep_sync_wait_gtid; #endif /* WITH_WSREP */ }; diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc index e622389de7e..0dd5c4dba14 100644 --- a/sql/wsrep_mysqld.cc +++ b/sql/wsrep_mysqld.cc @@ -810,19 +810,24 @@ bool wsrep_start_replication() return true; } +bool wsrep_must_sync_wait (THD* thd, uint mask) +{ + return (thd->variables.wsrep_sync_wait & mask) && + thd->variables.wsrep_on && + !thd->in_active_multi_stmt_transaction() && + thd->wsrep_conflict_state != REPLAYING && + thd->wsrep_sync_wait_gtid.seqno == WSREP_SEQNO_UNDEFINED; +} + bool wsrep_sync_wait (THD* thd, uint mask) { - if ((thd->variables.wsrep_sync_wait & mask) && - thd->variables.wsrep_on && - !thd->in_active_multi_stmt_transaction() && - thd->wsrep_conflict_state != REPLAYING) + if (wsrep_must_sync_wait(thd, mask)) { WSREP_DEBUG("wsrep_sync_wait: thd->variables.wsrep_sync_wait = %u, mask = %u", thd->variables.wsrep_sync_wait, mask); // This allows autocommit SELECTs and a first SELECT after SET AUTOCOMMIT=0 // TODO: modify to check if thd has locked any rows. - wsrep_gtid_t gtid; - wsrep_status_t ret= wsrep->causal_read (wsrep, >id); + wsrep_status_t ret= wsrep->causal_read (wsrep, &thd->wsrep_sync_wait_gtid); if (unlikely(WSREP_OK != ret)) { diff --git a/sql/wsrep_mysqld.h b/sql/wsrep_mysqld.h index 1616bab695e..242227fd2a0 100644 --- a/sql/wsrep_mysqld.h +++ b/sql/wsrep_mysqld.h @@ -192,6 +192,7 @@ extern void wsrep_kill_mysql(THD *thd); /* new defines */ extern void wsrep_stop_replication(THD *thd); extern bool wsrep_start_replication(); +extern bool wsrep_must_sync_wait (THD* thd, uint mask = WSREP_SYNC_WAIT_BEFORE_READ); extern bool wsrep_sync_wait (THD* thd, uint mask = WSREP_SYNC_WAIT_BEFORE_READ); extern int wsrep_check_opts (int argc, char* const* argv); extern void wsrep_prepend_PATH (const char* path); From d794f05910a8f5f87fb699cacc516837eeea821d Mon Sep 17 00:00:00 2001 From: Philip Stoev Date: Wed, 21 Oct 2015 01:15:52 -0700 Subject: [PATCH 33/61] Galera MTR Tests: stability fix for galera_gcs_fragment.test (TCP port was output to the .result file) --- mysql-test/suite/galera/r/galera_gcs_fragment.result | 1 - mysql-test/suite/galera/t/galera_gcs_fragment.test | 4 +++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/mysql-test/suite/galera/r/galera_gcs_fragment.result b/mysql-test/suite/galera/r/galera_gcs_fragment.result index 63181f23451..0c9c1819f60 100644 --- a/mysql-test/suite/galera/r/galera_gcs_fragment.result +++ b/mysql-test/suite/galera/r/galera_gcs_fragment.result @@ -7,7 +7,6 @@ INSERT INTO t1 VALUES (1, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa SET SESSION wsrep_on = 0; SET SESSION wsrep_on = 1; SET GLOBAL wsrep_provider_options = 'dbug='; -SET GLOBAL wsrep_cluster_address = 'gcomm://127.0.0.1:13001'; SET SESSION wsrep_on = 0; SET SESSION wsrep_on = 1; INSERT INTO t1 VALUES (2, "bbbbbaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); diff --git a/mysql-test/suite/galera/t/galera_gcs_fragment.test b/mysql-test/suite/galera/t/galera_gcs_fragment.test index a0c0362b7ba..ae1e0d8bab0 100644 --- a/mysql-test/suite/galera/t/galera_gcs_fragment.test +++ b/mysql-test/suite/galera/t/galera_gcs_fragment.test @@ -32,7 +32,9 @@ SET SESSION wsrep_retry_autocommit=0; # Restart node_2, wait until it joins the group and then make INSERT --connection node_2 +--disable_query_log --eval SET GLOBAL wsrep_cluster_address = '$wsrep_cluster_address_orig' +--enable_query_log SET SESSION wsrep_on = 0; --source include/galera_wait_ready.inc SET SESSION wsrep_on = 1; @@ -61,4 +63,4 @@ SELECT * FROM t1; --connection node_1 -DROP TABLE t1; \ No newline at end of file +DROP TABLE t1; From 5be449d014d0bdab4859409860deec669a1f11f3 Mon Sep 17 00:00:00 2001 From: Philip Stoev Date: Wed, 21 Oct 2015 01:25:32 -0700 Subject: [PATCH 34/61] Galera MTR Tests: attempt to work around codership/QA#179 in galera_as_slave_nonprim.test --- mysql-test/suite/galera/t/galera_as_slave_nonprim.test | 1 + 1 file changed, 1 insertion(+) diff --git a/mysql-test/suite/galera/t/galera_as_slave_nonprim.test b/mysql-test/suite/galera/t/galera_as_slave_nonprim.test index b7b656383fd..5914e52d851 100644 --- a/mysql-test/suite/galera/t/galera_as_slave_nonprim.test +++ b/mysql-test/suite/galera/t/galera_as_slave_nonprim.test @@ -26,6 +26,7 @@ SET SESSION wsrep_sync_wait = 0; CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; --connection node_2 +--sleep 1 --let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; --source include/wait_condition.inc From 1077eef94273a87a22d656a2fcd4e47413a29aed Mon Sep 17 00:00:00 2001 From: Raghavendra D Prabhu Date: Thu, 16 Jul 2015 05:24:13 -0700 Subject: [PATCH 35/61] PXC-391: Avoid Total Order Isolation (TOI) for LOCAL sql admin commands. The admin commands in question are: > OPTIMIZE > REPAIR > ANALYZE For LOCAL or NO_WRITE_TO_BINLOG invocations of these commands, ie OPTIMIZE LOCAL TABLE they are not binlogged as expected. Also, in addition, they are not executed under TOI. Hence, they are not propagated to other nodes. The effect is same as that of wsrep_on=0. Also added tests for this. A WSREP_DEBUG for wsrep_register_hton has also been added. The galera_flush_local test has also been updated for verifying that effects of NO_WRITE_TO_BINLOG / LOCAL are equivalent to wsrep_on=0 from wsrep perspective. (cherry picked from commit 5065122f94a8002d4da231528a46f8d9ddbffdc2) Conflicts: sql/sql_admin.cc sql/sql_reload.cc sql/wsrep_hton.cc --- .../suite/galera/r/galera_flush_local.result | 151 ++++++++++++++++++ .../suite/galera/t/galera_flush_local.opt | 1 + .../suite/galera/t/galera_flush_local.test | 148 +++++++++++++++++ sql/sql_admin.cc | 5 +- sql/sql_parse.cc | 2 +- sql/sql_parse.h | 7 + sql/sql_reload.cc | 30 ++++ sql/wsrep_hton.cc | 11 ++ 8 files changed, 352 insertions(+), 3 deletions(-) create mode 100644 mysql-test/suite/galera/r/galera_flush_local.result create mode 100644 mysql-test/suite/galera/t/galera_flush_local.opt create mode 100644 mysql-test/suite/galera/t/galera_flush_local.test diff --git a/mysql-test/suite/galera/r/galera_flush_local.result b/mysql-test/suite/galera/r/galera_flush_local.result new file mode 100644 index 00000000000..f740b0a7f65 --- /dev/null +++ b/mysql-test/suite/galera/r/galera_flush_local.result @@ -0,0 +1,151 @@ +DROP TABLE IF EXISTS t1, t2, x1, x2; +CREATE TABLE t1 (f1 INTEGER); +CREATE TABLE t2 (f1 INT PRIMARY KEY AUTO_INCREMENT, f2 INTEGER); +SET SESSION wsrep_replicate_myisam = TRUE; +CREATE TABLE x1 (f1 INTEGER) ENGINE=MyISAM; +CREATE TABLE x2 (f1 INT PRIMARY KEY AUTO_INCREMENT, f2 INTEGER) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +INSERT INTO x1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +INSERT INTO t2 (f2) SELECT 1 FROM t1 AS a1, t1 AS a2, t1 AS a3, t1 AS a4; +INSERT INTO x2 (f2) VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +FLUSH LOCAL DES_KEY_FILE; +FLUSH LOCAL HOSTS; +FLUSH LOCAL QUERY CACHE; +FLUSH LOCAL STATUS; +FLUSH LOCAL PRIVILEGES; +FLUSH LOCAL USER_RESOURCES; +FLUSH LOCAL TABLES; +FLUSH LOCAL TABLES t2; +FLUSH LOCAL ERROR LOGS; +FLUSH LOCAL SLOW LOGS; +FLUSH LOCAL GENERAL LOGS; +FLUSH LOCAL ENGINE LOGS; +FLUSH LOCAL RELAY LOGS; +FLUSH LOCAL CLIENT_STATISTICS; +FLUSH LOCAL INDEX_STATISTICS; +FLUSH LOCAL TABLE_STATISTICS; +FLUSH LOCAL USER_STATISTICS; +FLUSH LOCAL THREAD_STATISTICS; +FLUSH LOCAL CHANGED_PAGE_BITMAPS; +FLUSH LOCAL LOGS; +FLUSH LOCAL BINARY LOGS; +FLUSH LOCAL TABLES WITH READ LOCK; +UNLOCK TABLES; +FLUSH LOCAL TABLES t1 WITH READ LOCK; +UNLOCK TABLES; +FLUSH LOCAL TABLES t1 FOR EXPORT; +UNLOCK TABLES; +LOCK TABLES t1 WRITE; +FLUSH LOCAL TABLES t1; +UNLOCK TABLES; +LOCK TABLES t1 READ; +FLUSH LOCAL TABLES t1; +ERROR HY000: Table 't1' was locked with a READ lock and can't be updated +UNLOCK TABLES; +FLUSH LOCAL TABLES t1; +ANALYZE LOCAL TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +OPTIMIZE LOCAL TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 optimize note Table does not support optimize, doing recreate + analyze instead +test.t1 optimize status OK +test.t2 optimize note Table does not support optimize, doing recreate + analyze instead +test.t2 optimize status OK +REPAIR LOCAL TABLE x1, x2; +Table Op Msg_type Msg_text +test.x1 repair status OK +test.x2 repair status OK +wsrep_last_committed_diff +1 +SELECT COUNT(*) = 10 FROM t1; +COUNT(*) = 10 +1 +SELECT COUNT(*) = 10 FROM x1; +COUNT(*) = 10 +1 +SELECT COUNT(*) = 10000 FROM t2; +COUNT(*) = 10000 +1 +SELECT COUNT(*) = 10 FROM x2; +COUNT(*) = 10 +1 +DROP TABLE t1, t2, x1, x2; +CREATE TABLE t1 (f1 INTEGER); +CREATE TABLE t2 (f1 INT PRIMARY KEY AUTO_INCREMENT, f2 INTEGER); +SET SESSION wsrep_replicate_myisam = TRUE; +CREATE TABLE x1 (f1 INTEGER) ENGINE=MyISAM; +CREATE TABLE x2 (f1 INT PRIMARY KEY AUTO_INCREMENT, f2 INTEGER) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +INSERT INTO x1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +INSERT INTO t2 (f2) SELECT 1 FROM t1 AS a1, t1 AS a2, t1 AS a3, t1 AS a4; +INSERT INTO x2 (f2) VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +set wsrep_on=0; +FLUSH DES_KEY_FILE; +FLUSH HOSTS; +FLUSH QUERY CACHE; +FLUSH STATUS; +FLUSH PRIVILEGES; +FLUSH USER_RESOURCES; +FLUSH TABLES; +FLUSH TABLES t2; +FLUSH ERROR LOGS; +FLUSH SLOW LOGS; +FLUSH GENERAL LOGS; +FLUSH ENGINE LOGS; +FLUSH RELAY LOGS; +FLUSH CLIENT_STATISTICS; +FLUSH INDEX_STATISTICS; +FLUSH TABLE_STATISTICS; +FLUSH USER_STATISTICS; +FLUSH THREAD_STATISTICS; +FLUSH CHANGED_PAGE_BITMAPS; +FLUSH LOGS; +FLUSH BINARY LOGS; +FLUSH TABLES WITH READ LOCK; +UNLOCK TABLES; +FLUSH TABLES t1 WITH READ LOCK; +UNLOCK TABLES; +FLUSH TABLES t1 FOR EXPORT; +UNLOCK TABLES; +LOCK TABLES t1 WRITE; +FLUSH TABLES t1; +UNLOCK TABLES; +LOCK TABLES t1 READ; +FLUSH TABLES t1; +ERROR HY000: Table 't1' was locked with a READ lock and can't be updated +UNLOCK TABLES; +FLUSH TABLES t1; +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +OPTIMIZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 optimize note Table does not support optimize, doing recreate + analyze instead +test.t1 optimize status OK +test.t2 optimize note Table does not support optimize, doing recreate + analyze instead +test.t2 optimize status OK +REPAIR TABLE x1, x2; +Table Op Msg_type Msg_text +test.x1 repair status OK +test.x2 repair status OK +wsrep_last_committed_diff +1 +wsrep_last_committed_diff2 +1 +SELECT COUNT(*) = 10 FROM t1; +COUNT(*) = 10 +1 +SELECT COUNT(*) = 10 FROM x1; +COUNT(*) = 10 +1 +SELECT COUNT(*) = 10000 FROM t2; +COUNT(*) = 10000 +1 +SELECT COUNT(*) = 10 FROM x2; +COUNT(*) = 10 +1 +set wsrep_on=1; +DROP TABLE t1, t2, x1, x2; diff --git a/mysql-test/suite/galera/t/galera_flush_local.opt b/mysql-test/suite/galera/t/galera_flush_local.opt new file mode 100644 index 00000000000..698bbefe41f --- /dev/null +++ b/mysql-test/suite/galera/t/galera_flush_local.opt @@ -0,0 +1 @@ +--query_cache_type=1 --query_cache_size=1000000 --innodb_track_changed_pages=1 --userstat=1 --thread_statistics=1 diff --git a/mysql-test/suite/galera/t/galera_flush_local.test b/mysql-test/suite/galera/t/galera_flush_local.test new file mode 100644 index 00000000000..8f578c78e54 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_flush_local.test @@ -0,0 +1,148 @@ +# +# Test that various FLUSH LOCAL commands are replicated. Whenever possible, check the slave for the effects. +# PXC-391 + +--source include/galera_cluster.inc +--source include/have_innodb.inc +--source include/have_query_cache.inc + +--disable_warnings +DROP TABLE IF EXISTS t1, t2, x1, x2; +--enable_warnings +# +# The following FLUSH LOCAL statements should *not* be replicated +# +--connection node_1 +CREATE TABLE t1 (f1 INTEGER); +CREATE TABLE t2 (f1 INT PRIMARY KEY AUTO_INCREMENT, f2 INTEGER); +SET SESSION wsrep_replicate_myisam = TRUE; +CREATE TABLE x1 (f1 INTEGER) ENGINE=MyISAM; +CREATE TABLE x2 (f1 INT PRIMARY KEY AUTO_INCREMENT, f2 INTEGER) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +INSERT INTO x1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +INSERT INTO t2 (f2) SELECT 1 FROM t1 AS a1, t1 AS a2, t1 AS a3, t1 AS a4; +INSERT INTO x2 (f2) VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); + +--connection node_2 +--let $wsrep_last_committed_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` +--connection node_1 +FLUSH LOCAL DES_KEY_FILE; +FLUSH LOCAL HOSTS; +FLUSH LOCAL QUERY CACHE; +FLUSH LOCAL STATUS; +FLUSH LOCAL PRIVILEGES; +FLUSH LOCAL USER_RESOURCES; +FLUSH LOCAL TABLES; +FLUSH LOCAL TABLES t2; +FLUSH LOCAL ERROR LOGS; +FLUSH LOCAL SLOW LOGS; +FLUSH LOCAL GENERAL LOGS; +FLUSH LOCAL ENGINE LOGS; +FLUSH LOCAL RELAY LOGS; +FLUSH LOCAL CLIENT_STATISTICS; +FLUSH LOCAL INDEX_STATISTICS; +FLUSH LOCAL TABLE_STATISTICS; +FLUSH LOCAL USER_STATISTICS; +FLUSH LOCAL THREAD_STATISTICS; +FLUSH LOCAL CHANGED_PAGE_BITMAPS; +FLUSH LOCAL LOGS; +FLUSH LOCAL BINARY LOGS; +FLUSH LOCAL TABLES WITH READ LOCK; +UNLOCK TABLES; +FLUSH LOCAL TABLES t1 WITH READ LOCK; +UNLOCK TABLES; +FLUSH LOCAL TABLES t1 FOR EXPORT; +UNLOCK TABLES; +LOCK TABLES t1 WRITE; +FLUSH LOCAL TABLES t1; +UNLOCK TABLES; +LOCK TABLES t1 READ; +--error ER_TABLE_NOT_LOCKED_FOR_WRITE +FLUSH LOCAL TABLES t1; +UNLOCK TABLES; +FLUSH LOCAL TABLES t1; +ANALYZE LOCAL TABLE t1, t2; +OPTIMIZE LOCAL TABLE t1, t2; +REPAIR LOCAL TABLE x1, x2; +--connection node_2 +--let $wsrep_last_committed_after = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` +--disable_query_log +--eval SELECT $wsrep_last_committed_after = $wsrep_last_committed_before AS wsrep_last_committed_diff; +--enable_query_log + +SELECT COUNT(*) = 10 FROM t1; +SELECT COUNT(*) = 10 FROM x1; +SELECT COUNT(*) = 10000 FROM t2; +SELECT COUNT(*) = 10 FROM x2; + + +--connection node_1 +DROP TABLE t1, t2, x1, x2; +CREATE TABLE t1 (f1 INTEGER); +CREATE TABLE t2 (f1 INT PRIMARY KEY AUTO_INCREMENT, f2 INTEGER); +SET SESSION wsrep_replicate_myisam = TRUE; +CREATE TABLE x1 (f1 INTEGER) ENGINE=MyISAM; +CREATE TABLE x2 (f1 INT PRIMARY KEY AUTO_INCREMENT, f2 INTEGER) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +INSERT INTO x1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +INSERT INTO t2 (f2) SELECT 1 FROM t1 AS a1, t1 AS a2, t1 AS a3, t1 AS a4; +INSERT INTO x2 (f2) VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); + + +--connection node_2 +--let $wsrep_last_committed_before2 = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` +--connection node_1 +set wsrep_on=0; +FLUSH DES_KEY_FILE; +FLUSH HOSTS; +FLUSH QUERY CACHE; +FLUSH STATUS; +FLUSH PRIVILEGES; +FLUSH USER_RESOURCES; +FLUSH TABLES; +FLUSH TABLES t2; +FLUSH ERROR LOGS; +FLUSH SLOW LOGS; +FLUSH GENERAL LOGS; +FLUSH ENGINE LOGS; +FLUSH RELAY LOGS; +FLUSH CLIENT_STATISTICS; +FLUSH INDEX_STATISTICS; +FLUSH TABLE_STATISTICS; +FLUSH USER_STATISTICS; +FLUSH THREAD_STATISTICS; +FLUSH CHANGED_PAGE_BITMAPS; +FLUSH LOGS; +FLUSH BINARY LOGS; +FLUSH TABLES WITH READ LOCK; +UNLOCK TABLES; +FLUSH TABLES t1 WITH READ LOCK; +UNLOCK TABLES; +FLUSH TABLES t1 FOR EXPORT; +UNLOCK TABLES; +LOCK TABLES t1 WRITE; +FLUSH TABLES t1; +UNLOCK TABLES; +LOCK TABLES t1 READ; +--error ER_TABLE_NOT_LOCKED_FOR_WRITE +FLUSH TABLES t1; +UNLOCK TABLES; +FLUSH TABLES t1; +ANALYZE TABLE t1, t2; +OPTIMIZE TABLE t1, t2; +REPAIR TABLE x1, x2; +--connection node_2 +--let $wsrep_last_committed_after2 = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` +--disable_query_log +--eval SELECT $wsrep_last_committed_after2 = $wsrep_last_committed_before2 AS wsrep_last_committed_diff; +--eval SELECT $wsrep_last_committed_after2 = $wsrep_last_committed_before + 9 AS wsrep_last_committed_diff2; +--enable_query_log + +SELECT COUNT(*) = 10 FROM t1; +SELECT COUNT(*) = 10 FROM x1; +SELECT COUNT(*) = 10000 FROM t2; +SELECT COUNT(*) = 10 FROM x2; + +--connection node_1 +set wsrep_on=1; +DROP TABLE t1, t2, x1, x2; diff --git a/sql/sql_admin.cc b/sql/sql_admin.cc index 5ffa8b16345..3ed8545bcb4 100644 --- a/sql/sql_admin.cc +++ b/sql/sql_admin.cc @@ -1175,6 +1175,7 @@ bool Sql_cmd_analyze_table::execute(THD *thd) if (check_table_access(thd, SELECT_ACL | INSERT_ACL, first_table, FALSE, UINT_MAX, FALSE)) goto error; + WSREP_TO_ISOLATION_BEGIN_WRTCHK(NULL, NULL, first_table); thd->enable_slow_log= opt_log_slow_admin_statements; #ifdef WITH_WSREP WSREP_TO_ISOLATION_BEGIN(first_table->db, first_table->table_name, NULL); @@ -1233,7 +1234,7 @@ bool Sql_cmd_optimize_table::execute(THD *thd) if (check_table_access(thd, SELECT_ACL | INSERT_ACL, first_table, FALSE, UINT_MAX, FALSE)) goto error; /* purecov: inspected */ - WSREP_TO_ISOLATION_BEGIN(first_table->db, first_table->table_name, NULL) + WSREP_TO_ISOLATION_BEGIN_WRTCHK(NULL, NULL, first_table); thd->enable_slow_log= opt_log_slow_admin_statements; res= (specialflag & SPECIAL_NO_NEW_FUNC) ? mysql_recreate_table(thd, first_table, true) : @@ -1267,7 +1268,7 @@ bool Sql_cmd_repair_table::execute(THD *thd) FALSE, UINT_MAX, FALSE)) goto error; /* purecov: inspected */ thd->enable_slow_log= opt_log_slow_admin_statements; - WSREP_TO_ISOLATION_BEGIN(first_table->db, first_table->table_name, NULL) + WSREP_TO_ISOLATION_BEGIN_WRTCHK(NULL, NULL, first_table); res= mysql_admin_table(thd, first_table, &m_lex->check_opt, "repair", TL_WRITE, 1, MY_TEST(m_lex->check_opt.sql_flags & TT_USEFRM), diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 99a1af749f9..7faa319feb0 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -4679,7 +4679,7 @@ end_with_restore_list: REFRESH_STATUS | REFRESH_USER_RESOURCES)) { - WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL) + WSREP_TO_ISOLATION_BEGIN_WRTCHK(WSREP_MYSQL_DB, NULL, NULL) } #endif /* WITH_WSREP*/ diff --git a/sql/sql_parse.h b/sql/sql_parse.h index 5e46c881510..16d2986f031 100644 --- a/sql/sql_parse.h +++ b/sql/sql_parse.h @@ -215,6 +215,13 @@ inline bool is_supported_parser_charset(CHARSET_INFO *cs) if (WSREP(thd) || (thd && thd->wsrep_exec_mode==TOTAL_ORDER)) \ wsrep_to_isolation_end(thd); +/* Checks if lex->no_write_to_binlog is set for statements that use + LOCAL or NO_WRITE_TO_BINLOG +*/ +#define WSREP_TO_ISOLATION_BEGIN_WRTCHK(db_, table_, table_list_) \ + if (WSREP(thd) && !thd->lex->no_write_to_binlog \ + && wsrep_to_isolation_begin(thd, db_, table_, table_list_)) goto error; + #else #define WSREP_TO_ISOLATION_BEGIN(db_, table_, table_list_) diff --git a/sql/sql_reload.cc b/sql/sql_reload.cc index f3909913c5b..ee05ad7bd36 100644 --- a/sql/sql_reload.cc +++ b/sql/sql_reload.cc @@ -312,6 +312,36 @@ bool reload_acl_and_cache(THD *thd, unsigned long long options, } } } +#ifdef WITH_WSREP + if (WSREP(thd) && !thd->lex->no_write_to_binlog + && (options & REFRESH_TABLES) + && !(options & (REFRESH_FOR_EXPORT|REFRESH_READ_LOCK))) + { + /* + This is done here because LOCK TABLES is not replicated in galera, + the upgrade of which is checked above. Hence, done after/if we + are able to upgrade locks. + + Also, note that, in error log with debug you may see + 'thread holds MDL locks at TI' but since this is a flush + tables and is required for LOCK TABLE WRITE + it can be ignored there. + */ + if (tables) + { + if (wsrep_to_isolation_begin(thd, NULL, NULL, tables)) + { + result= 1; + goto cleanup; + } + } + else if (wsrep_to_isolation_begin(thd, WSREP_MYSQL_DB, NULL, NULL)) + { + result= 1; + goto cleanup; + } + } +#endif /* WITH_WSREP */ #ifdef WITH_WSREP if (thd && thd->wsrep_applier) diff --git a/sql/wsrep_hton.cc b/sql/wsrep_hton.cc index c096d2610eb..812d64c8c82 100644 --- a/sql/wsrep_hton.cc +++ b/sql/wsrep_hton.cc @@ -69,6 +69,17 @@ void wsrep_register_hton(THD* thd, bool all) { if (thd->wsrep_exec_mode != TOTAL_ORDER && !thd->wsrep_apply_toi) { + if (thd->wsrep_exec_mode == LOCAL_STATE && + (thd_sql_command(thd) == SQLCOM_OPTIMIZE || + thd_sql_command(thd) == SQLCOM_ANALYZE || + thd_sql_command(thd) == SQLCOM_REPAIR) && + thd->lex->no_write_to_binlog == 1) + { + WSREP_DEBUG("Skipping wsrep_register_hton for LOCAL sql admin command : %s", + thd->query()); + return; + } + THD_TRANS *trans=all ? &thd->transaction.all : &thd->transaction.stmt; for (Ha_trx_info *i= trans->ha_list; WSREP(thd) && i; i = i->next()) { From 0ecc4fe2acbb3d89167b0e9cea4157a8c6daaef4 Mon Sep 17 00:00:00 2001 From: Raghavendra D Prabhu Date: Tue, 7 Jul 2015 14:20:22 +0530 Subject: [PATCH 36/61] Bug#1421360: Add Percona Server specific FLUSH statements. Added following: FLUSH CLIENT_STATISTICS FLUSH INDEX_STATISTICS FLUSH TABLE_STATISTICS FLUSH THREAD_STATISTICS FLUSH USER_STATISTICS pertaining to USER STATISTICS https://www.percona.com/doc/percona-server/5.6/diagnostics/user_stats.html FLUSH CHANGED_PAGE_BITMAPS pertaining to changed page tracking. https://www.percona.com/doc/percona-server/5.6/management/changed_page_tracking.html Also, added tests for them. (cherry picked from commit 7efe49010c7f217663f364657090812b4723f426) Conflicts: mysql-test/suite/galera/r/galera_flush.result mysql-test/suite/galera/r/galera_flush_gtid.result mysql-test/suite/galera/t/galera_flush.test sql/sql_parse.cc --- mysql-test/suite/galera/r/galera_flush.result | 34 ++++++ mysql-test/suite/galera/t/galera_flush.test | 100 ++++++++++++++++++ sql/sql_parse.cc | 34 ++++-- 3 files changed, 162 insertions(+), 6 deletions(-) diff --git a/mysql-test/suite/galera/r/galera_flush.result b/mysql-test/suite/galera/r/galera_flush.result index 5f15bee14a8..620ad1ccb67 100644 --- a/mysql-test/suite/galera/r/galera_flush.result +++ b/mysql-test/suite/galera/r/galera_flush.result @@ -1,3 +1,4 @@ +DROP TABLE IF EXISTS t1, t2; FLUSH DES_KEY_FILE; wsrep_last_committed_diff 1 @@ -26,6 +27,37 @@ CREATE TABLE t2 (f1 INTEGER); FLUSH TABLES t2; wsrep_last_committed_diff 1 +FLUSH ERROR LOGS; +wsrep_last_committed_diff +1 +FLUSH SLOW LOGS; +wsrep_last_committed_diff +1 +FLUSH GENERAL LOGS; +wsrep_last_committed_diff +1 +FLUSH ENGINE LOGS; +wsrep_last_committed_diff +1 +FLUSH RELAY LOGS; +wsrep_last_committed_diff +1 +SET @userstat_old= @@userstat; +SET GLOBAL userstat=ON; +FLUSH CLIENT_STATISTICS; +FLUSH INDEX_STATISTICS; +FLUSH TABLE_STATISTICS; +FLUSH USER_STATISTICS; +wsrep_last_committed_diff +1 +SET @old_thread_statistics= @@global.thread_statistics; +SET GLOBAL thread_statistics= ON; +FLUSH THREAD_STATISTICS; +wsrep_last_committed_diff +1 +FLUSH CHANGED_PAGE_BITMAPS; +wsrep_last_committed_diff +1 CREATE TABLE t1 (f1 INTEGER); FLUSH LOGS; FLUSH TABLES WITH READ LOCK; @@ -52,3 +84,5 @@ wsrep_last_committed_diff 1 DROP TABLE t1; DROP TABLE t2; +SET GLOBAL userstat= @userstat_old; +SET GLOBAL thread_statistics= @old_thread_statistics; diff --git a/mysql-test/suite/galera/t/galera_flush.test b/mysql-test/suite/galera/t/galera_flush.test index b773af03592..2a0fdc694fc 100644 --- a/mysql-test/suite/galera/t/galera_flush.test +++ b/mysql-test/suite/galera/t/galera_flush.test @@ -7,6 +7,9 @@ --source include/have_perfschema.inc --source include/have_query_cache.inc +--disable_warnings +DROP TABLE IF EXISTS t1, t2; +--enable_warnings # # The following FLUSH statements should be replicated # @@ -101,6 +104,101 @@ FLUSH TABLES t2; --enable_query_log +--connection node_2 +--let $wsrep_last_committed_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` +--connection node_1 +FLUSH ERROR LOGS; +--connection node_2 +--let $wsrep_last_committed_after = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` +--disable_query_log +--eval SELECT $wsrep_last_committed_after = $wsrep_last_committed_before + 1 AS wsrep_last_committed_diff; +--enable_query_log + + +--connection node_2 +--let $wsrep_last_committed_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` +--connection node_1 +FLUSH SLOW LOGS; +--connection node_2 +--let $wsrep_last_committed_after = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` +--disable_query_log +--eval SELECT $wsrep_last_committed_after = $wsrep_last_committed_before + 1 AS wsrep_last_committed_diff; +--enable_query_log + +--connection node_2 +--let $wsrep_last_committed_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` +--connection node_1 +FLUSH GENERAL LOGS; +--connection node_2 +--let $wsrep_last_committed_after = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` +--disable_query_log +--eval SELECT $wsrep_last_committed_after = $wsrep_last_committed_before + 1 AS wsrep_last_committed_diff; +--enable_query_log + +--connection node_2 +--let $wsrep_last_committed_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` +--connection node_1 +FLUSH ENGINE LOGS; +--connection node_2 +--let $wsrep_last_committed_after = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` +--disable_query_log +--eval SELECT $wsrep_last_committed_after = $wsrep_last_committed_before + 1 AS wsrep_last_committed_diff; +--enable_query_log + +--connection node_2 +--let $wsrep_last_committed_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` +--connection node_1 +FLUSH RELAY LOGS; +--connection node_2 +--let $wsrep_last_committed_after = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` +--disable_query_log +--eval SELECT $wsrep_last_committed_after = $wsrep_last_committed_before + 1 AS wsrep_last_committed_diff; +--enable_query_log + +--connection node_1 +SET @userstat_old= @@userstat; +SET GLOBAL userstat=ON; + +--connection node_2 +--let $wsrep_last_committed_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` +--connection node_1 +FLUSH CLIENT_STATISTICS; +FLUSH INDEX_STATISTICS; +FLUSH TABLE_STATISTICS; +FLUSH USER_STATISTICS; +--connection node_2 +--let $wsrep_last_committed_after = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` +--disable_query_log +--eval SELECT $wsrep_last_committed_after = $wsrep_last_committed_before + 4 AS wsrep_last_committed_diff; +--enable_query_log + + +--connection node_1 +SET @old_thread_statistics= @@global.thread_statistics; +SET GLOBAL thread_statistics= ON; + +--connection node_2 +--let $wsrep_last_committed_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` +--connection node_1 +FLUSH THREAD_STATISTICS; +--connection node_2 +--let $wsrep_last_committed_after = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` +--disable_query_log +--eval SELECT $wsrep_last_committed_after = $wsrep_last_committed_before + 1 AS wsrep_last_committed_diff; +--enable_query_log + + +--connection node_2 +--let $wsrep_last_committed_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` +--connection node_1 +FLUSH CHANGED_PAGE_BITMAPS; +--connection node_2 +--let $wsrep_last_committed_after = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` +--disable_query_log +--eval SELECT $wsrep_last_committed_after = $wsrep_last_committed_before + 1 AS wsrep_last_committed_diff; +--enable_query_log + + # # The following statements should not be replicated: FLUSH LOGS, FLUSH TABLES WITH LOCKS # @@ -171,3 +269,5 @@ FLUSH TABLES t1; --connection node_1 DROP TABLE t1; DROP TABLE t2; +SET GLOBAL userstat= @userstat_old; +SET GLOBAL thread_statistics= @old_thread_statistics; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 7faa319feb0..e8a64a59b2f 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -4670,14 +4670,36 @@ end_with_restore_list: #ifdef WITH_WSREP if (lex->type & ( - REFRESH_GRANT | - REFRESH_HOSTS | - REFRESH_DES_KEY_FILE | + REFRESH_GRANT | + REFRESH_HOSTS | +#ifdef HAVE_OPENSSL + REFRESH_DES_KEY_FILE | +#endif + /* + Write all flush log statements except + FLUSH LOGS + FLUSH BINARY LOGS + Check reload_acl_and_cache for why. + */ + REFRESH_RELAY_LOG | + REFRESH_SLOW_LOG | + REFRESH_GENERAL_LOG | + REFRESH_ENGINE_LOG | + REFRESH_ERROR_LOG | #ifdef HAVE_QUERY_CACHE - REFRESH_QUERY_CACHE_FREE | + REFRESH_QUERY_CACHE_FREE | #endif /* HAVE_QUERY_CACHE */ - REFRESH_STATUS | - REFRESH_USER_RESOURCES)) + REFRESH_STATUS | + REFRESH_USER_RESOURCES | + /* + Percona Server specific + */ + REFRESH_FLUSH_PAGE_BITMAPS | + REFRESH_TABLE_STATS | + REFRESH_INDEX_STATS | + REFRESH_USER_STATS | + REFRESH_CLIENT_STATS | + REFRESH_THREAD_STATS)) { WSREP_TO_ISOLATION_BEGIN_WRTCHK(WSREP_MYSQL_DB, NULL, NULL) } From 7d89deb0a3df4df798e27472a55e32b10ac306b9 Mon Sep 17 00:00:00 2001 From: Teemu Ollakka Date: Thu, 22 Oct 2015 14:59:53 +0300 Subject: [PATCH 37/61] refs codership/mysql-wsrep#198 fixed merge issues --- .../suite/galera/r/galera_flush_local.result | 16 ++-------------- .../suite/galera/t/galera_flush_local.test | 16 ++-------------- sql/sql_parse.cc | 15 +++------------ sql/sql_reload.cc | 7 +++++++ 4 files changed, 14 insertions(+), 40 deletions(-) diff --git a/mysql-test/suite/galera/r/galera_flush_local.result b/mysql-test/suite/galera/r/galera_flush_local.result index f740b0a7f65..ed16255fcef 100644 --- a/mysql-test/suite/galera/r/galera_flush_local.result +++ b/mysql-test/suite/galera/r/galera_flush_local.result @@ -1,7 +1,7 @@ DROP TABLE IF EXISTS t1, t2, x1, x2; CREATE TABLE t1 (f1 INTEGER); CREATE TABLE t2 (f1 INT PRIMARY KEY AUTO_INCREMENT, f2 INTEGER); -SET SESSION wsrep_replicate_myisam = TRUE; +SET GLOBAL wsrep_replicate_myisam = TRUE; CREATE TABLE x1 (f1 INTEGER) ENGINE=MyISAM; CREATE TABLE x2 (f1 INT PRIMARY KEY AUTO_INCREMENT, f2 INTEGER) ENGINE=MyISAM; INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); @@ -21,12 +21,6 @@ FLUSH LOCAL SLOW LOGS; FLUSH LOCAL GENERAL LOGS; FLUSH LOCAL ENGINE LOGS; FLUSH LOCAL RELAY LOGS; -FLUSH LOCAL CLIENT_STATISTICS; -FLUSH LOCAL INDEX_STATISTICS; -FLUSH LOCAL TABLE_STATISTICS; -FLUSH LOCAL USER_STATISTICS; -FLUSH LOCAL THREAD_STATISTICS; -FLUSH LOCAL CHANGED_PAGE_BITMAPS; FLUSH LOCAL LOGS; FLUSH LOCAL BINARY LOGS; FLUSH LOCAL TABLES WITH READ LOCK; @@ -74,7 +68,7 @@ COUNT(*) = 10 DROP TABLE t1, t2, x1, x2; CREATE TABLE t1 (f1 INTEGER); CREATE TABLE t2 (f1 INT PRIMARY KEY AUTO_INCREMENT, f2 INTEGER); -SET SESSION wsrep_replicate_myisam = TRUE; +SET GLOBAL wsrep_replicate_myisam = TRUE; CREATE TABLE x1 (f1 INTEGER) ENGINE=MyISAM; CREATE TABLE x2 (f1 INT PRIMARY KEY AUTO_INCREMENT, f2 INTEGER) ENGINE=MyISAM; INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); @@ -95,12 +89,6 @@ FLUSH SLOW LOGS; FLUSH GENERAL LOGS; FLUSH ENGINE LOGS; FLUSH RELAY LOGS; -FLUSH CLIENT_STATISTICS; -FLUSH INDEX_STATISTICS; -FLUSH TABLE_STATISTICS; -FLUSH USER_STATISTICS; -FLUSH THREAD_STATISTICS; -FLUSH CHANGED_PAGE_BITMAPS; FLUSH LOGS; FLUSH BINARY LOGS; FLUSH TABLES WITH READ LOCK; diff --git a/mysql-test/suite/galera/t/galera_flush_local.test b/mysql-test/suite/galera/t/galera_flush_local.test index 8f578c78e54..733accea71c 100644 --- a/mysql-test/suite/galera/t/galera_flush_local.test +++ b/mysql-test/suite/galera/t/galera_flush_local.test @@ -15,7 +15,7 @@ DROP TABLE IF EXISTS t1, t2, x1, x2; --connection node_1 CREATE TABLE t1 (f1 INTEGER); CREATE TABLE t2 (f1 INT PRIMARY KEY AUTO_INCREMENT, f2 INTEGER); -SET SESSION wsrep_replicate_myisam = TRUE; +SET GLOBAL wsrep_replicate_myisam = TRUE; CREATE TABLE x1 (f1 INTEGER) ENGINE=MyISAM; CREATE TABLE x2 (f1 INT PRIMARY KEY AUTO_INCREMENT, f2 INTEGER) ENGINE=MyISAM; INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); @@ -39,12 +39,6 @@ FLUSH LOCAL SLOW LOGS; FLUSH LOCAL GENERAL LOGS; FLUSH LOCAL ENGINE LOGS; FLUSH LOCAL RELAY LOGS; -FLUSH LOCAL CLIENT_STATISTICS; -FLUSH LOCAL INDEX_STATISTICS; -FLUSH LOCAL TABLE_STATISTICS; -FLUSH LOCAL USER_STATISTICS; -FLUSH LOCAL THREAD_STATISTICS; -FLUSH LOCAL CHANGED_PAGE_BITMAPS; FLUSH LOCAL LOGS; FLUSH LOCAL BINARY LOGS; FLUSH LOCAL TABLES WITH READ LOCK; @@ -80,7 +74,7 @@ SELECT COUNT(*) = 10 FROM x2; DROP TABLE t1, t2, x1, x2; CREATE TABLE t1 (f1 INTEGER); CREATE TABLE t2 (f1 INT PRIMARY KEY AUTO_INCREMENT, f2 INTEGER); -SET SESSION wsrep_replicate_myisam = TRUE; +SET GLOBAL wsrep_replicate_myisam = TRUE; CREATE TABLE x1 (f1 INTEGER) ENGINE=MyISAM; CREATE TABLE x2 (f1 INT PRIMARY KEY AUTO_INCREMENT, f2 INTEGER) ENGINE=MyISAM; INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); @@ -106,12 +100,6 @@ FLUSH SLOW LOGS; FLUSH GENERAL LOGS; FLUSH ENGINE LOGS; FLUSH RELAY LOGS; -FLUSH CLIENT_STATISTICS; -FLUSH INDEX_STATISTICS; -FLUSH TABLE_STATISTICS; -FLUSH USER_STATISTICS; -FLUSH THREAD_STATISTICS; -FLUSH CHANGED_PAGE_BITMAPS; FLUSH LOGS; FLUSH BINARY LOGS; FLUSH TABLES WITH READ LOCK; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index e8a64a59b2f..249f4fb3434 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -4690,16 +4690,7 @@ end_with_restore_list: REFRESH_QUERY_CACHE_FREE | #endif /* HAVE_QUERY_CACHE */ REFRESH_STATUS | - REFRESH_USER_RESOURCES | - /* - Percona Server specific - */ - REFRESH_FLUSH_PAGE_BITMAPS | - REFRESH_TABLE_STATS | - REFRESH_INDEX_STATS | - REFRESH_USER_STATS | - REFRESH_CLIENT_STATS | - REFRESH_THREAD_STATS)) + REFRESH_USER_RESOURCES)) { WSREP_TO_ISOLATION_BEGIN_WRTCHK(WSREP_MYSQL_DB, NULL, NULL) } @@ -4736,11 +4727,11 @@ end_with_restore_list: */ if (first_table) { - WSREP_TO_ISOLATION_BEGIN(NULL, NULL, first_table); + WSREP_TO_ISOLATION_BEGIN_WRTCHK(NULL, NULL, first_table); } else { - WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL); + WSREP_TO_ISOLATION_BEGIN_WRTCHK(WSREP_MYSQL_DB, NULL, NULL); } } #endif /* WITH_WSREP */ diff --git a/sql/sql_reload.cc b/sql/sql_reload.cc index ee05ad7bd36..7a90319a6de 100644 --- a/sql/sql_reload.cc +++ b/sql/sql_reload.cc @@ -29,6 +29,10 @@ #include "debug_sync.h" #include "des_key_file.h" +#ifdef WITH_WSREP +#include "sql_parse.h" // WSREP_MYSQL_DB +#endif /* WITH_WSREP */ + static void disable_checkpoints(THD *thd); /** @@ -365,6 +369,9 @@ bool reload_acl_and_cache(THD *thd, unsigned long long options, result= 1; } } +#ifdef WITH_WSREP +cleanup: +#endif /* WITH_WSREP */ my_dbopt_cleanup(); } if (options & REFRESH_HOSTS) From 5d4fb15e5a2391d7117dfb13203e33f3673dab20 Mon Sep 17 00:00:00 2001 From: Nirbhay Choubey Date: Mon, 22 Feb 2016 22:05:16 -0500 Subject: [PATCH 38/61] Fix for compilation failure. --- sql/sql_cache.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc index 0d3497ad964..6a0f811d3a2 100644 --- a/sql/sql_cache.cc +++ b/sql/sql_cache.cc @@ -1963,7 +1963,7 @@ def_week_frmt: %lu, in_trans: %d, autocommit: %d", unlock(); if (wsrep_sync_wait(thd)) goto err; - if (try_lock(TRUE)) + if (try_lock(thd, Query_cache::TIMEOUT)) goto err; query_block = (Query_cache_block *) my_hash_search(&queries, (uchar*) sql, From 17ac9597163916d418c6cca2641242f20d682956 Mon Sep 17 00:00:00 2001 From: Nirbhay Choubey Date: Mon, 22 Feb 2016 22:07:59 -0500 Subject: [PATCH 39/61] Bug#1421360: Add Percona Server specific FLUSH statements. - Restore FLUSH commands supported by MariaDB (removed in the previous commit) - Adjust test case --- mysql-test/suite/galera/t/galera_flush_local.opt | 2 +- mysql-test/suite/galera/t/galera_flush_local.test | 10 ++++++++-- sql/sql_parse.cc | 6 +++++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/mysql-test/suite/galera/t/galera_flush_local.opt b/mysql-test/suite/galera/t/galera_flush_local.opt index 698bbefe41f..45a0ca24dc7 100644 --- a/mysql-test/suite/galera/t/galera_flush_local.opt +++ b/mysql-test/suite/galera/t/galera_flush_local.opt @@ -1 +1 @@ ---query_cache_type=1 --query_cache_size=1000000 --innodb_track_changed_pages=1 --userstat=1 --thread_statistics=1 +--query_cache_type=1 --query_cache_size=1000000 --userstat=1 --wsrep_replicate_myisam=true diff --git a/mysql-test/suite/galera/t/galera_flush_local.test b/mysql-test/suite/galera/t/galera_flush_local.test index 733accea71c..768f4ea4f1b 100644 --- a/mysql-test/suite/galera/t/galera_flush_local.test +++ b/mysql-test/suite/galera/t/galera_flush_local.test @@ -15,7 +15,6 @@ DROP TABLE IF EXISTS t1, t2, x1, x2; --connection node_1 CREATE TABLE t1 (f1 INTEGER); CREATE TABLE t2 (f1 INT PRIMARY KEY AUTO_INCREMENT, f2 INTEGER); -SET GLOBAL wsrep_replicate_myisam = TRUE; CREATE TABLE x1 (f1 INTEGER) ENGINE=MyISAM; CREATE TABLE x2 (f1 INT PRIMARY KEY AUTO_INCREMENT, f2 INTEGER) ENGINE=MyISAM; INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); @@ -39,6 +38,10 @@ FLUSH LOCAL SLOW LOGS; FLUSH LOCAL GENERAL LOGS; FLUSH LOCAL ENGINE LOGS; FLUSH LOCAL RELAY LOGS; +FLUSH LOCAL CLIENT_STATISTICS; +FLUSH LOCAL INDEX_STATISTICS; +FLUSH LOCAL TABLE_STATISTICS; +FLUSH LOCAL USER_STATISTICS; FLUSH LOCAL LOGS; FLUSH LOCAL BINARY LOGS; FLUSH LOCAL TABLES WITH READ LOCK; @@ -74,7 +77,6 @@ SELECT COUNT(*) = 10 FROM x2; DROP TABLE t1, t2, x1, x2; CREATE TABLE t1 (f1 INTEGER); CREATE TABLE t2 (f1 INT PRIMARY KEY AUTO_INCREMENT, f2 INTEGER); -SET GLOBAL wsrep_replicate_myisam = TRUE; CREATE TABLE x1 (f1 INTEGER) ENGINE=MyISAM; CREATE TABLE x2 (f1 INT PRIMARY KEY AUTO_INCREMENT, f2 INTEGER) ENGINE=MyISAM; INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); @@ -100,6 +102,10 @@ FLUSH SLOW LOGS; FLUSH GENERAL LOGS; FLUSH ENGINE LOGS; FLUSH RELAY LOGS; +FLUSH CLIENT_STATISTICS; +FLUSH INDEX_STATISTICS; +FLUSH TABLE_STATISTICS; +FLUSH USER_STATISTICS; FLUSH LOGS; FLUSH BINARY LOGS; FLUSH TABLES WITH READ LOCK; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 249f4fb3434..d73aac801c2 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -4690,7 +4690,11 @@ end_with_restore_list: REFRESH_QUERY_CACHE_FREE | #endif /* HAVE_QUERY_CACHE */ REFRESH_STATUS | - REFRESH_USER_RESOURCES)) + REFRESH_USER_RESOURCES | + REFRESH_TABLE_STATS | + REFRESH_INDEX_STATS | + REFRESH_USER_STATS | + REFRESH_CLIENT_STATS)) { WSREP_TO_ISOLATION_BEGIN_WRTCHK(WSREP_MYSQL_DB, NULL, NULL) } From 235bebe02ee74154a5782326d7a4d624ec55c07b Mon Sep 17 00:00:00 2001 From: Daniele Sciascia Date: Thu, 22 Oct 2015 17:30:20 +0200 Subject: [PATCH 40/61] refs codership/mysql-wsrep#201 - Eliminates code duplication in query cache patch - Reduces the number of iterations in mysql-wsrep#201.test to shorten the execution time - Adds a new test case that exercises more scenarios --- .../r/galera_query_cache_sync_wait.result | 45 ++++++++++ .../t/galera_query_cache_sync_wait-master.opt | 1 + .../t/galera_query_cache_sync_wait.test | 90 +++++++++++++++++++ .../suite/galera/t/mysql-wsrep#201.test | 2 +- sql/sql_cache.cc | 22 ++--- 5 files changed, 148 insertions(+), 12 deletions(-) create mode 100644 mysql-test/suite/galera/r/galera_query_cache_sync_wait.result create mode 100644 mysql-test/suite/galera/t/galera_query_cache_sync_wait-master.opt create mode 100644 mysql-test/suite/galera/t/galera_query_cache_sync_wait.test diff --git a/mysql-test/suite/galera/r/galera_query_cache_sync_wait.result b/mysql-test/suite/galera/r/galera_query_cache_sync_wait.result new file mode 100644 index 00000000000..e9faff8be8b --- /dev/null +++ b/mysql-test/suite/galera/r/galera_query_cache_sync_wait.result @@ -0,0 +1,45 @@ +CREATE TABLE t1 (id INT PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +SET GLOBAL wsrep_provider_options = "repl.causal_read_timeout=PT1S"; +SET GLOBAL DEBUG = "d,sync.wsrep_apply_cb"; +SET SESSION wsrep_sync_wait = 7; +SELECT MAX(id) FROM t1; +MAX(id) +1 +INSERT INTO t1 VALUES (2); +SELECT MAX(id) FROM t1; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +SET GLOBAL DEBUG = ""; +SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb"; +FLUSH QUERY CACHE; +SET SESSION wsrep_sync_wait = 7; +SET GLOBAL DEBUG = "d,sync.wsrep_apply_cb"; +INSERT INTO t1 VALUES (3); +SELECT MAX(id) FROM t1; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +SET GLOBAL DEBUG = ""; +SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb"; +INSERT INTO t1 VALUES (4); +SET SESSION wsrep_sync_wait = 7; +SELECT MAX(id) FROM t1; +MAX(id) +4 +SET SESSION wsrep_sync_wait = 7; +FLUSH STATUS; +SELECT MAX(id) FROM t1; +MAX(id) +4 +SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'Qcache_hits'; +VARIABLE_VALUE = 1 +1 +SET GLOBAL DEBUG = "d,sync.wsrep_apply_cb"; +INSERT INTO t1 VALUES (5); +SET SESSION wsrep_sync_wait = 7; +SELECT MAX(id) FROM t1 ; +SET GLOBAL DEBUG = ""; +SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb"; +MAX(id) +5 +SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'Qcache_hits'; +VARIABLE_VALUE = 1 +1 diff --git a/mysql-test/suite/galera/t/galera_query_cache_sync_wait-master.opt b/mysql-test/suite/galera/t/galera_query_cache_sync_wait-master.opt new file mode 100644 index 00000000000..a00258bc48c --- /dev/null +++ b/mysql-test/suite/galera/t/galera_query_cache_sync_wait-master.opt @@ -0,0 +1 @@ +--query_cache_type=1 diff --git a/mysql-test/suite/galera/t/galera_query_cache_sync_wait.test b/mysql-test/suite/galera/t/galera_query_cache_sync_wait.test new file mode 100644 index 00000000000..0634eba3264 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_query_cache_sync_wait.test @@ -0,0 +1,90 @@ +--source include/galera_cluster.inc +--source include/have_innodb.inc +--source include/have_debug_sync.inc +--source include/have_query_cache.inc + +CREATE TABLE t1 (id INT PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); + +--connection node_2 +--let $wsrep_provider_options_orig = `SELECT @@wsrep_provider_options` +SET GLOBAL wsrep_provider_options = "repl.causal_read_timeout=PT1S"; +SET GLOBAL DEBUG = "d,sync.wsrep_apply_cb"; +SET SESSION wsrep_sync_wait = 7; +SELECT MAX(id) FROM t1; # first lookup miss + +# +# Query cache hit, wait timeout +# + +--connection node_1 +INSERT INTO t1 VALUES (2); + +--connection node_2 +--error ER_LOCK_WAIT_TIMEOUT +SELECT MAX(id) FROM t1; +SET GLOBAL DEBUG = ""; +SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb"; + +FLUSH QUERY CACHE; +SET SESSION wsrep_sync_wait = 7; +SET GLOBAL DEBUG = "d,sync.wsrep_apply_cb"; + +# +# Query cache miss, wait timeout +# + +--connection node_1 +INSERT INTO t1 VALUES (3); + +--connection node_2 +--error ER_LOCK_WAIT_TIMEOUT +SELECT MAX(id) FROM t1; +SET GLOBAL DEBUG = ""; +SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb"; + +# +# Query cache miss +# + +--connection node_1 +INSERT INTO t1 VALUES (4); + +--connection node_2 +SET SESSION wsrep_sync_wait = 7; +SELECT MAX(id) FROM t1; +SET SESSION wsrep_sync_wait = 7; + +# +# Query cache hit +# + +FLUSH STATUS; +SELECT MAX(id) FROM t1; +SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'Qcache_hits'; +SET GLOBAL DEBUG = "d,sync.wsrep_apply_cb"; + +# +# Query cache invalidated +# + +--connection node_1 +INSERT INTO t1 VALUES (5); + +--connection node_2 +SET SESSION wsrep_sync_wait = 7; +--send SELECT MAX(id) FROM t1 + +--connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2 +--connection node_2a +SET GLOBAL DEBUG = ""; +SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb"; + +--connection node_2 +--reap +SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'Qcache_hits'; + + +--disable_query_log +--eval SET GLOBAL wsrep_provider_options = "$wsrep_provider_options_orig" +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/mysql-wsrep#201.test b/mysql-test/suite/galera/t/mysql-wsrep#201.test index cc842afb6d0..e9327540195 100644 --- a/mysql-test/suite/galera/t/mysql-wsrep#201.test +++ b/mysql-test/suite/galera/t/mysql-wsrep#201.test @@ -12,7 +12,7 @@ SET SESSION wsrep_sync_wait = 7; --disable_query_log ---let $count = 10000 +--let $count = 500 while ($count) { --connection node_1 diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc index 6a0f811d3a2..2e9e90346fb 100644 --- a/sql/sql_cache.cc +++ b/sql/sql_cache.cc @@ -1846,7 +1846,6 @@ Query_cache::send_result_to_client(THD *thd, char *org_sql, uint query_length) goto err; } } - /* Try to obtain an exclusive lock on the query cache. If the cache is disabled or if a full cache flush is in progress, the attempt to @@ -1946,6 +1945,13 @@ def_week_frmt: %lu, in_trans: %d, autocommit: %d", (int)flags.autocommit)); memcpy((uchar *)(sql + (tot_length - QUERY_CACHE_FLAGS_SIZE)), (uchar*) &flags, QUERY_CACHE_FLAGS_SIZE); + +#ifdef WITH_WSREP + bool once_more; + once_more= true; +lookup: +#endif /* WITH_WSREP */ + query_block = (Query_cache_block *) my_hash_search(&queries, (uchar*) sql, tot_length); /* Quick abort on unlocked data */ @@ -1959,21 +1965,15 @@ def_week_frmt: %lu, in_trans: %d, autocommit: %d", DBUG_PRINT("qcache", ("Query in query hash 0x%lx", (ulong)query_block)); #ifdef WITH_WSREP - if (WSREP_CLIENT(thd) && wsrep_must_sync_wait(thd)) { + if (once_more && WSREP_CLIENT(thd) && wsrep_must_sync_wait(thd)) + { unlock(); if (wsrep_sync_wait(thd)) goto err; if (try_lock(thd, Query_cache::TIMEOUT)) goto err; - query_block = (Query_cache_block *) my_hash_search(&queries, - (uchar*) sql, - tot_length); - if (query_block == 0 || - query_block->query()->result() == 0 || - query_block->query()->result()->type != Query_cache_block::RESULT) - { - goto err_unlock; - } + once_more= false; + goto lookup; } #endif /* WITH_WSREP */ From ea0b1837edea0dec524f64aafdfb6cd8216aee78 Mon Sep 17 00:00:00 2001 From: Teemu Ollakka Date: Fri, 23 Oct 2015 09:38:33 +0300 Subject: [PATCH 41/61] refs codership/mysql-wsrep#198 Removed code duplication, PXC specifics * Total order isolation was started twice for FLUSH TABLES, from reload_acl_and_cache() and from mysql_execute_command(). Removed the reload_acl_and_cache() part. * Removed PXC specific stuff from MTR tests --- mysql-test/suite/galera/r/galera_flush.result | 18 ------- mysql-test/suite/galera/t/galera_flush.test | 48 ------------------- sql/sql_reload.cc | 36 -------------- 3 files changed, 102 deletions(-) diff --git a/mysql-test/suite/galera/r/galera_flush.result b/mysql-test/suite/galera/r/galera_flush.result index 620ad1ccb67..27a0ce02217 100644 --- a/mysql-test/suite/galera/r/galera_flush.result +++ b/mysql-test/suite/galera/r/galera_flush.result @@ -42,22 +42,6 @@ wsrep_last_committed_diff FLUSH RELAY LOGS; wsrep_last_committed_diff 1 -SET @userstat_old= @@userstat; -SET GLOBAL userstat=ON; -FLUSH CLIENT_STATISTICS; -FLUSH INDEX_STATISTICS; -FLUSH TABLE_STATISTICS; -FLUSH USER_STATISTICS; -wsrep_last_committed_diff -1 -SET @old_thread_statistics= @@global.thread_statistics; -SET GLOBAL thread_statistics= ON; -FLUSH THREAD_STATISTICS; -wsrep_last_committed_diff -1 -FLUSH CHANGED_PAGE_BITMAPS; -wsrep_last_committed_diff -1 CREATE TABLE t1 (f1 INTEGER); FLUSH LOGS; FLUSH TABLES WITH READ LOCK; @@ -84,5 +68,3 @@ wsrep_last_committed_diff 1 DROP TABLE t1; DROP TABLE t2; -SET GLOBAL userstat= @userstat_old; -SET GLOBAL thread_statistics= @old_thread_statistics; diff --git a/mysql-test/suite/galera/t/galera_flush.test b/mysql-test/suite/galera/t/galera_flush.test index 2a0fdc694fc..b3ec4009288 100644 --- a/mysql-test/suite/galera/t/galera_flush.test +++ b/mysql-test/suite/galera/t/galera_flush.test @@ -155,50 +155,6 @@ FLUSH RELAY LOGS; --eval SELECT $wsrep_last_committed_after = $wsrep_last_committed_before + 1 AS wsrep_last_committed_diff; --enable_query_log ---connection node_1 -SET @userstat_old= @@userstat; -SET GLOBAL userstat=ON; - ---connection node_2 ---let $wsrep_last_committed_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` ---connection node_1 -FLUSH CLIENT_STATISTICS; -FLUSH INDEX_STATISTICS; -FLUSH TABLE_STATISTICS; -FLUSH USER_STATISTICS; ---connection node_2 ---let $wsrep_last_committed_after = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` ---disable_query_log ---eval SELECT $wsrep_last_committed_after = $wsrep_last_committed_before + 4 AS wsrep_last_committed_diff; ---enable_query_log - - ---connection node_1 -SET @old_thread_statistics= @@global.thread_statistics; -SET GLOBAL thread_statistics= ON; - ---connection node_2 ---let $wsrep_last_committed_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` ---connection node_1 -FLUSH THREAD_STATISTICS; ---connection node_2 ---let $wsrep_last_committed_after = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` ---disable_query_log ---eval SELECT $wsrep_last_committed_after = $wsrep_last_committed_before + 1 AS wsrep_last_committed_diff; ---enable_query_log - - ---connection node_2 ---let $wsrep_last_committed_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` ---connection node_1 -FLUSH CHANGED_PAGE_BITMAPS; ---connection node_2 ---let $wsrep_last_committed_after = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` ---disable_query_log ---eval SELECT $wsrep_last_committed_after = $wsrep_last_committed_before + 1 AS wsrep_last_committed_diff; ---enable_query_log - - # # The following statements should not be replicated: FLUSH LOGS, FLUSH TABLES WITH LOCKS # @@ -264,10 +220,6 @@ FLUSH TABLES t1; --eval SELECT $wsrep_last_committed_after = $wsrep_last_committed_before + 1 AS wsrep_last_committed_diff; --enable_query_log - - --connection node_1 DROP TABLE t1; DROP TABLE t2; -SET GLOBAL userstat= @userstat_old; -SET GLOBAL thread_statistics= @old_thread_statistics; diff --git a/sql/sql_reload.cc b/sql/sql_reload.cc index 7a90319a6de..597c38bed40 100644 --- a/sql/sql_reload.cc +++ b/sql/sql_reload.cc @@ -29,9 +29,6 @@ #include "debug_sync.h" #include "des_key_file.h" -#ifdef WITH_WSREP -#include "sql_parse.h" // WSREP_MYSQL_DB -#endif /* WITH_WSREP */ static void disable_checkpoints(THD *thd); @@ -316,36 +313,6 @@ bool reload_acl_and_cache(THD *thd, unsigned long long options, } } } -#ifdef WITH_WSREP - if (WSREP(thd) && !thd->lex->no_write_to_binlog - && (options & REFRESH_TABLES) - && !(options & (REFRESH_FOR_EXPORT|REFRESH_READ_LOCK))) - { - /* - This is done here because LOCK TABLES is not replicated in galera, - the upgrade of which is checked above. Hence, done after/if we - are able to upgrade locks. - - Also, note that, in error log with debug you may see - 'thread holds MDL locks at TI' but since this is a flush - tables and is required for LOCK TABLE WRITE - it can be ignored there. - */ - if (tables) - { - if (wsrep_to_isolation_begin(thd, NULL, NULL, tables)) - { - result= 1; - goto cleanup; - } - } - else if (wsrep_to_isolation_begin(thd, WSREP_MYSQL_DB, NULL, NULL)) - { - result= 1; - goto cleanup; - } - } -#endif /* WITH_WSREP */ #ifdef WITH_WSREP if (thd && thd->wsrep_applier) @@ -369,9 +336,6 @@ bool reload_acl_and_cache(THD *thd, unsigned long long options, result= 1; } } -#ifdef WITH_WSREP -cleanup: -#endif /* WITH_WSREP */ my_dbopt_cleanup(); } if (options & REFRESH_HOSTS) From d45f0c117f195897453a85a0ff7cadb603aa71ce Mon Sep 17 00:00:00 2001 From: Nirbhay Choubey Date: Mon, 22 Feb 2016 22:30:14 -0500 Subject: [PATCH 42/61] refs codership/mysql-wsrep#198: Revert test changes from previous commit Restore tests for FLUSH commands supported by MariaDB. --- mysql-test/suite/galera/r/galera_flush.result | 18 +++++++ mysql-test/suite/galera/t/galera_flush.test | 48 +++++++++++++++++++ 2 files changed, 66 insertions(+) diff --git a/mysql-test/suite/galera/r/galera_flush.result b/mysql-test/suite/galera/r/galera_flush.result index 27a0ce02217..620ad1ccb67 100644 --- a/mysql-test/suite/galera/r/galera_flush.result +++ b/mysql-test/suite/galera/r/galera_flush.result @@ -42,6 +42,22 @@ wsrep_last_committed_diff FLUSH RELAY LOGS; wsrep_last_committed_diff 1 +SET @userstat_old= @@userstat; +SET GLOBAL userstat=ON; +FLUSH CLIENT_STATISTICS; +FLUSH INDEX_STATISTICS; +FLUSH TABLE_STATISTICS; +FLUSH USER_STATISTICS; +wsrep_last_committed_diff +1 +SET @old_thread_statistics= @@global.thread_statistics; +SET GLOBAL thread_statistics= ON; +FLUSH THREAD_STATISTICS; +wsrep_last_committed_diff +1 +FLUSH CHANGED_PAGE_BITMAPS; +wsrep_last_committed_diff +1 CREATE TABLE t1 (f1 INTEGER); FLUSH LOGS; FLUSH TABLES WITH READ LOCK; @@ -68,3 +84,5 @@ wsrep_last_committed_diff 1 DROP TABLE t1; DROP TABLE t2; +SET GLOBAL userstat= @userstat_old; +SET GLOBAL thread_statistics= @old_thread_statistics; diff --git a/mysql-test/suite/galera/t/galera_flush.test b/mysql-test/suite/galera/t/galera_flush.test index b3ec4009288..2a0fdc694fc 100644 --- a/mysql-test/suite/galera/t/galera_flush.test +++ b/mysql-test/suite/galera/t/galera_flush.test @@ -155,6 +155,50 @@ FLUSH RELAY LOGS; --eval SELECT $wsrep_last_committed_after = $wsrep_last_committed_before + 1 AS wsrep_last_committed_diff; --enable_query_log +--connection node_1 +SET @userstat_old= @@userstat; +SET GLOBAL userstat=ON; + +--connection node_2 +--let $wsrep_last_committed_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` +--connection node_1 +FLUSH CLIENT_STATISTICS; +FLUSH INDEX_STATISTICS; +FLUSH TABLE_STATISTICS; +FLUSH USER_STATISTICS; +--connection node_2 +--let $wsrep_last_committed_after = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` +--disable_query_log +--eval SELECT $wsrep_last_committed_after = $wsrep_last_committed_before + 4 AS wsrep_last_committed_diff; +--enable_query_log + + +--connection node_1 +SET @old_thread_statistics= @@global.thread_statistics; +SET GLOBAL thread_statistics= ON; + +--connection node_2 +--let $wsrep_last_committed_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` +--connection node_1 +FLUSH THREAD_STATISTICS; +--connection node_2 +--let $wsrep_last_committed_after = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` +--disable_query_log +--eval SELECT $wsrep_last_committed_after = $wsrep_last_committed_before + 1 AS wsrep_last_committed_diff; +--enable_query_log + + +--connection node_2 +--let $wsrep_last_committed_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` +--connection node_1 +FLUSH CHANGED_PAGE_BITMAPS; +--connection node_2 +--let $wsrep_last_committed_after = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` +--disable_query_log +--eval SELECT $wsrep_last_committed_after = $wsrep_last_committed_before + 1 AS wsrep_last_committed_diff; +--enable_query_log + + # # The following statements should not be replicated: FLUSH LOGS, FLUSH TABLES WITH LOCKS # @@ -220,6 +264,10 @@ FLUSH TABLES t1; --eval SELECT $wsrep_last_committed_after = $wsrep_last_committed_before + 1 AS wsrep_last_committed_diff; --enable_query_log + + --connection node_1 DROP TABLE t1; DROP TABLE t2; +SET GLOBAL userstat= @userstat_old; +SET GLOBAL thread_statistics= @old_thread_statistics; From e9d805b8459ebbebe2629e40e769441a8e96513f Mon Sep 17 00:00:00 2001 From: Philip Stoev Date: Fri, 23 Oct 2015 00:01:16 -0700 Subject: [PATCH 43/61] Refs codership/mysql-wsrep#198 . MTR test case --- .../suite/galera/r/mysql-wsrep#198.result | 18 +++++++++ .../suite/galera/t/mysql-wsrep#198.test | 37 +++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 mysql-test/suite/galera/r/mysql-wsrep#198.result create mode 100644 mysql-test/suite/galera/t/mysql-wsrep#198.test diff --git a/mysql-test/suite/galera/r/mysql-wsrep#198.result b/mysql-test/suite/galera/r/mysql-wsrep#198.result new file mode 100644 index 00000000000..25ba2cb615c --- /dev/null +++ b/mysql-test/suite/galera/r/mysql-wsrep#198.result @@ -0,0 +1,18 @@ +CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB; +CREATE TABLE t2 (id INT PRIMARY KEY) ENGINE=InnoDB; +LOCK TABLE t2 WRITE; +OPTIMIZE TABLE t1,t2;; +REPAIR TABLE t1,t2;; +SET SESSION wsrep_sync_wait = 0; +INSERT INTO t2 VALUES (1); +UNLOCK TABLES; +Table Op Msg_type Msg_text +test.t1 optimize note Table does not support optimize, doing recreate + analyze instead +test.t1 optimize status OK +test.t2 optimize note Table does not support optimize, doing recreate + analyze instead +test.t2 optimize status OK +Table Op Msg_type Msg_text +test.t1 repair note The storage engine for the table doesn't support repair +test.t2 repair note The storage engine for the table doesn't support repair +DROP TABLE t1; +DROP TABLE t2; diff --git a/mysql-test/suite/galera/t/mysql-wsrep#198.test b/mysql-test/suite/galera/t/mysql-wsrep#198.test new file mode 100644 index 00000000000..3be61c024ae --- /dev/null +++ b/mysql-test/suite/galera/t/mysql-wsrep#198.test @@ -0,0 +1,37 @@ +--source include/galera_cluster.inc +--source include/have_innodb.inc +--source include/have_binlog_format_row.inc + +CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB; +CREATE TABLE t2 (id INT PRIMARY KEY) ENGINE=InnoDB; + +--connection node_2 +LOCK TABLE t2 WRITE; + +--connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2 +--connection node_2a +--send OPTIMIZE TABLE t1,t2; + +--connect node_2b, 127.0.0.1, root, , test, $NODE_MYPORT_2 +--connection node_2b +--send REPAIR TABLE t1,t2; + +--connection node_2 +SET SESSION wsrep_sync_wait = 0; +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE = 'Waiting for table metadata lock' +--source include/wait_condition.inc + +--connection node_1 +INSERT INTO t2 VALUES (1); + +--connection node_2 +UNLOCK TABLES; + +--connection node_2a +--reap + +--connection node_2b +--reap + +DROP TABLE t1; +DROP TABLE t2; From c05d85f45d24691831b862dedc52f188deaa13d2 Mon Sep 17 00:00:00 2001 From: Nirbhay Choubey Date: Mon, 22 Feb 2016 22:35:48 -0500 Subject: [PATCH 44/61] Refs codership/mysql-wsrep#198 : Fix test case --- mysql-test/suite/galera/t/mysql-wsrep#198.test | 1 - 1 file changed, 1 deletion(-) diff --git a/mysql-test/suite/galera/t/mysql-wsrep#198.test b/mysql-test/suite/galera/t/mysql-wsrep#198.test index 3be61c024ae..2b05c4ff4d9 100644 --- a/mysql-test/suite/galera/t/mysql-wsrep#198.test +++ b/mysql-test/suite/galera/t/mysql-wsrep#198.test @@ -1,6 +1,5 @@ --source include/galera_cluster.inc --source include/have_innodb.inc ---source include/have_binlog_format_row.inc CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB; CREATE TABLE t2 (id INT PRIMARY KEY) ENGINE=InnoDB; From c6659345a03b14225bfe0a2464a9cc8346a43adf Mon Sep 17 00:00:00 2001 From: Daniele Sciascia Date: Tue, 3 Nov 2015 14:16:08 +0100 Subject: [PATCH 45/61] refs codership/mysql-wsrep#201 Fix remaining issues with wsrep_sync_wait and query cache. - Fixes misplaced call to invalidate query cache in Rows_log_event::do_apply_event(). Query cache was invalidated too early, and allowed old entries to be inserted to the cache. - Reset thd->wsrep_sync_wait_gtid on query cache hit. THD->cleanup_after_query is not called in such cases, and thd->wsrep_sync_wait_gtid remained initialized. --- sql/log_event.cc | 19 +++++++++++++++++++ sql/sql_parse.cc | 6 ++++++ 2 files changed, 25 insertions(+) diff --git a/sql/log_event.cc b/sql/log_event.cc index 3870467e1da..1afa1475931 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -9892,7 +9892,18 @@ int Rows_log_event::do_apply_event(rpl_group_info *rgi) } #ifdef HAVE_QUERY_CACHE +#ifdef WITH_WSREP + /* + Moved invalidation right before the call to rows_event_stmt_cleanup(), + to avoid query cache being polluted with stale entries. + */ + if (! (WSREP(thd) && (thd->wsrep_exec_mode == REPL_RECV))) + { +#endif /* WITH_WSREP */ query_cache.invalidate_locked_for_write(thd, rgi->tables_to_lock); +#ifdef WITH_WSREP + } +#endif /* WITH_WSREP */ #endif } @@ -10080,6 +10091,14 @@ int Rows_log_event::do_apply_event(rpl_group_info *rgi) /* remove trigger's tables */ if (slave_run_triggers_for_rbr) restore_empty_query_table_list(thd->lex); + +#if defined(WITH_WSREP) && defined(HAVE_QUERY_CACHE) + if (WSREP(thd) && thd->wsrep_exec_mode == REPL_RECV) + { + query_cache.invalidate_locked_for_write(thd, rgi->tables_to_lock); + } +#endif /* WITH_WSREP && HAVE_QUERY_CACHE */ + if (get_flags(STMT_END_F) && (error= rows_event_stmt_cleanup(rgi, thd))) slave_rows_error_report(ERROR_LEVEL, thd->is_error() ? 0 : error, diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index d73aac801c2..6b6ca222188 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -7247,6 +7247,12 @@ void mysql_parse(THD *thd, char *rawbuf, uint length, sql_statement_info[SQLCOM_SELECT].m_key); status_var_increment(thd->status_var.com_stat[SQLCOM_SELECT]); thd->update_stats(); +#ifdef WITH_WSREP + if (WSREP_CLIENT(thd)) + { + thd->wsrep_sync_wait_gtid= WSREP_GTID_UNDEFINED; + } +#endif /* WITH_WSREP */ } DBUG_VOID_RETURN; } From 8504330d1d1fc201bc6cb5474afd34c927cc31c8 Mon Sep 17 00:00:00 2001 From: Philip Stoev Date: Fri, 13 Nov 2015 04:03:39 -0800 Subject: [PATCH 46/61] Galera MTR Tests: misc test stability fixes --- mysql-test/suite/galera/galera_2nodes.cnf | 4 ++-- mysql-test/suite/galera/r/galera_create_function.result | 3 +++ mysql-test/suite/galera/t/galera_create_function.test | 8 ++------ 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/mysql-test/suite/galera/galera_2nodes.cnf b/mysql-test/suite/galera/galera_2nodes.cnf index 7e998e387dc..d20080589f1 100644 --- a/mysql-test/suite/galera/galera_2nodes.cnf +++ b/mysql-test/suite/galera/galera_2nodes.cnf @@ -16,7 +16,7 @@ wsrep-sync-wait=7 #ist_port=@OPT.port #sst_port=@OPT.port wsrep-cluster-address=gcomm:// -wsrep_provider_options='base_port=@mysqld.1.#galera_port;gcache.size=10M' +wsrep_provider_options='repl.causal_read_timeout=PT90S;base_port=@mysqld.1.#galera_port;gcache.size=10M' wsrep_node_incoming_address=127.0.0.1:@mysqld.1.port wsrep_sst_receive_address='127.0.0.1:@mysqld.1.#sst_port' @@ -25,7 +25,7 @@ wsrep_sst_receive_address='127.0.0.1:@mysqld.1.#sst_port' #ist_port=@OPT.port #sst_port=@OPT.port wsrep_cluster_address='gcomm://127.0.0.1:@mysqld.1.#galera_port' -wsrep_provider_options='base_port=@mysqld.2.#galera_port;gcache.size=10M' +wsrep_provider_options='repl.causal_read_timeout=PT90S;base_port=@mysqld.2.#galera_port;gcache.size=10M' wsrep_node_incoming_address=127.0.0.1:@mysqld.2.port wsrep_sst_receive_address='127.0.0.1:@mysqld.2.#sst_port' diff --git a/mysql-test/suite/galera/r/galera_create_function.result b/mysql-test/suite/galera/r/galera_create_function.result index 442e2cf0e10..a35d7661a51 100644 --- a/mysql-test/suite/galera/r/galera_create_function.result +++ b/mysql-test/suite/galera/r/galera_create_function.result @@ -24,6 +24,9 @@ f1 CREATE DEFINER=`user1`@`%` FUNCTION `f1`(param INTEGER) RETURNS varchar(200) MODIFIES SQL DATA COMMENT 'f1_comment' RETURN 'abc' latin1 latin1_swedish_ci latin1_swedish_ci +SELECT 1 FROM DUAL; +1 +1 SHOW CREATE FUNCTION f1; Function sql_mode Create Function character_set_client collation_connection Database Collation f1 CREATE DEFINER=`user1`@`%` FUNCTION `f1`(param INTEGER) RETURNS varchar(200) CHARSET latin1 diff --git a/mysql-test/suite/galera/t/galera_create_function.test b/mysql-test/suite/galera/t/galera_create_function.test index fd4903a7b83..0d7cec0114f 100644 --- a/mysql-test/suite/galera/t/galera_create_function.test +++ b/mysql-test/suite/galera/t/galera_create_function.test @@ -33,6 +33,8 @@ RETURN 123; SHOW CREATE FUNCTION f1; --connection node_2 +# Work around codership/mysql-wsrep#228 - SHOW CREATE FUNCTION not covered by wsrep_sync_wait +SELECT 1 FROM DUAL; SHOW CREATE FUNCTION f1; --connection node_1 @@ -49,9 +51,3 @@ DROP FUNCTION f1; DROP FUNCTION f2; DROP USER 'user1'; - - - - - - From 2b7a5d9edbb496f838e64fc57b73d9d984d4fd22 Mon Sep 17 00:00:00 2001 From: Philip Stoev Date: Mon, 16 Nov 2015 03:00:27 -0800 Subject: [PATCH 47/61] Galera MTR Tests: adjust the galera.galera_defaults test for the new MTR default value for repl.causal_read_timeout --- mysql-test/suite/galera/r/galera_defaults.result | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/suite/galera/r/galera_defaults.result b/mysql-test/suite/galera/r/galera_defaults.result index c2814dbcea2..e15301c019e 100644 --- a/mysql-test/suite/galera/r/galera_defaults.result +++ b/mysql-test/suite/galera/r/galera_defaults.result @@ -47,7 +47,7 @@ WSREP_SST_DONOR WSREP_SST_DONOR_REJECTS_QUERIES OFF WSREP_SST_METHOD rsync WSREP_SYNC_WAIT 7 -; ; cert.log_conflicts = no; debug = no; evs.auto_evict = 0; evs.causal_keepalive_period = PT1S; evs.debug_log_mask = 0x1; evs.delay_margin = PT1S; evs.delayed_keep_period = PT30S; evs.inactive_check_period = PT0.5S; evs.inactive_timeout = PT15S; evs.info_log_mask = 0; evs.install_timeout = PT7.5S; evs.join_retrans_period = PT1S; evs.keepalive_period = PT1S; evs.max_install_timeouts = 3; evs.send_window = 4; evs.stats_report_period = PT1M; evs.suspect_timeout = PT5S; evs.use_aggregate = true; evs.user_send_window = 2; evs.version = 0; evs.view_forget_timeout = P1D; ; gcache.keep_pages_size = 0; gcache.mem_size = 0; ; gcache.page_size = 128M; gcache.size = 10M; gcs.fc_debug = 0; gcs.fc_factor = 1.0; gcs.fc_limit = 16; gcs.fc_master_slave = no; gcs.max_packet_size = 64500; gcs.max_throttle = 0.25; ; gcs.recv_q_soft_limit = 0.25; gcs.sync_donor = no; ; gmcast.mcast_addr = ; gmcast.mcast_ttl = 1; gmcast.peer_timeout = PT3S; gmcast.segment = 0; gmcast.time_wait = PT5S; gmcast.version = 0; ; pc.announce_timeout = PT3S; pc.checksum = false; pc.ignore_quorum = false; pc.ignore_sb = false; pc.linger = PT20S; pc.npvo = false; pc.recovery = true; pc.version = 0; pc.wait_prim = true; pc.wait_prim_timeout = P30S; pc.weight = 1; protonet.backend = asio; protonet.version = 0; repl.causal_read_timeout = PT30S; repl.commit_order = 3; repl.key_format = FLAT8; repl.max_ws_size = 2147483647; repl.proto_max = 7; socket.checksum = 2; +; ; cert.log_conflicts = no; debug = no; evs.auto_evict = 0; evs.causal_keepalive_period = PT1S; evs.debug_log_mask = 0x1; evs.delay_margin = PT1S; evs.delayed_keep_period = PT30S; evs.inactive_check_period = PT0.5S; evs.inactive_timeout = PT15S; evs.info_log_mask = 0; evs.install_timeout = PT7.5S; evs.join_retrans_period = PT1S; evs.keepalive_period = PT1S; evs.max_install_timeouts = 3; evs.send_window = 4; evs.stats_report_period = PT1M; evs.suspect_timeout = PT5S; evs.use_aggregate = true; evs.user_send_window = 2; evs.version = 0; evs.view_forget_timeout = P1D; ; gcache.keep_pages_size = 0; gcache.mem_size = 0; ; gcache.page_size = 128M; gcache.size = 10M; gcs.fc_debug = 0; gcs.fc_factor = 1.0; gcs.fc_limit = 16; gcs.fc_master_slave = no; gcs.max_packet_size = 64500; gcs.max_throttle = 0.25; ; gcs.recv_q_soft_limit = 0.25; gcs.sync_donor = no; ; gmcast.mcast_addr = ; gmcast.mcast_ttl = 1; gmcast.peer_timeout = PT3S; gmcast.segment = 0; gmcast.time_wait = PT5S; gmcast.version = 0; ; pc.announce_timeout = PT3S; pc.checksum = false; pc.ignore_quorum = false; pc.ignore_sb = false; pc.linger = PT20S; pc.npvo = false; pc.recovery = true; pc.version = 0; pc.wait_prim = true; pc.wait_prim_timeout = P30S; pc.weight = 1; protonet.backend = asio; protonet.version = 0; repl.causal_read_timeout = PT90S; repl.commit_order = 3; repl.key_format = FLAT8; repl.max_ws_size = 2147483647; repl.proto_max = 7; socket.checksum = 2; SELECT COUNT(*) FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME LIKE 'wsrep_%' AND VARIABLE_NAME != 'wsrep_debug_sync_waiters'; From 5ebf6ce7aa87c256d38c063eb2d3f605c93d964b Mon Sep 17 00:00:00 2001 From: Philip Stoev Date: Mon, 16 Nov 2015 04:06:38 -0800 Subject: [PATCH 48/61] Bump WSREP_PATCH_VERSION in cmake/wsrep.cmake to 12 --- cmake/wsrep.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/wsrep.cmake b/cmake/wsrep.cmake index ac2acb73313..b9b3d352630 100644 --- a/cmake/wsrep.cmake +++ b/cmake/wsrep.cmake @@ -18,7 +18,7 @@ # so WSREP_VERSION is produced regardless # Set the patch version -SET(WSREP_PATCH_VERSION "11") +SET(WSREP_PATCH_VERSION "12") # MariaDB addition: Revision number of the last revision merged from # codership branch visible in @@visible_comment. From 1e14db11ee6cf0f295376d6a13048c8edb10938c Mon Sep 17 00:00:00 2001 From: Daniele Sciascia Date: Mon, 16 Nov 2015 11:57:38 +0100 Subject: [PATCH 49/61] refs codership/mysql-wsrep#228 - Add calls to wsrep_sync_wait for SHOW CREATE DB/PROCEDURE/FUNCTION/TRIGGER/EVENT and SHOW PROCEDURE/FUNCTION CODE --- sql/sql_parse.cc | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 6b6ca222188..f20d578af1c 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -4367,6 +4367,11 @@ end_with_restore_list: db_name.str= db_name_buff; db_name.length= lex->name.length; strmov(db_name.str, lex->name.str); + +#ifdef WITH_WSREP + if (WSREP_CLIENT(thd) && wsrep_sync_wait(thd)) goto error; +#endif /* WITH_WSREP */ + if (check_db_name(&db_name)) { my_error(ER_WRONG_DB_NAME, MYF(0), db_name.str); @@ -4423,6 +4428,9 @@ end_with_restore_list: /* lex->unit.cleanup() is called outside, no need to call it here */ break; case SQLCOM_SHOW_CREATE_EVENT: +#ifdef WITH_WSREP + if (WSREP_CLIENT(thd) && wsrep_sync_wait(thd)) goto error; +#endif /* WITH_WSREP */ res= Events::show_create_event(thd, lex->spname->m_db, lex->spname->m_name); break; @@ -5389,12 +5397,18 @@ create_sp_error: } case SQLCOM_SHOW_CREATE_PROC: { +#ifdef WITH_WSREP + if (WSREP_CLIENT(thd) && wsrep_sync_wait(thd)) goto error; +#endif /* WITH_WSREP */ if (sp_show_create_routine(thd, TYPE_ENUM_PROCEDURE, lex->spname)) goto error; break; } case SQLCOM_SHOW_CREATE_FUNC: { +#ifdef WITH_WSREP + if (WSREP_CLIENT(thd) && wsrep_sync_wait(thd)) goto error; +#endif /* WITH_WSREP */ if (sp_show_create_routine(thd, TYPE_ENUM_FUNCTION, lex->spname)) goto error; break; @@ -5407,6 +5421,9 @@ create_sp_error: stored_procedure_type type= (lex->sql_command == SQLCOM_SHOW_PROC_CODE ? TYPE_ENUM_PROCEDURE : TYPE_ENUM_FUNCTION); +#ifdef WITH_WSREP + if (WSREP_CLIENT(thd) && wsrep_sync_wait(thd)) goto error; +#endif /* WITH_WSREP */ if (sp_cache_routine(thd, type, lex->spname, FALSE, &sp)) goto error; if (!sp || sp->show_routine_code(thd)) @@ -5431,6 +5448,9 @@ create_sp_error: goto error; } +#ifdef WITH_WSREP + if (WSREP_CLIENT(thd) && wsrep_sync_wait(thd)) goto error; +#endif /* WITH_WSREP */ if (show_create_trigger(thd, lex->spname)) goto error; /* Error has been already logged. */ From bf9572ba5925fb7687e5407f4c52a1d429d3d9e3 Mon Sep 17 00:00:00 2001 From: Philip Stoev Date: Wed, 25 Nov 2015 03:36:26 -0800 Subject: [PATCH 50/61] refs codership/mysql-wsrep#228 - a test for wsrep_sync_wait and SHOW --- .../galera/r/galera_sync_wait_show.result | 39 +++++++++++ .../suite/galera/t/galera_sync_wait_show.test | 67 +++++++++++++++++++ 2 files changed, 106 insertions(+) create mode 100644 mysql-test/suite/galera/r/galera_sync_wait_show.result create mode 100644 mysql-test/suite/galera/t/galera_sync_wait_show.test diff --git a/mysql-test/suite/galera/r/galera_sync_wait_show.result b/mysql-test/suite/galera/r/galera_sync_wait_show.result new file mode 100644 index 00000000000..6602d499412 --- /dev/null +++ b/mysql-test/suite/galera/r/galera_sync_wait_show.result @@ -0,0 +1,39 @@ +SET SESSION wsrep_sync_wait = 1; +CREATE DATABASE db1; +SHOW CREATE DATABASE db1; +Database Create Database +db1 CREATE DATABASE `db1` /*!40100 DEFAULT CHARACTER SET latin1 */ +DROP DATABASE db1; +CREATE PROCEDURE p1 () SELECT 1 FROM DUAL; +SHOW CREATE PROCEDURE p1; +Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation +p1 NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` PROCEDURE `p1`() +SELECT 1 FROM DUAL latin1 latin1_swedish_ci latin1_swedish_ci +DROP PROCEDURE p1; +CREATE PROCEDURE p1 () SELECT 1 FROM DUAL; +SHOW PROCEDURE CODE p1; +Pos Instruction +0 stmt "SELECT 1 FROM DUAL" +DROP PROCEDURE p1; +CREATE FUNCTION f1 () RETURNS INTEGER RETURN 123; +SHOW CREATE FUNCTION f1; +Function sql_mode Create Function character_set_client collation_connection Database Collation +f1 NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` FUNCTION `f1`() RETURNS int(11) +RETURN 123 latin1 latin1_swedish_ci latin1_swedish_ci +DROP FUNCTION f1; +CREATE FUNCTION f1 () RETURNS INTEGER RETURN 123; +SHOW FUNCTION CODE f1; +Pos Instruction +0 freturn 3 123 +DROP FUNCTION f1; +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW SET NEW.f1 = 'a'; +SHOW CREATE TRIGGER tr1; +Trigger sql_mode SQL Original Statement character_set_client collation_connection Database Collation +tr1 NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW SET NEW.f1 = 'a' latin1 latin1_swedish_ci latin1_swedish_ci +DROP TABLE t1; +CREATE EVENT event1 ON SCHEDULE AT '2038-01-01 23:59:59' DO SELECT 1; +SHOW CREATE EVENT event1; +Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation +event1 NO_ENGINE_SUBSTITUTION SYSTEM CREATE DEFINER=`root`@`localhost` EVENT `event1` ON SCHEDULE AT '2038-01-01 23:59:59' ON COMPLETION NOT PRESERVE DISABLE ON SLAVE DO SELECT 1 latin1 latin1_swedish_ci latin1_swedish_ci +DROP EVENT event1; diff --git a/mysql-test/suite/galera/t/galera_sync_wait_show.test b/mysql-test/suite/galera/t/galera_sync_wait_show.test new file mode 100644 index 00000000000..d025c8208bc --- /dev/null +++ b/mysql-test/suite/galera/t/galera_sync_wait_show.test @@ -0,0 +1,67 @@ +# +# Test that the various SHOW commands obey wsrep_sync_wait - codership/mysql-wsrep#228 +# + +--source include/galera_cluster.inc + +--connection node_2 +SET SESSION wsrep_sync_wait = 1; + + +--connection node_1 +CREATE DATABASE db1; + +--connection node_2 +SHOW CREATE DATABASE db1; +DROP DATABASE db1; + + +--connection node_1 +CREATE PROCEDURE p1 () SELECT 1 FROM DUAL; + +--connection node_2 +SHOW CREATE PROCEDURE p1; +DROP PROCEDURE p1; + + + +--connection node_1 +CREATE PROCEDURE p1 () SELECT 1 FROM DUAL; + +--connection node_2 +SHOW PROCEDURE CODE p1; +DROP PROCEDURE p1; + + + +--connection node_1 +CREATE FUNCTION f1 () RETURNS INTEGER RETURN 123; + +--connection node_2 +SHOW CREATE FUNCTION f1; +DROP FUNCTION f1; + + +--connection node_1 +CREATE FUNCTION f1 () RETURNS INTEGER RETURN 123; + +--connection node_2 +SHOW FUNCTION CODE f1; +DROP FUNCTION f1; + + +--connection node_1 +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW SET NEW.f1 = 'a'; + +--connection node_2 +SHOW CREATE TRIGGER tr1; +DROP TABLE t1; + + +--connection node_1 +CREATE EVENT event1 ON SCHEDULE AT '2038-01-01 23:59:59' DO SELECT 1; + +--connection node_2 +SHOW CREATE EVENT event1; +DROP EVENT event1; From 18f160d954dcd77a16a994bba4943212b831acbb Mon Sep 17 00:00:00 2001 From: sjaakola Date: Wed, 2 Dec 2015 22:57:46 +0200 Subject: [PATCH 51/61] refs codership/mysql-wsrep#233 - added dbug sync points for further mtr test for this issue --- sql/mdl.cc | 10 ++++++++++ storage/innobase/handler/ha_innodb.cc | 9 +++++++++ 2 files changed, 19 insertions(+) diff --git a/sql/mdl.cc b/sql/mdl.cc index 44831c55b44..2aef46a4fa5 100644 --- a/sql/mdl.cc +++ b/sql/mdl.cc @@ -24,6 +24,7 @@ #include #ifdef WITH_WSREP +#include "debug_sync.h" #include "wsrep_mysqld.h" #include "wsrep_thd.h" extern "C" my_thread_id wsrep_thd_thread_id(THD *thd); @@ -1445,6 +1446,15 @@ MDL_wait::timed_wait(MDL_context_owner *owner, struct timespec *abs_timeout, wait_result != ETIMEDOUT && wait_result != ETIME) { #ifdef WITH_WSREP + // Allow tests to block the applier thread using the DBUG facilities + DBUG_EXECUTE_IF("sync.wsrep_before_mdl_wait", + { + const char act[]= + "now " + "wait_for signal.wsrep_before_mdl_wait"; + DBUG_ASSERT(!debug_sync_set_action((owner->get_thd()), + STRING_WITH_LEN(act))); + };); if (wsrep_thd_is_BF(owner->get_thd(), true)) { wait_result= mysql_cond_wait(&m_COND_wait_status, &m_LOCK_wait_status); diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 8e9fb083f56..a2088d8fe1b 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -17357,6 +17357,15 @@ wsrep_innobase_kill_one_trx( (thd && wsrep_thd_query(thd)) ? wsrep_thd_query(thd) : "void"); wsrep_thd_LOCK(thd); + DBUG_EXECUTE_IF("sync.wsrep_after_BF_victim_lock", + { + const char act[]= + "now " + "wait_for signal.wsrep_after_BF_victim_lock"; + DBUG_ASSERT(!debug_sync_set_action(bf_thd, + STRING_WITH_LEN(act))); + };); + if (wsrep_thd_query_state(thd) == QUERY_EXITING) { WSREP_DEBUG("kill trx EXITING for %lu", victim_trx->id); From 2cdcde93c53a85c34db6b59b5950be6bb0c3225e Mon Sep 17 00:00:00 2001 From: Nirbhay Choubey Date: Tue, 23 Feb 2016 00:19:41 -0500 Subject: [PATCH 52/61] Merge sync point from previous commit to XtraDB. --- storage/xtradb/handler/ha_innodb.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/storage/xtradb/handler/ha_innodb.cc b/storage/xtradb/handler/ha_innodb.cc index cea5286a1ab..634e9a1c6a8 100644 --- a/storage/xtradb/handler/ha_innodb.cc +++ b/storage/xtradb/handler/ha_innodb.cc @@ -18529,6 +18529,15 @@ wsrep_innobase_kill_one_trx( (thd && wsrep_thd_query(thd)) ? wsrep_thd_query(thd) : "void"); wsrep_thd_LOCK(thd); + DBUG_EXECUTE_IF("sync.wsrep_after_BF_victim_lock", + { + const char act[]= + "now " + "wait_for signal.wsrep_after_BF_victim_lock"; + DBUG_ASSERT(!debug_sync_set_action(bf_thd, + STRING_WITH_LEN(act))); + };); + if (wsrep_thd_query_state(thd) == QUERY_EXITING) { WSREP_DEBUG("kill trx EXITING for %lu", victim_trx->id); From 90e5e2f91c2f5be240186b6c08f4cab8c8c8b278 Mon Sep 17 00:00:00 2001 From: sjaakola Date: Wed, 2 Dec 2015 23:16:25 +0200 Subject: [PATCH 53/61] refs codership/mysql-wsrep#233 - added mtr test case for this issue - not a perfect one, depends on some sleeps instead of checking if sync points are met --- .../suite/galera/r/galera_mdl_race.result | 31 ++++++++ .../suite/galera/t/galera_mdl_race.test | 75 +++++++++++++++++++ 2 files changed, 106 insertions(+) create mode 100644 mysql-test/suite/galera/r/galera_mdl_race.result create mode 100644 mysql-test/suite/galera/t/galera_mdl_race.test diff --git a/mysql-test/suite/galera/r/galera_mdl_race.result b/mysql-test/suite/galera/r/galera_mdl_race.result new file mode 100644 index 00000000000..ae4e6ed063c --- /dev/null +++ b/mysql-test/suite/galera/r/galera_mdl_race.result @@ -0,0 +1,31 @@ +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 CHAR(1)); +CREATE TABLE t2 (f1 INTEGER PRIMARY KEY, f2 CHAR(1)); +INSERT INTO t1 VALUES (1, 'a'); +INSERT INTO t1 VALUES (2, 'a'); +SET AUTOCOMMIT=ON; +START TRANSACTION; +UPDATE t1 SET f2 = 'b' WHERE f1 = 1; +LOCK TABLE t2 WRITE; +SET GLOBAL DEBUG = "d,sync.wsrep_before_mdl_wait"; +SELECT * FROM t2;; +SET GLOBAL DEBUG = "d,sync.wsrep_after_BF_victim_lock"; +UPDATE t1 SET f2 = 'c' WHERE f1 = 1; +SET GLOBAL DEBUG = ""; +SET DEBUG_SYNC = "now SIGNAL signal.wsrep_before_mdl_wait"; +SET DEBUG_SYNC = "now SIGNAL signal.wsrep_after_BF_victim_lock"; +UNLOCK TABLES; +ERROR 40001: Deadlock found when trying to get lock; try restarting transaction +SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'a'; +COUNT(*) = 1 +1 +SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'c'; +COUNT(*) = 1 +1 +SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'a'; +COUNT(*) = 1 +1 +SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'c'; +COUNT(*) = 1 +1 +DROP TABLE t1; +DROP TABLE t2; diff --git a/mysql-test/suite/galera/t/galera_mdl_race.test b/mysql-test/suite/galera/t/galera_mdl_race.test new file mode 100644 index 00000000000..c7f03ba2cfb --- /dev/null +++ b/mysql-test/suite/galera/t/galera_mdl_race.test @@ -0,0 +1,75 @@ +# +# This test tests a potential race condition in MDL locking +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc +--source include/have_debug_sync.inc + +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 CHAR(1)); +CREATE TABLE t2 (f1 INTEGER PRIMARY KEY, f2 CHAR(1)); +INSERT INTO t1 VALUES (1, 'a'); +INSERT INTO t1 VALUES (2, 'a'); + +--connection node_1 +SET AUTOCOMMIT=ON; +START TRANSACTION; + +UPDATE t1 SET f2 = 'b' WHERE f1 = 1; + +# block access to t2 +--connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1 +--connection node_1a +LOCK TABLE t2 WRITE; + +# Block before MLD lock wait +--connection node_1 + SET GLOBAL DEBUG = "d,sync.wsrep_before_mdl_wait"; +--send SELECT * FROM t2; + +# Wait for SELECT to be blocked +--connection node_1a +#--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIS WHERE STATE = 'System lock'; +#--source include/wait_condition.inc +#--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE = 'init' AND INFO = 'COMMIT'; +#--source include/wait_condition.inc + +# block applier to wait after BF victim is locked +SET GLOBAL DEBUG = "d,sync.wsrep_after_BF_victim_lock"; + +# Issue a conflicting update on node #2 +--connection node_2 +UPDATE t1 SET f2 = 'c' WHERE f1 = 1; + +--sleep 3 + +# Unblock the SELECT, to enter wsrep_thd_is_BF +--connection node_1a +SET GLOBAL DEBUG = ""; +SET DEBUG_SYNC = "now SIGNAL signal.wsrep_before_mdl_wait"; + +--sleep 3 + +# unblock applier to try to BF the SELECT +SET DEBUG_SYNC = "now SIGNAL signal.wsrep_after_BF_victim_lock"; + + +# table lock is not needed anymore +--sleep 3 +UNLOCK TABLES; + +# SELECT succeeds +--connection node_1 + +--error ER_LOCK_DEADLOCK +--reap + +SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'a'; +SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'c'; + +--connection node_2 +SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'a'; +SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'c'; + +DROP TABLE t1; +DROP TABLE t2; From 32df0b1aac4ebd8ae7232260500ae4d262ca9915 Mon Sep 17 00:00:00 2001 From: sjaakola Date: Wed, 2 Dec 2015 23:20:10 +0200 Subject: [PATCH 54/61] refs codership/mysql-wsrep#233 - avoiding the race condition, by not grabbing thd->LOCK_wsrep_thd for accessing thd->wsrep_exec_mode. The caller is same thread and exec mode can only be changed by self. --- sql/mdl.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/mdl.cc b/sql/mdl.cc index 2aef46a4fa5..daa3d919c15 100644 --- a/sql/mdl.cc +++ b/sql/mdl.cc @@ -1455,7 +1455,7 @@ MDL_wait::timed_wait(MDL_context_owner *owner, struct timespec *abs_timeout, DBUG_ASSERT(!debug_sync_set_action((owner->get_thd()), STRING_WITH_LEN(act))); };); - if (wsrep_thd_is_BF(owner->get_thd(), true)) + if (wsrep_thd_is_BF(owner->get_thd(), false)) { wait_result= mysql_cond_wait(&m_COND_wait_status, &m_LOCK_wait_status); } From b633dbdac955c5a9bd3a589fac56763304cff4f9 Mon Sep 17 00:00:00 2001 From: sjaakola Date: Wed, 23 Dec 2015 09:44:32 +0200 Subject: [PATCH 55/61] refs codership/mysql-wsrep#237 - test for FLUSH TABLES hang in slave node --- .../suite/galera/r/mysql-wsrep#237.result | 10 ++++++ .../suite/galera/t/mysql-wsrep#237.test | 31 +++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 mysql-test/suite/galera/r/mysql-wsrep#237.result create mode 100644 mysql-test/suite/galera/t/mysql-wsrep#237.test diff --git a/mysql-test/suite/galera/r/mysql-wsrep#237.result b/mysql-test/suite/galera/r/mysql-wsrep#237.result new file mode 100644 index 00000000000..3fd9aed1480 --- /dev/null +++ b/mysql-test/suite/galera/r/mysql-wsrep#237.result @@ -0,0 +1,10 @@ +CREATE TABLE t (f1 INTEGER PRIMARY KEY) Engine=InnoDB; +SET DEBUG_SYNC = 'wsrep_before_replication WAIT_FOR continue'; +INSERT INTO t values (1);; +SET SESSION wsrep_sync_wait = 0; +FLUSH TABLES; +SELECT SLEEP(1); +SLEEP(1) +0 +SET DEBUG_SYNC= 'now SIGNAL continue'; +DROP TABLE t; diff --git a/mysql-test/suite/galera/t/mysql-wsrep#237.test b/mysql-test/suite/galera/t/mysql-wsrep#237.test new file mode 100644 index 00000000000..7a65cb52ae9 --- /dev/null +++ b/mysql-test/suite/galera/t/mysql-wsrep#237.test @@ -0,0 +1,31 @@ +# hang because of replicated FLUSH TABLE command + +--source include/galera_cluster.inc +--source include/have_innodb.inc +--source include/have_debug_sync.inc + +CREATE TABLE t (f1 INTEGER PRIMARY KEY) Engine=InnoDB; + +--connection node_1 +SET DEBUG_SYNC = 'wsrep_before_replication WAIT_FOR continue'; +--send INSERT INTO t values (1); + +--connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1 +--connection node_1a +SET SESSION wsrep_sync_wait = 0; +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE = 'debug sync point: wsrep_before_replication' +--source include/wait_condition.inc + +--connection node_2 +FLUSH TABLES; + + +--connection node_1a +SELECT SLEEP(1); + +SET DEBUG_SYNC= 'now SIGNAL continue'; + +--connection node_1 +--reap + +DROP TABLE t; From 15118d35612814ccf549ba49ed1200a7f8fa71c8 Mon Sep 17 00:00:00 2001 From: Nirbhay Choubey Date: Tue, 23 Feb 2016 00:30:47 -0500 Subject: [PATCH 56/61] refs codership/mysql-wsrep#237: Add sync point for mtr test. --- sql/wsrep_hton.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sql/wsrep_hton.cc b/sql/wsrep_hton.cc index 812d64c8c82..e5ff462eb19 100644 --- a/sql/wsrep_hton.cc +++ b/sql/wsrep_hton.cc @@ -22,6 +22,7 @@ #include "wsrep_xid.h" #include #include +#include "debug_sync.h" extern ulonglong thd_to_trx_id(THD *thd); @@ -321,6 +322,8 @@ wsrep_run_wsrep_commit(THD *thd, handlerton *hton, bool all) DBUG_ENTER("wsrep_run_wsrep_commit"); + DEBUG_SYNC(thd, "wsrep_before_replication"); + if (thd->slave_thread && !opt_log_slave_updates) DBUG_RETURN(WSREP_TRX_OK); if (thd->wsrep_exec_mode == REPL_RECV) { From b9c42d7a47f7282f5d0063a467d506cb55a69899 Mon Sep 17 00:00:00 2001 From: Philip Stoev Date: Mon, 11 Jan 2016 11:57:22 +0200 Subject: [PATCH 57/61] Bump WSREP_PATCH_VERSION in cmake/wsrep.cmake to 13 --- cmake/wsrep.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/wsrep.cmake b/cmake/wsrep.cmake index b9b3d352630..d3c122c9b18 100644 --- a/cmake/wsrep.cmake +++ b/cmake/wsrep.cmake @@ -18,7 +18,7 @@ # so WSREP_VERSION is produced regardless # Set the patch version -SET(WSREP_PATCH_VERSION "12") +SET(WSREP_PATCH_VERSION "13") # MariaDB addition: Revision number of the last revision merged from # codership branch visible in @@visible_comment. From 276d65b324f4f0021bc457b4d5723153d4e12608 Mon Sep 17 00:00:00 2001 From: Nirbhay Choubey Date: Tue, 23 Feb 2016 20:33:21 -0500 Subject: [PATCH 58/61] Fix for test failures. --- mysql-test/suite/galera/disabled.def | 2 ++ mysql-test/suite/galera/r/galera_flush_local.result | 10 ++++++++-- mysql-test/suite/galera/r/galera_mdl_race.result | 7 +++++++ .../galera/r/galera_query_cache_sync_wait.result | 13 +++++++++++++ .../suite/galera/r/galera_sync_wait_show.result | 10 +++++----- mysql-test/suite/galera/t/galera_mdl_race.test | 4 ++++ .../suite/galera/t/galera_query_cache-master.opt | 2 -- .../t/galera_query_cache_sync_wait-master.opt | 2 +- .../galera/t/galera_query_cache_sync_wait.test | 4 ++++ .../suite/galera/t/galera_sync_wait_show.test | 1 + mysql-test/suite/galera/t/mysql-wsrep#31.test | 2 +- sql/sql_admin.cc | 3 --- sql/sql_parse.h | 8 +++++--- sql/wsrep_applier.cc | 11 +++++++++++ 14 files changed, 62 insertions(+), 17 deletions(-) diff --git a/mysql-test/suite/galera/disabled.def b/mysql-test/suite/galera/disabled.def index 85d8614c91f..9391f97732b 100644 --- a/mysql-test/suite/galera/disabled.def +++ b/mysql-test/suite/galera/disabled.def @@ -27,3 +27,5 @@ galera_ssl_upgrade : TODO: investigate mysql-wsrep#90 : TODO: investigate galera_flush : mysql-wsrep/issues/229 galera_transaction_read_only : mysql-wsrep/issues/229 +galera_gcs_fragment : Incorrect arguments to SET +galera_flush_local : Fails sporadically diff --git a/mysql-test/suite/galera/r/galera_flush_local.result b/mysql-test/suite/galera/r/galera_flush_local.result index ed16255fcef..3fdd541b513 100644 --- a/mysql-test/suite/galera/r/galera_flush_local.result +++ b/mysql-test/suite/galera/r/galera_flush_local.result @@ -1,7 +1,6 @@ DROP TABLE IF EXISTS t1, t2, x1, x2; CREATE TABLE t1 (f1 INTEGER); CREATE TABLE t2 (f1 INT PRIMARY KEY AUTO_INCREMENT, f2 INTEGER); -SET GLOBAL wsrep_replicate_myisam = TRUE; CREATE TABLE x1 (f1 INTEGER) ENGINE=MyISAM; CREATE TABLE x2 (f1 INT PRIMARY KEY AUTO_INCREMENT, f2 INTEGER) ENGINE=MyISAM; INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); @@ -21,6 +20,10 @@ FLUSH LOCAL SLOW LOGS; FLUSH LOCAL GENERAL LOGS; FLUSH LOCAL ENGINE LOGS; FLUSH LOCAL RELAY LOGS; +FLUSH LOCAL CLIENT_STATISTICS; +FLUSH LOCAL INDEX_STATISTICS; +FLUSH LOCAL TABLE_STATISTICS; +FLUSH LOCAL USER_STATISTICS; FLUSH LOCAL LOGS; FLUSH LOCAL BINARY LOGS; FLUSH LOCAL TABLES WITH READ LOCK; @@ -68,7 +71,6 @@ COUNT(*) = 10 DROP TABLE t1, t2, x1, x2; CREATE TABLE t1 (f1 INTEGER); CREATE TABLE t2 (f1 INT PRIMARY KEY AUTO_INCREMENT, f2 INTEGER); -SET GLOBAL wsrep_replicate_myisam = TRUE; CREATE TABLE x1 (f1 INTEGER) ENGINE=MyISAM; CREATE TABLE x2 (f1 INT PRIMARY KEY AUTO_INCREMENT, f2 INTEGER) ENGINE=MyISAM; INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); @@ -89,6 +91,10 @@ FLUSH SLOW LOGS; FLUSH GENERAL LOGS; FLUSH ENGINE LOGS; FLUSH RELAY LOGS; +FLUSH CLIENT_STATISTICS; +FLUSH INDEX_STATISTICS; +FLUSH TABLE_STATISTICS; +FLUSH USER_STATISTICS; FLUSH LOGS; FLUSH BINARY LOGS; FLUSH TABLES WITH READ LOCK; diff --git a/mysql-test/suite/galera/r/galera_mdl_race.result b/mysql-test/suite/galera/r/galera_mdl_race.result index ae4e6ed063c..535f20de7f1 100644 --- a/mysql-test/suite/galera/r/galera_mdl_race.result +++ b/mysql-test/suite/galera/r/galera_mdl_race.result @@ -7,10 +7,16 @@ START TRANSACTION; UPDATE t1 SET f2 = 'b' WHERE f1 = 1; LOCK TABLE t2 WRITE; SET GLOBAL DEBUG = "d,sync.wsrep_before_mdl_wait"; +Warnings: +Warning 1287 '@@debug' is deprecated and will be removed in a future release. Please use '@@debug_dbug' instead SELECT * FROM t2;; SET GLOBAL DEBUG = "d,sync.wsrep_after_BF_victim_lock"; +Warnings: +Warning 1287 '@@debug' is deprecated and will be removed in a future release. Please use '@@debug_dbug' instead UPDATE t1 SET f2 = 'c' WHERE f1 = 1; SET GLOBAL DEBUG = ""; +Warnings: +Warning 1287 '@@debug' is deprecated and will be removed in a future release. Please use '@@debug_dbug' instead SET DEBUG_SYNC = "now SIGNAL signal.wsrep_before_mdl_wait"; SET DEBUG_SYNC = "now SIGNAL signal.wsrep_after_BF_victim_lock"; UNLOCK TABLES; @@ -29,3 +35,4 @@ COUNT(*) = 1 1 DROP TABLE t1; DROP TABLE t2; +SET DEBUG_SYNC = "RESET"; diff --git a/mysql-test/suite/galera/r/galera_query_cache_sync_wait.result b/mysql-test/suite/galera/r/galera_query_cache_sync_wait.result index e9faff8be8b..856abbb43be 100644 --- a/mysql-test/suite/galera/r/galera_query_cache_sync_wait.result +++ b/mysql-test/suite/galera/r/galera_query_cache_sync_wait.result @@ -2,6 +2,8 @@ CREATE TABLE t1 (id INT PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB; INSERT INTO t1 VALUES (1); SET GLOBAL wsrep_provider_options = "repl.causal_read_timeout=PT1S"; SET GLOBAL DEBUG = "d,sync.wsrep_apply_cb"; +Warnings: +Warning 1287 '@@debug' is deprecated and will be removed in a future release. Please use '@@debug_dbug' instead SET SESSION wsrep_sync_wait = 7; SELECT MAX(id) FROM t1; MAX(id) @@ -10,14 +12,21 @@ INSERT INTO t1 VALUES (2); SELECT MAX(id) FROM t1; ERROR HY000: Lock wait timeout exceeded; try restarting transaction SET GLOBAL DEBUG = ""; +Warnings: +Warning 1287 '@@debug' is deprecated and will be removed in a future release. Please use '@@debug_dbug' instead SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb"; FLUSH QUERY CACHE; SET SESSION wsrep_sync_wait = 7; SET GLOBAL DEBUG = "d,sync.wsrep_apply_cb"; +Warnings: +Warning 1287 '@@debug' is deprecated and will be removed in a future release. Please use '@@debug_dbug' instead +SET DEBUG_SYNC = "RESET"; INSERT INTO t1 VALUES (3); SELECT MAX(id) FROM t1; ERROR HY000: Lock wait timeout exceeded; try restarting transaction SET GLOBAL DEBUG = ""; +Warnings: +Warning 1287 '@@debug' is deprecated and will be removed in a future release. Please use '@@debug_dbug' instead SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb"; INSERT INTO t1 VALUES (4); SET SESSION wsrep_sync_wait = 7; @@ -33,10 +42,14 @@ SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_ VARIABLE_VALUE = 1 1 SET GLOBAL DEBUG = "d,sync.wsrep_apply_cb"; +Warnings: +Warning 1287 '@@debug' is deprecated and will be removed in a future release. Please use '@@debug_dbug' instead INSERT INTO t1 VALUES (5); SET SESSION wsrep_sync_wait = 7; SELECT MAX(id) FROM t1 ; SET GLOBAL DEBUG = ""; +Warnings: +Warning 1287 '@@debug' is deprecated and will be removed in a future release. Please use '@@debug_dbug' instead SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb"; MAX(id) 5 diff --git a/mysql-test/suite/galera/r/galera_sync_wait_show.result b/mysql-test/suite/galera/r/galera_sync_wait_show.result index 6602d499412..c719aaab5d8 100644 --- a/mysql-test/suite/galera/r/galera_sync_wait_show.result +++ b/mysql-test/suite/galera/r/galera_sync_wait_show.result @@ -7,18 +7,18 @@ DROP DATABASE db1; CREATE PROCEDURE p1 () SELECT 1 FROM DUAL; SHOW CREATE PROCEDURE p1; Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation -p1 NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` PROCEDURE `p1`() +p1 CREATE DEFINER=`root`@`localhost` PROCEDURE `p1`() SELECT 1 FROM DUAL latin1 latin1_swedish_ci latin1_swedish_ci DROP PROCEDURE p1; CREATE PROCEDURE p1 () SELECT 1 FROM DUAL; SHOW PROCEDURE CODE p1; Pos Instruction -0 stmt "SELECT 1 FROM DUAL" +0 stmt 0 "SELECT 1 FROM DUAL" DROP PROCEDURE p1; CREATE FUNCTION f1 () RETURNS INTEGER RETURN 123; SHOW CREATE FUNCTION f1; Function sql_mode Create Function character_set_client collation_connection Database Collation -f1 NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` FUNCTION `f1`() RETURNS int(11) +f1 CREATE DEFINER=`root`@`localhost` FUNCTION `f1`() RETURNS int(11) RETURN 123 latin1 latin1_swedish_ci latin1_swedish_ci DROP FUNCTION f1; CREATE FUNCTION f1 () RETURNS INTEGER RETURN 123; @@ -30,10 +30,10 @@ CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW SET NEW.f1 = 'a'; SHOW CREATE TRIGGER tr1; Trigger sql_mode SQL Original Statement character_set_client collation_connection Database Collation -tr1 NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW SET NEW.f1 = 'a' latin1 latin1_swedish_ci latin1_swedish_ci +tr1 CREATE DEFINER=`root`@`localhost` TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW SET NEW.f1 = 'a' latin1 latin1_swedish_ci latin1_swedish_ci DROP TABLE t1; CREATE EVENT event1 ON SCHEDULE AT '2038-01-01 23:59:59' DO SELECT 1; SHOW CREATE EVENT event1; Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation -event1 NO_ENGINE_SUBSTITUTION SYSTEM CREATE DEFINER=`root`@`localhost` EVENT `event1` ON SCHEDULE AT '2038-01-01 23:59:59' ON COMPLETION NOT PRESERVE DISABLE ON SLAVE DO SELECT 1 latin1 latin1_swedish_ci latin1_swedish_ci +event1 SYSTEM CREATE DEFINER=`root`@`localhost` EVENT `event1` ON SCHEDULE AT '2038-01-01 23:59:59' ON COMPLETION NOT PRESERVE DISABLE ON SLAVE DO SELECT 1 latin1 latin1_swedish_ci latin1_swedish_ci DROP EVENT event1; diff --git a/mysql-test/suite/galera/t/galera_mdl_race.test b/mysql-test/suite/galera/t/galera_mdl_race.test index c7f03ba2cfb..508b85add4b 100644 --- a/mysql-test/suite/galera/t/galera_mdl_race.test +++ b/mysql-test/suite/galera/t/galera_mdl_race.test @@ -73,3 +73,7 @@ SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'c'; DROP TABLE t1; DROP TABLE t2; + +--connection node_1a +SET DEBUG_SYNC = "RESET"; + diff --git a/mysql-test/suite/galera/t/galera_query_cache-master.opt b/mysql-test/suite/galera/t/galera_query_cache-master.opt index cb983993b91..915a36c0937 100644 --- a/mysql-test/suite/galera/t/galera_query_cache-master.opt +++ b/mysql-test/suite/galera/t/galera_query_cache-master.opt @@ -1,3 +1 @@ --query_cache_type=1 --query_cache_size=1355776 - - diff --git a/mysql-test/suite/galera/t/galera_query_cache_sync_wait-master.opt b/mysql-test/suite/galera/t/galera_query_cache_sync_wait-master.opt index a00258bc48c..915a36c0937 100644 --- a/mysql-test/suite/galera/t/galera_query_cache_sync_wait-master.opt +++ b/mysql-test/suite/galera/t/galera_query_cache_sync_wait-master.opt @@ -1 +1 @@ ---query_cache_type=1 +--query_cache_type=1 --query_cache_size=1355776 diff --git a/mysql-test/suite/galera/t/galera_query_cache_sync_wait.test b/mysql-test/suite/galera/t/galera_query_cache_sync_wait.test index 0634eba3264..6b14118d5fc 100644 --- a/mysql-test/suite/galera/t/galera_query_cache_sync_wait.test +++ b/mysql-test/suite/galera/t/galera_query_cache_sync_wait.test @@ -29,6 +29,7 @@ SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb"; FLUSH QUERY CACHE; SET SESSION wsrep_sync_wait = 7; SET GLOBAL DEBUG = "d,sync.wsrep_apply_cb"; +SET DEBUG_SYNC = "RESET"; # # Query cache miss, wait timeout @@ -88,3 +89,6 @@ SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_ --disable_query_log --eval SET GLOBAL wsrep_provider_options = "$wsrep_provider_options_orig" DROP TABLE t1; + +--connection node_2a +SET DEBUG_SYNC = "RESET"; diff --git a/mysql-test/suite/galera/t/galera_sync_wait_show.test b/mysql-test/suite/galera/t/galera_sync_wait_show.test index d025c8208bc..0d0207a2ebe 100644 --- a/mysql-test/suite/galera/t/galera_sync_wait_show.test +++ b/mysql-test/suite/galera/t/galera_sync_wait_show.test @@ -3,6 +3,7 @@ # --source include/galera_cluster.inc +--source include/have_innodb.inc --connection node_2 SET SESSION wsrep_sync_wait = 1; diff --git a/mysql-test/suite/galera/t/mysql-wsrep#31.test b/mysql-test/suite/galera/t/mysql-wsrep#31.test index b6b6d1ebb4d..eaace5d50dd 100644 --- a/mysql-test/suite/galera/t/mysql-wsrep#31.test +++ b/mysql-test/suite/galera/t/mysql-wsrep#31.test @@ -30,7 +30,7 @@ if ($galera_wsrep_start_position != $expected_position) --let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size' --source include/wait_condition.inc ---source include/galera_wait_ready.inc +--source include/wait_until_ready.inc --connection node_1 DROP TABLE t1; diff --git a/sql/sql_admin.cc b/sql/sql_admin.cc index 3ed8545bcb4..507840772f5 100644 --- a/sql/sql_admin.cc +++ b/sql/sql_admin.cc @@ -1177,9 +1177,6 @@ bool Sql_cmd_analyze_table::execute(THD *thd) goto error; WSREP_TO_ISOLATION_BEGIN_WRTCHK(NULL, NULL, first_table); thd->enable_slow_log= opt_log_slow_admin_statements; -#ifdef WITH_WSREP - WSREP_TO_ISOLATION_BEGIN(first_table->db, first_table->table_name, NULL); -#endif res= mysql_admin_table(thd, first_table, &m_lex->check_opt, "analyze", lock_type, 1, 0, 0, 0, &handler::ha_analyze, 0); diff --git a/sql/sql_parse.h b/sql/sql_parse.h index 16d2986f031..859a1f21202 100644 --- a/sql/sql_parse.h +++ b/sql/sql_parse.h @@ -215,8 +215,9 @@ inline bool is_supported_parser_charset(CHARSET_INFO *cs) if (WSREP(thd) || (thd && thd->wsrep_exec_mode==TOTAL_ORDER)) \ wsrep_to_isolation_end(thd); -/* Checks if lex->no_write_to_binlog is set for statements that use - LOCAL or NO_WRITE_TO_BINLOG +/* + Checks if lex->no_write_to_binlog is set for statements that use LOCAL or + NO_WRITE_TO_BINLOG. */ #define WSREP_TO_ISOLATION_BEGIN_WRTCHK(db_, table_, table_list_) \ if (WSREP(thd) && !thd->lex->no_write_to_binlog \ @@ -225,7 +226,8 @@ inline bool is_supported_parser_charset(CHARSET_INFO *cs) #else #define WSREP_TO_ISOLATION_BEGIN(db_, table_, table_list_) -#define WSREP_TO_ISOLATION_END +#define WSREP_TO_ISOLATION_END +#define WSREP_TO_ISOLATION_BEGIN_WRTCHK(db_, table_, table_list_) #endif /* WITH_WSREP */ diff --git a/sql/wsrep_applier.cc b/sql/wsrep_applier.cc index 520e63f3077..90c84f1c2cc 100644 --- a/sql/wsrep_applier.cc +++ b/sql/wsrep_applier.cc @@ -19,6 +19,7 @@ #include "wsrep_xid.h" #include "log_event.h" // class THD, EVENT_LEN_OFFSET, etc. +#include "debug_sync.h" /* read the first event from (*buf). The size of the (*buf) is (*buf_len). @@ -222,6 +223,16 @@ wsrep_cb_status_t wsrep_apply_cb(void* const ctx, { THD* const thd((THD*)ctx); + // Allow tests to block the applier thread using the DBUG facilities. + DBUG_EXECUTE_IF("sync.wsrep_apply_cb", + { + const char act[]= + "now " + "wait_for signal.wsrep_apply_cb"; + DBUG_ASSERT(!debug_sync_set_action(thd, + STRING_WITH_LEN(act))); + };); + thd->wsrep_trx_meta = *meta; #ifdef WSREP_PROC_INFO From 0fd9d5a6568406c6c3fe481b72bf744b3a3f59cd Mon Sep 17 00:00:00 2001 From: Nirbhay Choubey Date: Tue, 23 Feb 2016 21:24:00 -0500 Subject: [PATCH 59/61] Update WSREP_PATCH_REVNO. --- cmake/wsrep.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/wsrep.cmake b/cmake/wsrep.cmake index d3c122c9b18..61e41778166 100644 --- a/cmake/wsrep.cmake +++ b/cmake/wsrep.cmake @@ -23,7 +23,7 @@ SET(WSREP_PATCH_VERSION "13") # MariaDB addition: Revision number of the last revision merged from # codership branch visible in @@visible_comment. # Branch : https://github.com/codership/mysql-wsrep/tree/5.6 -SET(WSREP_PATCH_REVNO "21a2415") # Should be updated on every merge. +SET(WSREP_PATCH_REVNO "af7f02e") # Should be updated on every merge. # MariaDB: Obtain patch revision number: # Update WSREP_PATCH_REVNO if WSREP_REV environment variable is set. From 0cf66e49dbe6a13533769f325a615f357d31df98 Mon Sep 17 00:00:00 2001 From: Krunal Bauskar Date: Thu, 22 Oct 2015 14:56:29 +0530 Subject: [PATCH 60/61] - PXC#460: wsrep_sst_auth don't work in Percona-XtraDB-Cluster-56-5.6.25-25.12.1.el7 Semantics: --------- * Generally end-user will create a separate user with needed privileges for performing DONOR action. * This user credentials are specified using wsrep_sst_auth. * Along with this user there could be other user(s) created on the server that sysadmin may use for normal or other operations * Credentials for these user(s) can be specified in same cluster/server cnf file as part of [client] section When cluster act as DONOR and if wsrep_sst_auth is provided then it should strictly use it for performing SST based action. What if end-user has same credentials for performing both SST action and normal admin work ? * Then end-user can simply specify these credentials as part of [client] section in cnf file and skip providing wsrep_sst_auth. Issue: ----- MySQL client user/password parsing preference order is as follows: * command line (through --user/--password) * cnf file * MYSQL_PWD enviornment variable. Recent change tried passing sst user password through MYSQL_PWD (and user though --user command line param as before). On the system where-in admin had another user for performing non-SST actions, credentials for such user were present in cnf file under [client] section. Due to mysql client preference order, SST user name was used (as it was passed through command line) but password of other user (meant for non-SST) action was being used as it was passed through cnf file. Password passed through MYSQL_PWD was completely ignored causing user-name/password mismatch. Solution: --------- * If user has specified credentials for SST then pass them through command line so that they are used in priority. (There could be security concern on passing things through command line but when I tried passing user-name and password through command line to mysql client and then did ps I saw this ./bin/mysql --user=sstuser --password=x xxxxxxxx -S /tmp/n1.sock so seems like password is not shown) --- scripts/wsrep_sst_xtrabackup-v2.sh | 5 ++--- scripts/wsrep_sst_xtrabackup.sh | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/scripts/wsrep_sst_xtrabackup-v2.sh b/scripts/wsrep_sst_xtrabackup-v2.sh index e3ad8257df6..2634fead919 100644 --- a/scripts/wsrep_sst_xtrabackup-v2.sh +++ b/scripts/wsrep_sst_xtrabackup-v2.sh @@ -689,9 +689,8 @@ then INNOEXTRA+=" --user=$WSREP_SST_OPT_USER" fi - if [ -n "$WSREP_SST_OPT_PSWD" ]; then -# INNOEXTRA+=" --password=$WSREP_SST_OPT_PSWD" - export MYSQL_PWD="$WSREP_SST_OPT_PSWD" + if [ -n "${WSREP_SST_OPT_PSWD:-}" ]; then + INNOEXTRA+=" --password=$WSREP_SST_OPT_PSWD" else # Empty password, used for testing, debugging etc. INNOEXTRA+=" --password=" diff --git a/scripts/wsrep_sst_xtrabackup.sh b/scripts/wsrep_sst_xtrabackup.sh index 7279c623288..4acf2854301 100644 --- a/scripts/wsrep_sst_xtrabackup.sh +++ b/scripts/wsrep_sst_xtrabackup.sh @@ -442,9 +442,8 @@ then INNOEXTRA+=" --user=$WSREP_SST_OPT_USER" fi - if [ -n "$WSREP_SST_OPT_PSWD" ]; then -# INNOEXTRA+=" --password=$WSREP_SST_OPT_PSWD" - export MYSQL_PWD="$WSREP_SST_OPT_PSWD" + if [ -n "${WSREP_SST_OPT_PSWD:-}" ]; then + INNOEXTRA+=" --password=$WSREP_SST_OPT_PSWD" else # Empty password, used for testing, debugging etc. INNOEXTRA+=" --password=" From f67d6fccacfb8a2963f23448cabb67c6178d2a10 Mon Sep 17 00:00:00 2001 From: Krunal Bauskar Date: Fri, 4 Dec 2015 15:09:08 +0530 Subject: [PATCH 61/61] - PXC#480: xtrabackup-v2 SST fails with multiple log_bin directives in my.cnf If any given variable the xtrabackup-v2 sst script looks for is specified multiple times in cnf file then it tend to pick both of them causing some of the follow-up command to fail. Avoid this programatic mistake by honoring only the last variable assigned setting as done by mysqld too. Check https://bugs.launchpad.net/percona-xtradb-cluster/+bug/1362830 --- scripts/wsrep_sst_xtrabackup-v2.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/wsrep_sst_xtrabackup-v2.sh b/scripts/wsrep_sst_xtrabackup-v2.sh index 2634fead919..6357d811e44 100644 --- a/scripts/wsrep_sst_xtrabackup-v2.sh +++ b/scripts/wsrep_sst_xtrabackup-v2.sh @@ -240,7 +240,11 @@ parse_cnf() { local group=$1 local var=$2 - reval=$($MY_PRINT_DEFAULTS -c $WSREP_SST_OPT_CONF $group | awk -F= '{if ($1 ~ /_/) { gsub(/_/,"-",$1); print $1"="$2 } else { print $0 }}' | grep -- "--$var=" | cut -d= -f2-) + # print the default settings for given group using my_print_default. + # normalize the variable names specified in cnf file (user can use _ or - for example log-bin or log_bin) + # then grep for needed variable + # finally get the variable value (if variables has been specified multiple time use the last value only) + reval=$($MY_PRINT_DEFAULTS -c $WSREP_SST_OPT_CONF $group | awk -F= '{if ($1 ~ /_/) { gsub(/_/,"-",$1); print $1"="$2 } else { print $0 }}' | grep -- "--$var=" | cut -d= -f2- | tail -1) if [[ -z $reval ]];then [[ -n $3 ]] && reval=$3 fi