From 3db92ee43358f5df256bf1b0db4955ec86bdceee Mon Sep 17 00:00:00 2001 From: Daniele Sciascia Date: Tue, 3 May 2016 16:22:01 +0200 Subject: [PATCH 01/68] MW-265 Add support for wsrep_max_ws_rows Variable wsrep_max_ws_rows limits the number of rows that a transaction can insert/update/delete. --- .../galera/r/galera_var_max_ws_rows.result | 93 ++++++++++++++ .../galera/t/galera_var_max_ws_rows.test | 118 ++++++++++++++++++ sql/handler.cc | 33 +++++ sql/sql_class.cc | 8 +- sql/sql_class.h | 1 + sql/sys_vars.cc | 2 +- 6 files changed, 252 insertions(+), 3 deletions(-) create mode 100644 mysql-test/suite/galera/r/galera_var_max_ws_rows.result create mode 100644 mysql-test/suite/galera/t/galera_var_max_ws_rows.test diff --git a/mysql-test/suite/galera/r/galera_var_max_ws_rows.result b/mysql-test/suite/galera/r/galera_var_max_ws_rows.result new file mode 100644 index 0000000000000..e41f0f96c95bb --- /dev/null +++ b/mysql-test/suite/galera/r/galera_var_max_ws_rows.result @@ -0,0 +1,93 @@ +CREATE TABLE ten (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO ten VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); +CREATE TABLE t1 (f1 INTEGER AUTO_INCREMENT PRIMARY KEY, f2 INTEGER) ENGINE=InnoDB; +SET GLOBAL wsrep_max_ws_rows = 4; +START TRANSACTION; +INSERT INTO t1 (f2) VALUES (1); +INSERT INTO t1 (f2) VALUES (2); +INSERT INTO t1 (f2) VALUES (3); +INSERT INTO t1 (f2) VALUES (4); +INSERT INTO t1 (f2) VALUES (5); +ERROR HY000: wsrep_max_ws_rows exceeded +COMMIT; +SELECT COUNT(*) = 0 FROM t1; +COUNT(*) = 0 +1 +START TRANSACTION; +INSERT INTO t1 (f2) VALUES (1); +INSERT INTO t1 (f2) VALUES (2); +INSERT INTO t1 (f2) VALUES (3); +INSERT INTO t1 (f2) VALUES (4); +UPDATE t1 SET f2 = 10 WHERE f2 = 4; +ERROR HY000: wsrep_max_ws_rows exceeded +COMMIT; +SELECT COUNT(*) = 0 FROM t1; +COUNT(*) = 0 +1 +START TRANSACTION; +INSERT INTO t1 (f2) VALUES (1); +INSERT INTO t1 (f2) VALUES (2); +INSERT INTO t1 (f2) VALUES (3); +INSERT INTO t1 (f2) VALUES (4); +DELETE FROM t1 WHERE f2 = 1; +ERROR HY000: wsrep_max_ws_rows exceeded +COMMIT; +SELECT COUNT(*) = 0 FROM t1; +COUNT(*) = 0 +1 +SET GLOBAL wsrep_max_ws_rows = 5; +INSERT INTO t1 (f2) VALUES (1),(2),(3),(4),(5); +SET GLOBAL wsrep_max_ws_rows = 4; +UPDATE t1 SET f2 = f2 + 10; +ERROR HY000: wsrep_max_ws_rows exceeded +SELECT COUNT(*) = 5 FROM t1; +COUNT(*) = 5 +1 +DELETE FROM t1 WHERE f2 < 10; +ERROR HY000: wsrep_max_ws_rows exceeded +SELECT COUNT(*) = 5 FROM t1; +COUNT(*) = 5 +1 +INSERT INTO t1 (f2) SELECT * FROM ten; +ERROR HY000: wsrep_max_ws_rows exceeded +SELECT COUNT(*) = 5 FROM t1; +COUNT(*) = 5 +1 +INSERT INTO t1 (f2) VALUES (10),(20),(30),(40),(50); +ERROR HY000: wsrep_max_ws_rows exceeded +SELECT COUNT(*) = 5 FROM t1; +COUNT(*) = 5 +1 +SET GLOBAL wsrep_max_ws_rows = 10; +DELETE FROM t1 WHERE f2 < 10; +SELECT COUNT(*) = 0 FROM t1; +COUNT(*) = 0 +1 +SET GLOBAL wsrep_max_ws_rows = 100; +SELECT COUNT(*) = 100 FROM t1; +COUNT(*) = 100 +1 +DELETE FROM t1 WHERE f2 < 101; +SELECT COUNT(*) = 0 FROM t1; +COUNT(*) = 0 +1 +SET GLOBAL wsrep_max_ws_rows = 9999; +INSERT INTO t1 (f2) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4; +ERROR HY000: wsrep_max_ws_rows exceeded +SET GLOBAL wsrep_max_ws_rows = 10000; +INSERT INTO t1 (f2) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4; +SET GLOBAL wsrep_max_ws_rows = 9999; +UPDATE t1 SET f2 = 2 WHERE f2 = 1; +ERROR HY000: wsrep_max_ws_rows exceeded +SET GLOBAL wsrep_max_ws_rows = 10000; +UPDATE t1 SET f2 = 2 WHERE f2 = 1; +SET GLOBAL wsrep_max_ws_rows = 9999; +DELETE FROM t1 WHERE f2 = 2; +ERROR HY000: wsrep_max_ws_rows exceeded +SET GLOBAL wsrep_max_ws_rows = 10000; +DELETE FROM t1 WHERE f2 = 2; +SELECT COUNT(*) = 0 FROM t1; +COUNT(*) = 0 +1 +DROP TABLE t1; +DROP TABLE ten; diff --git a/mysql-test/suite/galera/t/galera_var_max_ws_rows.test b/mysql-test/suite/galera/t/galera_var_max_ws_rows.test new file mode 100644 index 0000000000000..d086142d1e127 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_var_max_ws_rows.test @@ -0,0 +1,118 @@ +--source include/galera_cluster.inc +--source include/have_innodb.inc + +CREATE TABLE ten (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO ten VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); + +CREATE TABLE t1 (f1 INTEGER AUTO_INCREMENT PRIMARY KEY, f2 INTEGER) ENGINE=InnoDB; + +--let $wsrep_max_ws_rows_orig = `SELECT @@wsrep_max_ws_rows` +SET GLOBAL wsrep_max_ws_rows = 4; + +# Test that wsrep_max_ws_rows is enforced with multi statement transactions + +START TRANSACTION; +INSERT INTO t1 (f2) VALUES (1); +INSERT INTO t1 (f2) VALUES (2); +INSERT INTO t1 (f2) VALUES (3); +INSERT INTO t1 (f2) VALUES (4); +--error ER_ERROR_DURING_COMMIT +INSERT INTO t1 (f2) VALUES (5); +COMMIT; +SELECT COUNT(*) = 0 FROM t1; + +START TRANSACTION; +INSERT INTO t1 (f2) VALUES (1); +INSERT INTO t1 (f2) VALUES (2); +INSERT INTO t1 (f2) VALUES (3); +INSERT INTO t1 (f2) VALUES (4); +--error ER_ERROR_DURING_COMMIT +UPDATE t1 SET f2 = 10 WHERE f2 = 4; +COMMIT; +SELECT COUNT(*) = 0 FROM t1; + +START TRANSACTION; +INSERT INTO t1 (f2) VALUES (1); +INSERT INTO t1 (f2) VALUES (2); +INSERT INTO t1 (f2) VALUES (3); +INSERT INTO t1 (f2) VALUES (4); +--error ER_ERROR_DURING_COMMIT +DELETE FROM t1 WHERE f2 = 1; +COMMIT; +SELECT COUNT(*) = 0 FROM t1; + + +# Test that wsrep_max_ws_rows is enforced on sigle statements + +SET GLOBAL wsrep_max_ws_rows = 5; +INSERT INTO t1 (f2) VALUES (1),(2),(3),(4),(5); +SET GLOBAL wsrep_max_ws_rows = 4; + +--error ER_ERROR_DURING_COMMIT +UPDATE t1 SET f2 = f2 + 10; +SELECT COUNT(*) = 5 FROM t1; + +--error ER_ERROR_DURING_COMMIT +DELETE FROM t1 WHERE f2 < 10; +SELECT COUNT(*) = 5 FROM t1; + +--error ER_ERROR_DURING_COMMIT +INSERT INTO t1 (f2) SELECT * FROM ten; +SELECT COUNT(*) = 5 FROM t1; + +--error ER_ERROR_DURING_COMMIT +INSERT INTO t1 (f2) VALUES (10),(20),(30),(40),(50); +SELECT COUNT(*) = 5 FROM t1; + +# Fewer than wsrep_max_ws_rows is OK + +SET GLOBAL wsrep_max_ws_rows = 10; +DELETE FROM t1 WHERE f2 < 10; +SELECT COUNT(*) = 0 FROM t1; + +# Test a series of transactions + +--disable_query_log +SET GLOBAL wsrep_max_ws_rows = 5; +let $i= 100; +while ($i) +{ + START TRANSACTION; + --eval INSERT INTO t1 (f2) VALUES ($i); + COMMIT; + dec $i; +} +--enable_query_log +SET GLOBAL wsrep_max_ws_rows = 100; +SELECT COUNT(*) = 100 FROM t1; +DELETE FROM t1 WHERE f2 < 101; +SELECT COUNT(*) = 0 FROM t1; + +# Test large statements + +SET GLOBAL wsrep_max_ws_rows = 9999; +--error ER_ERROR_DURING_COMMIT +INSERT INTO t1 (f2) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4; +SET GLOBAL wsrep_max_ws_rows = 10000; +INSERT INTO t1 (f2) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4; + +SET GLOBAL wsrep_max_ws_rows = 9999; +--error ER_ERROR_DURING_COMMIT +UPDATE t1 SET f2 = 2 WHERE f2 = 1; +SET GLOBAL wsrep_max_ws_rows = 10000; +UPDATE t1 SET f2 = 2 WHERE f2 = 1; + +SET GLOBAL wsrep_max_ws_rows = 9999; +--error ER_ERROR_DURING_COMMIT +DELETE FROM t1 WHERE f2 = 2; +SET GLOBAL wsrep_max_ws_rows = 10000; +DELETE FROM t1 WHERE f2 = 2; + +SELECT COUNT(*) = 0 FROM t1; + +--disable_query_log +--eval SET GLOBAL wsrep_max_ws_rows = $wsrep_max_ws_rows_orig +--enable_query_log + +DROP TABLE t1; +DROP TABLE ten; diff --git a/sql/handler.cc b/sql/handler.cc index e84e1b52ca2a1..6fa937faa84c1 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -6098,6 +6098,17 @@ int handler::ha_write_row(uchar *buf) rows_changed++; if (unlikely(error= binlog_log_row(table, 0, buf, log_func))) DBUG_RETURN(error); /* purecov: inspected */ +#ifdef WITH_WSREP + current_thd->wsrep_affected_rows++; + if (wsrep_max_ws_rows && + current_thd->wsrep_exec_mode != REPL_RECV && + current_thd->wsrep_affected_rows > wsrep_max_ws_rows) + { + current_thd->transaction_rollback_request= TRUE; + my_message(ER_ERROR_DURING_COMMIT, "wsrep_max_ws_rows exceeded", MYF(0)); + DBUG_RETURN(ER_ERROR_DURING_COMMIT); + } +#endif /* WITH_WSREP */ DEBUG_SYNC_C("ha_write_row_end"); DBUG_RETURN(0); @@ -6131,6 +6142,17 @@ int handler::ha_update_row(const uchar *old_data, uchar *new_data) rows_changed++; if (unlikely(error= binlog_log_row(table, old_data, new_data, log_func))) return error; +#ifdef WITH_WSREP + current_thd->wsrep_affected_rows++; + if (wsrep_max_ws_rows && + current_thd->wsrep_exec_mode != REPL_RECV && + current_thd->wsrep_affected_rows > wsrep_max_ws_rows) + { + current_thd->transaction_rollback_request= TRUE; + my_message(ER_ERROR_DURING_COMMIT, "wsrep_max_ws_rows exceeded", MYF(0)); + return ER_ERROR_DURING_COMMIT; + } +#endif /* WITH_WSREP */ return 0; } @@ -6158,6 +6180,17 @@ int handler::ha_delete_row(const uchar *buf) rows_changed++; if (unlikely(error= binlog_log_row(table, buf, 0, log_func))) return error; +#ifdef WITH_WSREP + current_thd->wsrep_affected_rows++; + if (wsrep_max_ws_rows && + current_thd->wsrep_exec_mode != REPL_RECV && + current_thd->wsrep_affected_rows > wsrep_max_ws_rows) + { + current_thd->transaction_rollback_request= TRUE; + my_message(ER_ERROR_DURING_COMMIT, "wsrep_max_ws_rows exceeded", MYF(0)); + return ER_ERROR_DURING_COMMIT; + } +#endif /* WITH_WSREP */ return 0; } diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 5705694208ab6..4873586aba55b 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -1213,7 +1213,8 @@ THD::THD() wsrep_mysql_replicated = 0; wsrep_TOI_pre_query = NULL; wsrep_TOI_pre_query_len = 0; - wsrep_sync_wait_gtid= WSREP_GTID_UNDEFINED; + wsrep_sync_wait_gtid = WSREP_GTID_UNDEFINED; + wsrep_affected_rows = 0; #endif /* Call to init() below requires fully initialized Open_tables_state. */ reset_open_tables_state(this); @@ -1629,7 +1630,8 @@ 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_sync_wait_gtid = WSREP_GTID_UNDEFINED; + wsrep_affected_rows = 0; /* @@wsrep_causal_reads is now being handled via wsrep_sync_wait, update it @@ -2383,6 +2385,8 @@ void THD::cleanup_after_query() #ifdef WITH_WSREP wsrep_sync_wait_gtid= WSREP_GTID_UNDEFINED; + if (!in_active_multi_stmt_transaction()) + wsrep_affected_rows= 0; #endif /* WITH_WSREP */ DBUG_VOID_RETURN; diff --git a/sql/sql_class.h b/sql/sql_class.h index b9f0c0a0ae72c..9ee5a40dc99b9 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -3878,6 +3878,7 @@ class THD :public Statement, bool wsrep_apply_toi; /* applier processing in TOI */ bool wsrep_skip_append_keys; wsrep_gtid_t wsrep_sync_wait_gtid; + ulong wsrep_affected_rows; #endif /* WITH_WSREP */ }; diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index c49a5de75e3fc..0bfa0bf5eb071 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -4694,7 +4694,7 @@ static Sys_var_ulong Sys_wsrep_max_ws_size ( static Sys_var_ulong Sys_wsrep_max_ws_rows ( "wsrep_max_ws_rows", "Max number of rows in write set", GLOBAL_VAR(wsrep_max_ws_rows), CMD_LINE(REQUIRED_ARG), - VALID_RANGE(1, 1048576), DEFAULT(131072), BLOCK_SIZE(1)); + VALID_RANGE(0, 1048576), DEFAULT(0), BLOCK_SIZE(1)); static Sys_var_charptr Sys_wsrep_notify_cmd( "wsrep_notify_cmd", "", From e373f60fd161eaf050eb117c9a05d8d83fe0e501 Mon Sep 17 00:00:00 2001 From: Nirbhay Choubey Date: Wed, 20 Jul 2016 18:12:17 -0400 Subject: [PATCH 02/68] MW-265 Add support for wsrep_max_ws_rows Update test results. --- mysql-test/suite/sys_vars/r/wsrep_max_ws_rows_basic.result | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/mysql-test/suite/sys_vars/r/wsrep_max_ws_rows_basic.result b/mysql-test/suite/sys_vars/r/wsrep_max_ws_rows_basic.result index 15438a2afd556..d96bc8708c5a1 100644 --- a/mysql-test/suite/sys_vars/r/wsrep_max_ws_rows_basic.result +++ b/mysql-test/suite/sys_vars/r/wsrep_max_ws_rows_basic.result @@ -6,7 +6,7 @@ SET @wsrep_max_ws_rows_global_saved = @@global.wsrep_max_ws_rows; # default SELECT @@global.wsrep_max_ws_rows; @@global.wsrep_max_ws_rows -131072 +0 # scope SELECT @@session.wsrep_max_ws_rows; @@ -26,11 +26,9 @@ SELECT @@global.wsrep_max_ws_rows; @@global.wsrep_max_ws_rows 131073 SET @@global.wsrep_max_ws_rows=0; -Warnings: -Warning 1292 Truncated incorrect wsrep_max_ws_rows value: '0' SELECT @@global.wsrep_max_ws_rows; @@global.wsrep_max_ws_rows -1 +0 SET @@global.wsrep_max_ws_rows=default; SELECT @global.wsrep_max_ws_rows; @global.wsrep_max_ws_rows From 5197fcf6b4611a26b3847d1101f1a4fb6d17570a Mon Sep 17 00:00:00 2001 From: Daniele Sciascia Date: Thu, 5 May 2016 13:20:32 +0200 Subject: [PATCH 03/68] MW-269 Fix outstanding issues with wsrep_max_ws_rows This patch includes two fixes: 1) Rollback when wsrep_max_ws_rows is exceeded would not switch back to previous autocommit mode; and 2) Internal rows counter would not be reset on implicit commits. --- .../suite/galera/r/galera_defaults.result | 2 +- .../galera/r/galera_var_max_ws_rows.result | 22 +++++++++++ .../galera/t/galera_var_max_ws_rows.test | 37 +++++++++++++++++++ sql/handler.cc | 6 +-- sql/wsrep_hton.cc | 1 + 5 files changed, 64 insertions(+), 4 deletions(-) diff --git a/mysql-test/suite/galera/r/galera_defaults.result b/mysql-test/suite/galera/r/galera_defaults.result index e15301c019e1b..6442cfebcb0be 100644 --- a/mysql-test/suite/galera/r/galera_defaults.result +++ b/mysql-test/suite/galera/r/galera_defaults.result @@ -29,7 +29,7 @@ WSREP_DRUPAL_282555_WORKAROUND OFF WSREP_FORCED_BINLOG_FORMAT NONE WSREP_LOAD_DATA_SPLITTING ON WSREP_LOG_CONFLICTS OFF -WSREP_MAX_WS_ROWS 131072 +WSREP_MAX_WS_ROWS 0 WSREP_MAX_WS_SIZE 1073741824 WSREP_MYSQL_REPLICATION_BUNDLE 0 WSREP_NOTIFY_CMD diff --git a/mysql-test/suite/galera/r/galera_var_max_ws_rows.result b/mysql-test/suite/galera/r/galera_var_max_ws_rows.result index e41f0f96c95bb..6e239c70a3ef4 100644 --- a/mysql-test/suite/galera/r/galera_var_max_ws_rows.result +++ b/mysql-test/suite/galera/r/galera_var_max_ws_rows.result @@ -89,5 +89,27 @@ DELETE FROM t1 WHERE f2 = 2; SELECT COUNT(*) = 0 FROM t1; COUNT(*) = 0 1 +SET AUTOCOMMIT = ON; +SET GLOBAL wsrep_max_ws_rows = 1; +START TRANSACTION; +INSERT INTO t1 (f2) VALUES (1); +INSERT INTO t1 (f2) VALUES (2); +ERROR HY000: wsrep_max_ws_rows exceeded +INSERT INTO t1 (f2) VALUES (1); +INSERT INTO t1 (f2) VALUES (2); +SET AUTOCOMMIT = OFF; +START TRANSACTION; +INSERT INTO t1 (f2) VALUES (1); +INSERT INTO t1 (f2) VALUES (2); +ERROR HY000: wsrep_max_ws_rows exceeded +INSERT INTO t1 (f2) VALUES (1); +INSERT INTO t1 (f2) VALUES (2); +ERROR HY000: wsrep_max_ws_rows exceeded +START TRANSACTION; +INSERT INTO t1 (f2) VALUES (1); +START TRANSACTION; +INSERT INTO t1 (f2) VALUES (1); +INSERT INTO t1 (f2) VALUES (2); +ERROR HY000: wsrep_max_ws_rows exceeded DROP TABLE t1; DROP TABLE ten; diff --git a/mysql-test/suite/galera/t/galera_var_max_ws_rows.test b/mysql-test/suite/galera/t/galera_var_max_ws_rows.test index d086142d1e127..944238bf1aa67 100644 --- a/mysql-test/suite/galera/t/galera_var_max_ws_rows.test +++ b/mysql-test/suite/galera/t/galera_var_max_ws_rows.test @@ -110,6 +110,43 @@ DELETE FROM t1 WHERE f2 = 2; SELECT COUNT(*) = 0 FROM t1; + +# Test that wsrep_max_ws_rows is reset when switching autocommit mode + +SET AUTOCOMMIT = ON; +SET GLOBAL wsrep_max_ws_rows = 1; + +START TRANSACTION; +INSERT INTO t1 (f2) VALUES (1); +--error ER_ERROR_DURING_COMMIT +INSERT INTO t1 (f2) VALUES (2); + +INSERT INTO t1 (f2) VALUES (1); +INSERT INTO t1 (f2) VALUES (2); + + +SET AUTOCOMMIT = OFF; +START TRANSACTION; +INSERT INTO t1 (f2) VALUES (1); +--error ER_ERROR_DURING_COMMIT +INSERT INTO t1 (f2) VALUES (2); + +INSERT INTO t1 (f2) VALUES (1); +--error ER_ERROR_DURING_COMMIT +INSERT INTO t1 (f2) VALUES (2); + + +# Test that wsrep_max_ws_rows is reset on implicit commits + +START TRANSACTION; +INSERT INTO t1 (f2) VALUES (1); + +START TRANSACTION; +INSERT INTO t1 (f2) VALUES (1); +--error ER_ERROR_DURING_COMMIT +INSERT INTO t1 (f2) VALUES (2); + + --disable_query_log --eval SET GLOBAL wsrep_max_ws_rows = $wsrep_max_ws_rows_orig --enable_query_log diff --git a/sql/handler.cc b/sql/handler.cc index 6fa937faa84c1..0eef23ad75317 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -6104,7 +6104,7 @@ int handler::ha_write_row(uchar *buf) current_thd->wsrep_exec_mode != REPL_RECV && current_thd->wsrep_affected_rows > wsrep_max_ws_rows) { - current_thd->transaction_rollback_request= TRUE; + trans_rollback_stmt(current_thd) || trans_rollback(current_thd); my_message(ER_ERROR_DURING_COMMIT, "wsrep_max_ws_rows exceeded", MYF(0)); DBUG_RETURN(ER_ERROR_DURING_COMMIT); } @@ -6148,7 +6148,7 @@ int handler::ha_update_row(const uchar *old_data, uchar *new_data) current_thd->wsrep_exec_mode != REPL_RECV && current_thd->wsrep_affected_rows > wsrep_max_ws_rows) { - current_thd->transaction_rollback_request= TRUE; + trans_rollback_stmt(current_thd) || trans_rollback(current_thd); my_message(ER_ERROR_DURING_COMMIT, "wsrep_max_ws_rows exceeded", MYF(0)); return ER_ERROR_DURING_COMMIT; } @@ -6186,7 +6186,7 @@ int handler::ha_delete_row(const uchar *buf) current_thd->wsrep_exec_mode != REPL_RECV && current_thd->wsrep_affected_rows > wsrep_max_ws_rows) { - current_thd->transaction_rollback_request= TRUE; + trans_rollback_stmt(current_thd) || trans_rollback(current_thd); my_message(ER_ERROR_DURING_COMMIT, "wsrep_max_ws_rows exceeded", MYF(0)); return ER_ERROR_DURING_COMMIT; } diff --git a/sql/wsrep_hton.cc b/sql/wsrep_hton.cc index e5ff462eb1997..e1bf63cd31f34 100644 --- a/sql/wsrep_hton.cc +++ b/sql/wsrep_hton.cc @@ -42,6 +42,7 @@ void wsrep_cleanup_transaction(THD *thd) thd->wsrep_trx_meta.gtid= WSREP_GTID_UNDEFINED; thd->wsrep_trx_meta.depends_on= WSREP_SEQNO_UNDEFINED; thd->wsrep_exec_mode= LOCAL_STATE; + thd->wsrep_affected_rows= 0; return; } From 74f80b349924c7f0c091a0973dea0ec61191c2c9 Mon Sep 17 00:00:00 2001 From: Daniele Sciascia Date: Fri, 6 May 2016 16:07:53 +0200 Subject: [PATCH 04/68] MW-267 Enforce wsrep_max_ws_size limit in wsrep provider This changes variable wsrep_max_ws_size so that its value is linked to the value of provider option repl.max_ws_size. That is, changing the value of variable wsrep_max_ws_size will change the value of provider option repl.max_ws_size, and viceversa. The writeset size limit is always enforced in the provider, regardless of which option is used. --- .../suite/galera/r/galera_defaults.result | 2 +- .../galera/r/galera_var_max_ws_size.result | 9 ++++ .../galera/t/galera_var_max_ws_size.test | 23 +++++++++ sql/sys_vars.cc | 5 +- sql/wsrep_applier.cc | 10 +--- sql/wsrep_binlog.h | 2 +- sql/wsrep_var.cc | 48 +++++++++++++++++-- sql/wsrep_var.h | 2 + 8 files changed, 86 insertions(+), 15 deletions(-) diff --git a/mysql-test/suite/galera/r/galera_defaults.result b/mysql-test/suite/galera/r/galera_defaults.result index 6442cfebcb0be..3b89ccb7dbed7 100644 --- a/mysql-test/suite/galera/r/galera_defaults.result +++ b/mysql-test/suite/galera/r/galera_defaults.result @@ -30,7 +30,7 @@ WSREP_FORCED_BINLOG_FORMAT NONE WSREP_LOAD_DATA_SPLITTING ON WSREP_LOG_CONFLICTS OFF WSREP_MAX_WS_ROWS 0 -WSREP_MAX_WS_SIZE 1073741824 +WSREP_MAX_WS_SIZE 2147483647 WSREP_MYSQL_REPLICATION_BUNDLE 0 WSREP_NOTIFY_CMD WSREP_ON ON diff --git a/mysql-test/suite/galera/r/galera_var_max_ws_size.result b/mysql-test/suite/galera/r/galera_var_max_ws_size.result index 5a1b5cf621ad9..0940b5f12c035 100644 --- a/mysql-test/suite/galera/r/galera_var_max_ws_size.result +++ b/mysql-test/suite/galera/r/galera_var_max_ws_size.result @@ -5,4 +5,13 @@ ERROR HY000: Got error 5 "Input/output error" during COMMIT SELECT COUNT(*) = 0 FROM t1; COUNT(*) = 0 1 +SET GLOBAL wsrep_provider_options = 'repl.max_ws_size=10000'; +SELECT @@wsrep_max_ws_size = 10000; +@@wsrep_max_ws_size = 10000 +1 +SET GLOBAL wsrep_provider_options = 'repl.max_ws_size=20000'; +SET GLOBAL wsrep_provider_options = 'repl.max_ws_size=10000'; +SET GLOBAL wsrep_max_ws_size = 20000; +provider_options_match +1 DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/galera_var_max_ws_size.test b/mysql-test/suite/galera/t/galera_var_max_ws_size.test index b66ef2d5ee274..8eb93bda9be0b 100644 --- a/mysql-test/suite/galera/t/galera_var_max_ws_size.test +++ b/mysql-test/suite/galera/t/galera_var_max_ws_size.test @@ -16,6 +16,29 @@ SET GLOBAL wsrep_max_ws_size = 1024; INSERT INTO t1 VALUES (DEFAULT, REPEAT('X', 1024)); SELECT COUNT(*) = 0 FROM t1; +# +# Changing repl.max_ws_size also changes wsrep_max_ws_size +# + +SET GLOBAL wsrep_provider_options = 'repl.max_ws_size=10000'; +SELECT @@wsrep_max_ws_size = 10000; + + +# +# Changing wsrep_max_ws_size is equivalent to changing repl.max_ws_size +# + +SET GLOBAL wsrep_provider_options = 'repl.max_ws_size=20000'; +--let $provider_options = `SELECT @@wsrep_provider_options` +SET GLOBAL wsrep_provider_options = 'repl.max_ws_size=10000'; + +SET GLOBAL wsrep_max_ws_size = 20000; +--let $provider_options_updated = `SELECT @@wsrep_provider_options` + +--disable_query_log +--eval SELECT STRCMP('$provider_options', '$provider_options_updated') = 0 AS provider_options_match +--enable_query_log + --disable_query_log --eval SET GLOBAL wsrep_max_ws_size = $wsrep_max_ws_size_orig --enable_query_log diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index 0bfa0bf5eb071..0ac8d40fbaebb 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -4688,8 +4688,9 @@ static Sys_var_charptr Sys_wsrep_start_position ( static Sys_var_ulong Sys_wsrep_max_ws_size ( "wsrep_max_ws_size", "Max write set size (bytes)", GLOBAL_VAR(wsrep_max_ws_size), CMD_LINE(REQUIRED_ARG), - /* Upper limit is 65K short of 4G to avoid overlows on 32-bit systems */ - VALID_RANGE(1024, WSREP_MAX_WS_SIZE), DEFAULT(1073741824UL), BLOCK_SIZE(1)); + VALID_RANGE(1024, WSREP_MAX_WS_SIZE), DEFAULT(WSREP_MAX_WS_SIZE), + BLOCK_SIZE(1), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), + ON_UPDATE(wsrep_max_ws_size_update)); static Sys_var_ulong Sys_wsrep_max_ws_rows ( "wsrep_max_ws_rows", "Max number of rows in write set", diff --git a/sql/wsrep_applier.cc b/sql/wsrep_applier.cc index 90c84f1c2ccdf..73a43185162d4 100644 --- a/sql/wsrep_applier.cc +++ b/sql/wsrep_applier.cc @@ -39,15 +39,9 @@ static Log_event* wsrep_read_log_event( const char *error= 0; Log_event *res= 0; - if (data_len > wsrep_max_ws_size) - { - error = "Event too big"; - goto err; - } - - res= Log_event::read_log_event(buf, data_len, &error, description_event, true); + res= Log_event::read_log_event(buf, data_len, &error, description_event, + true); -err: if (!res) { DBUG_ASSERT(error != 0); diff --git a/sql/wsrep_binlog.h b/sql/wsrep_binlog.h index a7b680f616b1d..c29d51caf2cba 100644 --- a/sql/wsrep_binlog.h +++ b/sql/wsrep_binlog.h @@ -19,7 +19,7 @@ #include "sql_class.h" // THD, IO_CACHE #define HEAP_PAGE_SIZE 65536 /* 64K */ -#define WSREP_MAX_WS_SIZE (0xFFFFFFFFUL - HEAP_PAGE_SIZE) +#define WSREP_MAX_WS_SIZE 2147483647 /* 2GB */ /* Write the contents of a cache to a memory buffer. diff --git a/sql/wsrep_var.cc b/sql/wsrep_var.cc index 7ac68df66bd7e..44d17e3e78ade 100644 --- a/sql/wsrep_var.cc +++ b/sql/wsrep_var.cc @@ -179,6 +179,32 @@ void wsrep_start_position_init (const char* val) wsrep_set_local_position (val, false); } +static int get_provider_option_value(const char* opts, + const char* opt_name, + ulong* opt_value) +{ + int ret= 1; + ulong opt_value_tmp; + char *opt_value_str, *s, *opts_copy= my_strdup(opts, MYF(MY_WME)); + + if ((opt_value_str= strstr(opts_copy, opt_name)) == NULL) + goto end; + opt_value_str= strtok_r(opt_value_str, "=", &s); + if (opt_value_str == NULL) goto end; + opt_value_str= strtok_r(NULL, ";", &s); + if (opt_value_str == NULL) goto end; + + opt_value_tmp= strtoul(opt_value_str, NULL, 10); + if (errno == ERANGE) goto end; + + *opt_value= opt_value_tmp; + ret= 0; + +end: + my_free(opts_copy); + return ret; +} + static bool refresh_provider_options() { WSREP_DEBUG("refresh_provider_options: %s", @@ -186,9 +212,10 @@ static bool refresh_provider_options() char* opts= wsrep->options_get(wsrep); if (opts) { - if (wsrep_provider_options) my_free((void *)wsrep_provider_options); - wsrep_provider_options = (char*)my_memdup(opts, strlen(opts) + 1, - MYF(MY_WME)); + wsrep_provider_options_init(opts); + get_provider_option_value(wsrep_provider_options, + (char*)"repl.max_ws_size", + &wsrep_max_ws_size); } else { @@ -531,6 +558,21 @@ bool wsrep_desync_update (sys_var *self, THD* thd, enum_var_type type) return false; } +bool wsrep_max_ws_size_update (sys_var *self, THD *thd, enum_var_type) +{ + char max_ws_size_opt[128]; + my_snprintf(max_ws_size_opt, sizeof(max_ws_size_opt), + "repl.max_ws_size=%d", wsrep_max_ws_size); + wsrep_status_t ret= wsrep->options_set(wsrep, max_ws_size_opt); + if (ret != WSREP_OK) + { + WSREP_ERROR("Set options returned %d", ret); + refresh_provider_options(); + return true; + } + return refresh_provider_options(); +} + /* * Status variables stuff below */ diff --git a/sql/wsrep_var.h b/sql/wsrep_var.h index 524dabfd9c0ea..f72df9d098a6e 100644 --- a/sql/wsrep_var.h +++ b/sql/wsrep_var.h @@ -83,4 +83,6 @@ extern bool wsrep_slave_threads_update UPDATE_ARGS; extern bool wsrep_desync_check CHECK_ARGS; extern bool wsrep_desync_update UPDATE_ARGS; +extern bool wsrep_max_ws_size_update UPDATE_ARGS; + #endif /* WSREP_VAR_H */ From cbc8a84fa2e65cad7561fa53799ca0273e8a5ff5 Mon Sep 17 00:00:00 2001 From: Nirbhay Choubey Date: Mon, 25 Jul 2016 11:51:21 -0400 Subject: [PATCH 05/68] MW-267 Enforce wsrep_max_ws_size limit in wsrep provider Update test results. --- mysql-test/r/mysqld--help.result | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/mysqld--help.result b/mysql-test/r/mysqld--help.result index ef07db5ac52a0..8ff9073b62583 100644 --- a/mysql-test/r/mysqld--help.result +++ b/mysql-test/r/mysqld--help.result @@ -1458,8 +1458,8 @@ wsrep-drupal-282555-workaround FALSE wsrep-forced-binlog-format NONE wsrep-load-data-splitting TRUE wsrep-log-conflicts FALSE -wsrep-max-ws-rows 131072 -wsrep-max-ws-size 1073741824 +wsrep-max-ws-rows 0 +wsrep-max-ws-size 2147483647 wsrep-mysql-replication-bundle 0 wsrep-new-cluster FALSE wsrep-node-address From 7431368eafb3e531ba3926e85cc515778f6b5e2f Mon Sep 17 00:00:00 2001 From: Daniele Sciascia Date: Thu, 14 Jul 2016 14:29:59 +0200 Subject: [PATCH 06/68] MW-292 Reset timestamp after transaction replay Transaction replay causes the THD to re-apply the replication events from execution, using the same path appliers do. While applying the log events, the THD's timestamp is set to the timestamp of the event. Setting the timestamp explicitly causes function NOW() to always the timestamp that was set. To avoid this behavior we reset the timestamp after replaying is done. --- sql/sql_class.h | 1 + sql/wsrep_thd.cc | 2 ++ 2 files changed, 3 insertions(+) diff --git a/sql/sql_class.h b/sql/sql_class.h index 9ee5a40dc99b9..bf3d043cc1a3a 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -68,6 +68,7 @@ struct wsrep_thd_shadow { ulong tx_isolation; char *db; size_t db_length; + my_hrtime_t user_time; }; #endif class Reprepare_observer; diff --git a/sql/wsrep_thd.cc b/sql/wsrep_thd.cc index 464a68a822151..9c2fa4ba85603 100644 --- a/sql/wsrep_thd.cc +++ b/sql/wsrep_thd.cc @@ -160,6 +160,7 @@ static void wsrep_prepare_bf_thd(THD *thd, struct wsrep_thd_shadow* shadow) shadow->db = thd->db; shadow->db_length = thd->db_length; + shadow->user_time = thd->user_time; thd->reset_db(NULL, 0); } @@ -170,6 +171,7 @@ static void wsrep_return_from_bf_mode(THD *thd, struct wsrep_thd_shadow* shadow) thd->wsrep_exec_mode = shadow->wsrep_exec_mode; thd->net.vio = shadow->vio; thd->variables.tx_isolation = shadow->tx_isolation; + thd->user_time = shadow->user_time; thd->reset_db(shadow->db, shadow->db_length); delete thd->system_thread_info.rpl_sql_info; From e57287866fd33b4494839c21ccd7875480c8558d Mon Sep 17 00:00:00 2001 From: Philip Stoev Date: Fri, 15 Jul 2016 01:13:32 -0700 Subject: [PATCH 07/68] Galera MTR Tests: Test case for MW-292 : NOW() returns stale timestamp after transaction replay --- mysql-test/suite/galera/r/MW-292.result | 30 ++++++++++ mysql-test/suite/galera/t/MW-292.test | 79 +++++++++++++++++++++++++ 2 files changed, 109 insertions(+) create mode 100644 mysql-test/suite/galera/r/MW-292.result create mode 100644 mysql-test/suite/galera/t/MW-292.test diff --git a/mysql-test/suite/galera/r/MW-292.result b/mysql-test/suite/galera/r/MW-292.result new file mode 100644 index 0000000000000..f038f880efa25 --- /dev/null +++ b/mysql-test/suite/galera/r/MW-292.result @@ -0,0 +1,30 @@ +CREATE TABLE rand_table (f1 FLOAT); +CREATE TABLE t1 (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; +SELECT * FROM t1 WHERE f1 = 2 FOR UPDATE; +f1 f2 +2 a +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'; +SELECT TIMEDIFF(SYSDATE(), NOW()) < 2; +TIMEDIFF(SYSDATE(), NOW()) < 2 +1 +INSERT INTO rand_table VALUES (RAND()),(RAND()),(RAND()),(RAND()),(RAND()); +INSERT INTO rand_table VALUES (RAND()),(RAND()),(RAND()),(RAND()),(RAND()); +SELECT COUNT(DISTINCT f1) = 10 FROM rand_table; +COUNT(DISTINCT f1) = 10 +1 +wsrep_local_replays +1 +DROP TABLE t1; +DROP TABLE rand_table; diff --git a/mysql-test/suite/galera/t/MW-292.test b/mysql-test/suite/galera/t/MW-292.test new file mode 100644 index 0000000000000..945d9f42458ed --- /dev/null +++ b/mysql-test/suite/galera/t/MW-292.test @@ -0,0 +1,79 @@ +# +# MW-292 Reset timestamp after transaction replay +# +# We force transaction replay to happen and then we check that NOW() is not stuck in time. +# As a bonus we also check that RAND() continues to return random values after replay +# +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc +--source include/have_debug_sync.inc +--source suite/galera/include/galera_have_debug_sync.inc + +--let $wsrep_local_replays_old = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_replays'` + +CREATE TABLE rand_table (f1 FLOAT); +CREATE TABLE t1 (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; +SELECT * FROM t1 WHERE f1 = 2 FOR UPDATE; + +# Block the commit +--connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1 +--let $galera_sync_point = commit_monitor_enter_sync +--source include/galera_set_sync_point.inc + +--connection node_1 +--send COMMIT; + +# Wait until commit is blocked +--connection node_1a +SET SESSION wsrep_sync_wait = 0; +--source include/galera_wait_sync_point.inc + +# Issue a conflicting update on node #2 +--connection node_2 +UPDATE t1 SET f2 = 'c' WHERE f1 = 2; + +# Wait for both transactions to be blocked +--connection node_1a +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST 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 + +# Unblock the commit +--connection node_1a +--source include/galera_clear_sync_point.inc +--source include/galera_signal_sync_point.inc + +# Commit succeeds via replay +--connection node_1 +--reap + +# Confirm that NOW() is not stuck in time relative to SYSDATE(); +--sleep 3 +SELECT TIMEDIFF(SYSDATE(), NOW()) < 2; + +INSERT INTO rand_table VALUES (RAND()),(RAND()),(RAND()),(RAND()),(RAND()); +INSERT INTO rand_table VALUES (RAND()),(RAND()),(RAND()),(RAND()),(RAND()); + +SELECT COUNT(DISTINCT f1) = 10 FROM rand_table; + +# wsrep_local_replays has increased by 1 +--let $wsrep_local_replays_new = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_replays'` +--disable_query_log +--eval SELECT $wsrep_local_replays_new - $wsrep_local_replays_old = 1 AS wsrep_local_replays; +--enable_query_log + +--connection node_2 +DROP TABLE t1; +DROP TABLE rand_table; From 963673e7af5ecdfd31279ed733bcdc964b9d0619 Mon Sep 17 00:00:00 2001 From: Nirbhay Choubey Date: Mon, 25 Jul 2016 21:52:02 -0400 Subject: [PATCH 08/68] MW-292: Fix test case --- mysql-test/suite/galera/t/MW-292.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/suite/galera/t/MW-292.test b/mysql-test/suite/galera/t/MW-292.test index 945d9f42458ed..ecb1273759e1b 100644 --- a/mysql-test/suite/galera/t/MW-292.test +++ b/mysql-test/suite/galera/t/MW-292.test @@ -44,7 +44,7 @@ UPDATE t1 SET f2 = 'c' WHERE f1 = 2; # Wait for both transactions to be blocked --connection node_1a ---let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE = 'System lock'; +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE LIKE 'Update_rows_log_event::find_row%'; --source include/wait_condition.inc --let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE = 'init' AND INFO = 'COMMIT'; From 9f211d49562da522c8b1dec35ff871fa20f5d89f Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Tue, 19 Jul 2016 20:44:02 +0000 Subject: [PATCH 09/68] MDEV-10314 : wsrep_client_thread was not set in threadpool. Fixed threadpool_add_connection to use thd_prepare_connection() to match thread-per-conection flow. --- sql/threadpool_common.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sql/threadpool_common.cc b/sql/threadpool_common.cc index 5bcea767aae06..ae8a81b1bcd7e 100644 --- a/sql/threadpool_common.cc +++ b/sql/threadpool_common.cc @@ -148,9 +148,8 @@ int threadpool_add_connection(THD *thd) if (!setup_connection_thread_globals(thd)) { - if (!login_connection(thd)) + if (!thd_prepare_connection(thd)) { - prepare_new_connection_state(thd); /* Check if THD is ok, as prepare_new_connection_state() From 44e3046d3b09a21e21295979d6ddad9f332ebadd Mon Sep 17 00:00:00 2001 From: Nirbhay Choubey Date: Wed, 3 Aug 2016 22:15:57 -0400 Subject: [PATCH 10/68] MDEV-10487: Galera SST using rsync does not filter out lost+found In rsync based SST method, during third phase of data transfer, 'lost+found' should be filtered out while recursively transferring files from various directories under data directory. --- scripts/wsrep_sst_rsync.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/wsrep_sst_rsync.sh b/scripts/wsrep_sst_rsync.sh index 3202087f5262e..7f0901c10fb36 100644 --- a/scripts/wsrep_sst_rsync.sh +++ b/scripts/wsrep_sst_rsync.sh @@ -176,7 +176,8 @@ then [ "$OS" == "Linux" ] && count=$(grep -c processor /proc/cpuinfo) [ "$OS" == "Darwin" -o "$OS" == "FreeBSD" ] && count=$(sysctl -n hw.ncpu) - find . -maxdepth 1 -mindepth 1 -type d -print0 | xargs -I{} -0 -P $count \ + find . -maxdepth 1 -mindepth 1 -type d -not -name "lost+found" -print0 | \ + xargs -I{} -0 -P $count \ rsync --owner --group --perms --links --specials \ --ignore-times --inplace --recursive --delete --quiet \ $WHOLE_FILE_OPT --exclude '*/ib_logfile*' "$WSREP_SST_OPT_DATA"/{}/ \ From 9a809fe31be15131baf909e898c1ad2c02976728 Mon Sep 17 00:00:00 2001 From: Daniele Sciascia Date: Thu, 14 Jul 2016 14:29:59 +0200 Subject: [PATCH 11/68] MW-292 Reset timestamp after transaction replay Transaction replay causes the THD to re-apply the replication events from execution, using the same path appliers do. While applying the log events, the THD's timestamp is set to the timestamp of the event. Setting the timestamp explicitly causes function NOW() to always the timestamp that was set. To avoid this behavior we reset the timestamp after replaying is done. --- sql/sql_class.h | 1 + sql/wsrep_thd.cc | 2 ++ 2 files changed, 3 insertions(+) diff --git a/sql/sql_class.h b/sql/sql_class.h index ad3e94d43cae6..e42eeacfff060 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -55,6 +55,7 @@ struct wsrep_thd_shadow { ulong tx_isolation; char *db; size_t db_length; + my_hrtime_t user_time; }; #endif class Reprepare_observer; diff --git a/sql/wsrep_thd.cc b/sql/wsrep_thd.cc index 50e8a09706be0..4d665775f2d08 100644 --- a/sql/wsrep_thd.cc +++ b/sql/wsrep_thd.cc @@ -127,6 +127,7 @@ static void wsrep_prepare_bf_thd(THD *thd, struct wsrep_thd_shadow* shadow) shadow->db = thd->db; shadow->db_length = thd->db_length; + shadow->user_time = thd->user_time; thd->reset_db(NULL, 0); } @@ -137,6 +138,7 @@ static void wsrep_return_from_bf_mode(THD *thd, struct wsrep_thd_shadow* shadow) thd->wsrep_exec_mode = shadow->wsrep_exec_mode; thd->net.vio = shadow->vio; thd->variables.tx_isolation = shadow->tx_isolation; + thd->user_time = shadow->user_time; thd->reset_db(shadow->db, shadow->db_length); thd->wsrep_rli->cleanup_after_session(); From dfadb3680d0ffc211ce4f36fed28e59e3fec0842 Mon Sep 17 00:00:00 2001 From: Philip Stoev Date: Fri, 15 Jul 2016 01:13:32 -0700 Subject: [PATCH 12/68] Galera MTR Tests: Test case for MW-292 : NOW() returns stale timestamp after transaction replay --- mysql-test/suite/galera/r/MW-292.result | 30 ++++++++++ mysql-test/suite/galera/t/MW-292.test | 79 +++++++++++++++++++++++++ 2 files changed, 109 insertions(+) create mode 100644 mysql-test/suite/galera/r/MW-292.result create mode 100644 mysql-test/suite/galera/t/MW-292.test diff --git a/mysql-test/suite/galera/r/MW-292.result b/mysql-test/suite/galera/r/MW-292.result new file mode 100644 index 0000000000000..f038f880efa25 --- /dev/null +++ b/mysql-test/suite/galera/r/MW-292.result @@ -0,0 +1,30 @@ +CREATE TABLE rand_table (f1 FLOAT); +CREATE TABLE t1 (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; +SELECT * FROM t1 WHERE f1 = 2 FOR UPDATE; +f1 f2 +2 a +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'; +SELECT TIMEDIFF(SYSDATE(), NOW()) < 2; +TIMEDIFF(SYSDATE(), NOW()) < 2 +1 +INSERT INTO rand_table VALUES (RAND()),(RAND()),(RAND()),(RAND()),(RAND()); +INSERT INTO rand_table VALUES (RAND()),(RAND()),(RAND()),(RAND()),(RAND()); +SELECT COUNT(DISTINCT f1) = 10 FROM rand_table; +COUNT(DISTINCT f1) = 10 +1 +wsrep_local_replays +1 +DROP TABLE t1; +DROP TABLE rand_table; diff --git a/mysql-test/suite/galera/t/MW-292.test b/mysql-test/suite/galera/t/MW-292.test new file mode 100644 index 0000000000000..945d9f42458ed --- /dev/null +++ b/mysql-test/suite/galera/t/MW-292.test @@ -0,0 +1,79 @@ +# +# MW-292 Reset timestamp after transaction replay +# +# We force transaction replay to happen and then we check that NOW() is not stuck in time. +# As a bonus we also check that RAND() continues to return random values after replay +# +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc +--source include/have_debug_sync.inc +--source suite/galera/include/galera_have_debug_sync.inc + +--let $wsrep_local_replays_old = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_replays'` + +CREATE TABLE rand_table (f1 FLOAT); +CREATE TABLE t1 (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; +SELECT * FROM t1 WHERE f1 = 2 FOR UPDATE; + +# Block the commit +--connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1 +--let $galera_sync_point = commit_monitor_enter_sync +--source include/galera_set_sync_point.inc + +--connection node_1 +--send COMMIT; + +# Wait until commit is blocked +--connection node_1a +SET SESSION wsrep_sync_wait = 0; +--source include/galera_wait_sync_point.inc + +# Issue a conflicting update on node #2 +--connection node_2 +UPDATE t1 SET f2 = 'c' WHERE f1 = 2; + +# Wait for both transactions to be blocked +--connection node_1a +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST 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 + +# Unblock the commit +--connection node_1a +--source include/galera_clear_sync_point.inc +--source include/galera_signal_sync_point.inc + +# Commit succeeds via replay +--connection node_1 +--reap + +# Confirm that NOW() is not stuck in time relative to SYSDATE(); +--sleep 3 +SELECT TIMEDIFF(SYSDATE(), NOW()) < 2; + +INSERT INTO rand_table VALUES (RAND()),(RAND()),(RAND()),(RAND()),(RAND()); +INSERT INTO rand_table VALUES (RAND()),(RAND()),(RAND()),(RAND()),(RAND()); + +SELECT COUNT(DISTINCT f1) = 10 FROM rand_table; + +# wsrep_local_replays has increased by 1 +--let $wsrep_local_replays_new = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_replays'` +--disable_query_log +--eval SELECT $wsrep_local_replays_new - $wsrep_local_replays_old = 1 AS wsrep_local_replays; +--enable_query_log + +--connection node_2 +DROP TABLE t1; +DROP TABLE rand_table; From abfbe80840e4b8ad63b31ea65b59f52ef7d151a2 Mon Sep 17 00:00:00 2001 From: Nirbhay Choubey Date: Wed, 10 Aug 2016 14:48:44 -0400 Subject: [PATCH 13/68] MW-292: Fix test case Also backported missing test include files. --- 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 | 6 ++++++ .../suite/galera/include/galera_have_debug_sync.inc | 9 +++++++++ mysql-test/suite/galera/t/MW-292.test | 6 +++--- 6 files changed, 21 insertions(+), 3 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 create mode 100644 mysql-test/suite/galera/include/galera_have_debug_sync.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 0000000000000..589522a55b054 --- /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 0000000000000..5fe4e8c38c095 --- /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 0000000000000..eaa5cdd43f5bd --- /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 0000000000000..cf3a49801866f --- /dev/null +++ b/mysql-test/include/galera_wait_sync_point.inc @@ -0,0 +1,6 @@ +--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 +--eval SET SESSION wsrep_on = $wsrep_on_orig diff --git a/mysql-test/suite/galera/include/galera_have_debug_sync.inc b/mysql-test/suite/galera/include/galera_have_debug_sync.inc new file mode 100644 index 0000000000000..7c0156052d8a3 --- /dev/null +++ b/mysql-test/suite/galera/include/galera_have_debug_sync.inc @@ -0,0 +1,9 @@ +--disable_query_log + +--let $galera_have_debug_sync = `SELECT 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_debug_sync_waiters'` + +--if (!$galera_have_debug_sync) { + --skip "Test requires Galera debug library with debug_sync functionality" +} + +--enable_query_log diff --git a/mysql-test/suite/galera/t/MW-292.test b/mysql-test/suite/galera/t/MW-292.test index 945d9f42458ed..7e4cf9050aee5 100644 --- a/mysql-test/suite/galera/t/MW-292.test +++ b/mysql-test/suite/galera/t/MW-292.test @@ -44,11 +44,11 @@ UPDATE t1 SET f2 = 'c' WHERE f1 = 2; # Wait for both transactions to be blocked --connection node_1a ---let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE = 'System lock'; +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE LIKE 'Update_rows_log_event::find_row%'; --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 +#--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE = 'init' AND INFO = 'COMMIT'; +#--source include/wait_condition.inc # Unblock the commit --connection node_1a From d40d3f4e57f375897aa29e72e947e372e6bc229d Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Tue, 19 Jul 2016 20:44:02 +0000 Subject: [PATCH 14/68] MDEV-10314 : wsrep_client_thread was not set in threadpool. Fixed threadpool_add_connection to use thd_prepare_connection() to match thread-per-conection flow. --- sql/threadpool_common.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sql/threadpool_common.cc b/sql/threadpool_common.cc index 9e0cb07b86c3b..75b8f821d2261 100644 --- a/sql/threadpool_common.cc +++ b/sql/threadpool_common.cc @@ -148,9 +148,8 @@ int threadpool_add_connection(THD *thd) if (!setup_connection_thread_globals(thd)) { - if (!login_connection(thd)) + if (!thd_prepare_connection(thd)) { - prepare_new_connection_state(thd); /* Check if THD is ok, as prepare_new_connection_state() From 58386ca04dffd5fc9006d8f70a44a3a82f385b96 Mon Sep 17 00:00:00 2001 From: sjaakola Date: Mon, 11 Jan 2016 22:43:27 +0200 Subject: [PATCH 15/68] refs codership/mysql-wsrep#239 Synced xtrabackup SST scripts from PXC source tree as of PXC 5.6.27-25.13 - PXC#480: xtrabackup-v2 SST fails with multiple log_bin directives in my.cn - PXC#460: wsrep_sst_auth don't work in Percona-XtraDB-Cluster-56-5.6.25-25. - PXC-416: Fix SST related issues. - PXC-389: Merge remote-tracking branch 'wsrep/5.6' into 5.6-wsrep-pxc389 - Bug #1431101: SST does not clobber backup-my.cnf --- scripts/wsrep_sst_common.sh | 4 ++-- scripts/wsrep_sst_xtrabackup-v2.sh | 6 ++++-- scripts/wsrep_sst_xtrabackup.sh | 6 ++++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/scripts/wsrep_sst_common.sh b/scripts/wsrep_sst_common.sh index 0aa338510e0de..25ec0baae803e 100644 --- a/scripts/wsrep_sst_common.sh +++ b/scripts/wsrep_sst_common.sh @@ -134,7 +134,7 @@ if $MY_PRINT_DEFAULTS -c $WSREP_SST_OPT_CONF sst | grep -q "wsrep_sst_auth" then if wsrep_auth_not_set then - WSREP_SST_OPT_AUTH=$(MY_PRINT_DEFAULTS -c $WSREP_SST_OPT_CONF sst | grep -- "--wsrep_sst_auth" | cut -d= -f2) + WSREP_SST_OPT_AUTH=$($MY_PRINT_DEFAULTS -c $WSREP_SST_OPT_CONF sst | grep -- "--wsrep_sst_auth" | cut -d= -f2) fi fi readonly WSREP_SST_OPT_AUTH @@ -176,7 +176,7 @@ wsrep_log_info() wsrep_cleanup_progress_file() { - [ -n "$SST_PROGRESS_FILE" ] && rm -f "$SST_PROGRESS_FILE" 2>/dev/null + [ -n "${SST_PROGRESS_FILE:-}" ] && rm -f "$SST_PROGRESS_FILE" 2>/dev/null || true } wsrep_check_program() diff --git a/scripts/wsrep_sst_xtrabackup-v2.sh b/scripts/wsrep_sst_xtrabackup-v2.sh index 074f36a11e95e..b5556c60c642d 100644 --- a/scripts/wsrep_sst_xtrabackup-v2.sh +++ b/scripts/wsrep_sst_xtrabackup-v2.sh @@ -674,6 +674,7 @@ then if [ $WSREP_SST_OPT_BYPASS -eq 0 ] then + usrst=0 if [[ -z $sst_ver ]];then wsrep_log_error "Upgrade joiner to 5.6.21 or higher for backup locks support" wsrep_log_error "The joiner is not supported for this version of donor" @@ -689,13 +690,14 @@ then itmpdir=$(mktemp -d) wsrep_log_info "Using $itmpdir as innobackupex temporary directory" - if [ "$WSREP_SST_OPT_USER" != "(null)" ]; then + if [[ -n "${WSREP_SST_OPT_USER:-}" && "$WSREP_SST_OPT_USER" != "(null)" ]]; then INNOEXTRA+=" --user=$WSREP_SST_OPT_USER" + usrst=1 fi if [ -n "${WSREP_SST_OPT_PSWD:-}" ]; then INNOEXTRA+=" --password=$WSREP_SST_OPT_PSWD" - else + elif [[ $usrst -eq 1 ]];then # Empty password, used for testing, debugging etc. INNOEXTRA+=" --password=" fi diff --git a/scripts/wsrep_sst_xtrabackup.sh b/scripts/wsrep_sst_xtrabackup.sh index 4acf28543012f..b40be208be759 100644 --- a/scripts/wsrep_sst_xtrabackup.sh +++ b/scripts/wsrep_sst_xtrabackup.sh @@ -436,15 +436,17 @@ then if [ $WSREP_SST_OPT_BYPASS -eq 0 ] then + usrst=0 TMPDIR="${TMPDIR:-/tmp}" - if [ "$WSREP_SST_OPT_USER" != "(null)" ]; then + if [[ -n "${WSREP_SST_OPT_USER:-}" && "$WSREP_SST_OPT_USER" != "(null)" ]]; then INNOEXTRA+=" --user=$WSREP_SST_OPT_USER" + usrst=1 fi if [ -n "${WSREP_SST_OPT_PSWD:-}" ]; then INNOEXTRA+=" --password=$WSREP_SST_OPT_PSWD" - else + elif [[ $usrst -eq 1 ]];then # Empty password, used for testing, debugging etc. INNOEXTRA+=" --password=" fi From a53ac77c4265c2bf8ad4d07b924f6155e8b39458 Mon Sep 17 00:00:00 2001 From: Nirbhay Choubey Date: Wed, 10 Aug 2016 12:30:57 -0400 Subject: [PATCH 16/68] Cleanup: Remove dead code --- sql/sql_parse.cc | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 581a82126684e..34c4474a9e205 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2641,31 +2641,10 @@ mysql_execute_command(THD *thd) lex->sql_command == SQLCOM_SELECT) && !wsrep_is_show_query(lex->sql_command)) { -#if DIRTY_HACK - /* Dirty hack for lp:1002714 - trying to recognize mysqldump connection - * and allow it to continue. Actuall mysqldump_magic_str may be longer - * and is obviously version dependent and may be issued by any client - * connection after which connection becomes non-replicating. */ - static char const mysqldump_magic_str[]= -"SELECT LOGFILE_GROUP_NAME, FILE_NAME, TOTAL_EXTENTS, INITIAL_SIZE, ENGINE, EXTRA FROM INFORMATION_SCHEMA.FILES WHERE FILE_TYPE = 'UNDO LOG' AND FILE_NAME IS NOT NULL"; - static const size_t mysqldump_magic_str_len= sizeof(mysqldump_magic_str) -1; - if (SQLCOM_SELECT != lex->sql_command || - thd->query_length() < mysqldump_magic_str_len || - strncmp(thd->query(), mysqldump_magic_str, mysqldump_magic_str_len)) - { -#endif /* DIRTY_HACK */ my_message(ER_UNKNOWN_COM_ERROR, "WSREP has not yet prepared node for application use", MYF(0)); goto error; -#if DIRTY_HACK - } - else - { - /* mysqldump connection, allow all further queries to pass */ - thd->variables.wsrep_on= FALSE; - } -#endif /* DIRTY_HACK */ } } #endif /* WITH_WSREP */ From df96eb5d049db22157ad0c01ac0e50c7beb79a88 Mon Sep 17 00:00:00 2001 From: sjaakola Date: Thu, 18 Feb 2016 14:34:53 +0200 Subject: [PATCH 17/68] Refs: MW-248 - test cases from PXC for reproducing the issue - initial fix --- .../galera/r/galera_as_slave_autoinc.result | 61 ++++++++++ .../r/galera_binlog_stmt_autoinc.result | 74 ++++++++++++ .../galera/t/galera_as_slave_autoinc.cnf | 1 + .../galera/t/galera_as_slave_autoinc.test | 79 ++++++++++++ .../galera/t/galera_binlog_stmt_autoinc.test | 114 ++++++++++++++++++ sql/sql_class.h | 1 + sql/sql_parse.cc | 23 ++-- 7 files changed, 341 insertions(+), 12 deletions(-) create mode 100644 mysql-test/suite/galera/r/galera_as_slave_autoinc.result create mode 100644 mysql-test/suite/galera/r/galera_binlog_stmt_autoinc.result create mode 100644 mysql-test/suite/galera/t/galera_as_slave_autoinc.cnf create mode 100644 mysql-test/suite/galera/t/galera_as_slave_autoinc.test create mode 100644 mysql-test/suite/galera/t/galera_binlog_stmt_autoinc.test diff --git a/mysql-test/suite/galera/r/galera_as_slave_autoinc.result b/mysql-test/suite/galera/r/galera_as_slave_autoinc.result new file mode 100644 index 0000000000000..b3a4cd770444b --- /dev/null +++ b/mysql-test/suite/galera/r/galera_as_slave_autoinc.result @@ -0,0 +1,61 @@ +START SLAVE USER='root'; +Warnings: +Note 1759 Sending passwords in plain text without SSL/TLS is extremely insecure. +SET SESSION binlog_format='STATEMENT'; +CREATE TABLE t1 ( +i int(11) NOT NULL AUTO_INCREMENT, +c char(32) DEFAULT 'dummy_text', +PRIMARY KEY (i) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +insert into t1(i) values(null); +select * from t1; +i c +1 dummy_text +insert into t1(i) values(null), (null), (null); +select * from t1; +i c +1 dummy_text +2 dummy_text +3 dummy_text +4 dummy_text +show variables like 'binlog_format'; +Variable_name Value +binlog_format STATEMENT +show variables like '%auto_increment%'; +Variable_name Value +auto_increment_increment 1 +auto_increment_offset 1 +wsrep_auto_increment_control ON +select * from t1; +i c +1 dummy_text +2 dummy_text +3 dummy_text +4 dummy_text +show variables like 'binlog_format'; +Variable_name Value +binlog_format ROW +show variables like '%auto_increment%'; +Variable_name Value +auto_increment_increment 2 +auto_increment_offset 1 +wsrep_auto_increment_control ON +select * from t1; +i c +1 dummy_text +2 dummy_text +3 dummy_text +4 dummy_text +show variables like 'binlog_format'; +Variable_name Value +binlog_format ROW +show variables like '%auto_increment%'; +Variable_name Value +auto_increment_increment 2 +auto_increment_offset 2 +wsrep_auto_increment_control ON +DROP TABLE t1; +STOP SLAVE; +RESET SLAVE ALL; +SET GLOBAL binlog_format='ROW'; +RESET MASTER; diff --git a/mysql-test/suite/galera/r/galera_binlog_stmt_autoinc.result b/mysql-test/suite/galera/r/galera_binlog_stmt_autoinc.result new file mode 100644 index 0000000000000..6237ed7d5d881 --- /dev/null +++ b/mysql-test/suite/galera/r/galera_binlog_stmt_autoinc.result @@ -0,0 +1,74 @@ +SET GLOBAL wsrep_forced_binlog_format='STATEMENT'; +SET GLOBAL wsrep_forced_binlog_format='STATEMENT'; +CREATE TABLE t1 ( +i int(11) NOT NULL AUTO_INCREMENT, +c char(32) DEFAULT 'dummy_text', +PRIMARY KEY (i) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +insert into t1(i) values(null); +select * from t1; +i c +1 dummy_text +insert into t1(i) values(null), (null), (null); +select * from t1; +i c +1 dummy_text +3 dummy_text +5 dummy_text +7 dummy_text +select * from t1; +i c +1 dummy_text +3 dummy_text +5 dummy_text +7 dummy_text +SET GLOBAL wsrep_forced_binlog_format='none'; +SET GLOBAL wsrep_forced_binlog_format='none'; +drop table t1; +SET SESSION binlog_format='STATEMENT'; +show variables like 'binlog_format'; +Variable_name Value +binlog_format STATEMENT +SET GLOBAL wsrep_auto_increment_control='OFF'; +SET SESSION auto_increment_increment = 3; +SET SESSION auto_increment_offset = 1; +CREATE TABLE t1 ( +i int(11) NOT NULL AUTO_INCREMENT, +c char(32) DEFAULT 'dummy_text', +PRIMARY KEY (i) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +insert into t1(i) values(null); +select * from t1; +i c +1 dummy_text +insert into t1(i) values(null), (null), (null); +select * from t1; +i c +1 dummy_text +4 dummy_text +7 dummy_text +10 dummy_text +select * from t1; +i c +1 dummy_text +4 dummy_text +7 dummy_text +10 dummy_text +SET GLOBAL wsrep_auto_increment_control='ON'; +SET SESSION binlog_format='ROW'; +show variables like 'binlog_format'; +Variable_name Value +binlog_format ROW +show variables like '%auto_increment%'; +Variable_name Value +auto_increment_increment 2 +auto_increment_offset 1 +wsrep_auto_increment_control ON +SET GLOBAL wsrep_auto_increment_control='OFF'; +show variables like '%auto_increment%'; +Variable_name Value +auto_increment_increment 3 +auto_increment_offset 1 +wsrep_auto_increment_control OFF +SET GLOBAL wsrep_auto_increment_control='ON'; +drop table t1; diff --git a/mysql-test/suite/galera/t/galera_as_slave_autoinc.cnf b/mysql-test/suite/galera/t/galera_as_slave_autoinc.cnf new file mode 100644 index 0000000000000..9449ec9cf40fd --- /dev/null +++ b/mysql-test/suite/galera/t/galera_as_slave_autoinc.cnf @@ -0,0 +1 @@ +!include ../galera_2nodes_as_slave.cnf diff --git a/mysql-test/suite/galera/t/galera_as_slave_autoinc.test b/mysql-test/suite/galera/t/galera_as_slave_autoinc.test new file mode 100644 index 0000000000000..a1520a739052a --- /dev/null +++ b/mysql-test/suite/galera/t/galera_as_slave_autoinc.test @@ -0,0 +1,79 @@ +# +# Test Galera as a slave to a MySQL master +# +# The galera/galera_2node_slave.cnf describes the setup of the nodes +# + +--source include/have_innodb.inc +--source include/have_log_bin.inc + +# As node #1 is not a Galera node, we connect to node #2 in order to run include/galera_cluster.inc +--connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2 +--source include/galera_cluster.inc + +--connection node_2 +--disable_query_log +--eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$NODE_MYPORT_1; +--enable_query_log +START SLAVE USER='root'; + +--connection node_1 + +## +## Verify the correct operation of the auto-increment when +## the binlog format set to the 'STATEMENT' on the master node: +## + +SET SESSION binlog_format='STATEMENT'; + +CREATE TABLE t1 ( + i int(11) NOT NULL AUTO_INCREMENT, + c char(32) DEFAULT 'dummy_text', + PRIMARY KEY (i) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +insert into t1(i) values(null); + +select * from t1; + +insert into t1(i) values(null), (null), (null); + +select * from t1; + +show variables like 'binlog_format'; +show variables like '%auto_increment%'; + +--connection node_2 +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; +--source include/wait_condition.inc + +--let $wait_condition = SELECT COUNT(*) = 4 FROM t1; +--source include/wait_condition.inc + +select * from t1; + +show variables like 'binlog_format'; +show variables like '%auto_increment%'; + +--connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3 + +select * from t1; + +show variables like 'binlog_format'; +show variables like '%auto_increment%'; + +--connection node_1 +DROP TABLE t1; + +--connection node_2 +--let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; +--source include/wait_condition.inc + +STOP SLAVE; +RESET SLAVE ALL; + +--connection node_1 + +SET GLOBAL binlog_format='ROW'; + +RESET MASTER; diff --git a/mysql-test/suite/galera/t/galera_binlog_stmt_autoinc.test b/mysql-test/suite/galera/t/galera_binlog_stmt_autoinc.test new file mode 100644 index 0000000000000..e35aa4642f53c --- /dev/null +++ b/mysql-test/suite/galera/t/galera_binlog_stmt_autoinc.test @@ -0,0 +1,114 @@ +## +## Tests the auto-increment with binlog in STATEMENT mode. +## + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +## +## Verify the correct operation of the auto-increment when the binlog +## format artificially set to the 'STATEMENT' (although this mode is +## not recommended in the current version): +## + +--connection node_2 +SET GLOBAL wsrep_forced_binlog_format='STATEMENT'; + +--connection node_1 +SET GLOBAL wsrep_forced_binlog_format='STATEMENT'; + +CREATE TABLE t1 ( + i int(11) NOT NULL AUTO_INCREMENT, + c char(32) DEFAULT 'dummy_text', + PRIMARY KEY (i) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +insert into t1(i) values(null); + +select * from t1; + +insert into t1(i) values(null), (null), (null); + +select * from t1; + +--connection node_2 + +select * from t1; + +SET GLOBAL wsrep_forced_binlog_format='none'; + +--connection node_1 + +SET GLOBAL wsrep_forced_binlog_format='none'; + +drop table t1; + +## +## Check the operation when the automatic control over the auto-increment +## settings is switched off, that is, when we use the increment step and +## the offset specified by the user. In the current session, the binlog +## format is set to 'STATEMENT'. It is important that the values of the +## auto-increment options does not changed on other node - it allows us +## to check the correct transmission of the auto-increment options to +## other nodes: +## + +--disable_warnings +SET SESSION binlog_format='STATEMENT'; +--enable_warnings + +show variables like 'binlog_format'; + +SET GLOBAL wsrep_auto_increment_control='OFF'; + +SET SESSION auto_increment_increment = 3; +SET SESSION auto_increment_offset = 1; + +CREATE TABLE t1 ( + i int(11) NOT NULL AUTO_INCREMENT, + c char(32) DEFAULT 'dummy_text', + PRIMARY KEY (i) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +insert into t1(i) values(null); + +select * from t1; + +insert into t1(i) values(null), (null), (null); + +select * from t1; + +--connection node_2 + +select * from t1; + +--connection node_1 + +## +## Verify the return to automatic calculation of the step +## and offset of the auto-increment: +## + +SET GLOBAL wsrep_auto_increment_control='ON'; + +SET SESSION binlog_format='ROW'; + +show variables like 'binlog_format'; +show variables like '%auto_increment%'; + +## +## Verify the recovery of original user-defined values after +## stopping the automatic control over auto-increment: +## + +SET GLOBAL wsrep_auto_increment_control='OFF'; + +show variables like '%auto_increment%'; + +## +## Restore original options and drop test table: +## + +SET GLOBAL wsrep_auto_increment_control='ON'; + +drop table t1; diff --git a/sql/sql_class.h b/sql/sql_class.h index bf3d043cc1a3a..ee637b3726d28 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -660,6 +660,7 @@ typedef struct system_variables uint wsrep_sync_wait; ulong wsrep_retry_autocommit; ulong wsrep_OSU_method; + ulong wsrep_auto_increment_control; #endif double long_query_time_double; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 34c4474a9e205..c8f3c5ae4bfa0 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -6805,18 +6805,17 @@ void THD::reset_for_next_command() transactions. Appliers and replayers are either processing ROW events or get autoinc variable values from Query_log_event. */ - if (WSREP(thd) && thd->wsrep_exec_mode == LOCAL_STATE) { - if (wsrep_auto_increment_control) - { - if (thd->variables.auto_increment_offset != - global_system_variables.auto_increment_offset) - thd->variables.auto_increment_offset= - global_system_variables.auto_increment_offset; - if (thd->variables.auto_increment_increment != - global_system_variables.auto_increment_increment) - thd->variables.auto_increment_increment= - global_system_variables.auto_increment_increment; - } + if (WSREP(thd) && thd->wsrep_exec_mode == LOCAL_STATE && + !thd->slave_thread && wsrep_auto_increment_control) + { + if (thd->variables.auto_increment_offset != + global_system_variables.auto_increment_offset) + thd->variables.auto_increment_offset= + global_system_variables.auto_increment_offset; + if (thd->variables.auto_increment_increment != + global_system_variables.auto_increment_increment) + thd->variables.auto_increment_increment= + global_system_variables.auto_increment_increment; } #endif /* WITH_WSREP */ thd->query_start_used= 0; From 5edf55be631d86a92e1faaa9e0c2792be8f41c29 Mon Sep 17 00:00:00 2001 From: sjaakola Date: Fri, 19 Feb 2016 11:48:09 +0200 Subject: [PATCH 18/68] Refs: MW-248 - fixed the test case and extended with autoinc modification is master side --- .../galera/r/galera_as_slave_autoinc.result | 41 +++++++++++++++---- .../galera/t/galera_as_slave_autoinc.test | 17 +++++--- 2 files changed, 43 insertions(+), 15 deletions(-) diff --git a/mysql-test/suite/galera/r/galera_as_slave_autoinc.result b/mysql-test/suite/galera/r/galera_as_slave_autoinc.result index b3a4cd770444b..a8f5ec8e37e32 100644 --- a/mysql-test/suite/galera/r/galera_as_slave_autoinc.result +++ b/mysql-test/suite/galera/r/galera_as_slave_autoinc.result @@ -18,13 +18,29 @@ i c 2 dummy_text 3 dummy_text 4 dummy_text +SET SESSION auto_increment_increment=7; +insert into t1(i) values(null), (null), (null); +SET SESSION auto_increment_offset=5; +insert into t1(i) values(null), (null), (null); +select * from t1; +i c +1 dummy_text +2 dummy_text +3 dummy_text +4 dummy_text +8 dummy_text +15 dummy_text +22 dummy_text +33 dummy_text +40 dummy_text +47 dummy_text show variables like 'binlog_format'; Variable_name Value binlog_format STATEMENT show variables like '%auto_increment%'; Variable_name Value -auto_increment_increment 1 -auto_increment_offset 1 +auto_increment_increment 7 +auto_increment_offset 5 wsrep_auto_increment_control ON select * from t1; i c @@ -32,30 +48,37 @@ i c 2 dummy_text 3 dummy_text 4 dummy_text +8 dummy_text +15 dummy_text +22 dummy_text +33 dummy_text +40 dummy_text +47 dummy_text show variables like 'binlog_format'; Variable_name Value binlog_format ROW -show variables like '%auto_increment%'; +show variables like 'auto_increment_increment'; Variable_name Value auto_increment_increment 2 -auto_increment_offset 1 -wsrep_auto_increment_control ON select * from t1; i c 1 dummy_text 2 dummy_text 3 dummy_text 4 dummy_text +8 dummy_text +15 dummy_text +22 dummy_text +33 dummy_text +40 dummy_text +47 dummy_text show variables like 'binlog_format'; Variable_name Value binlog_format ROW -show variables like '%auto_increment%'; +show variables like 'auto_increment_increment'; Variable_name Value auto_increment_increment 2 -auto_increment_offset 2 -wsrep_auto_increment_control ON DROP TABLE t1; STOP SLAVE; RESET SLAVE ALL; -SET GLOBAL binlog_format='ROW'; RESET MASTER; diff --git a/mysql-test/suite/galera/t/galera_as_slave_autoinc.test b/mysql-test/suite/galera/t/galera_as_slave_autoinc.test index a1520a739052a..bf04b274ca7d1 100644 --- a/mysql-test/suite/galera/t/galera_as_slave_autoinc.test +++ b/mysql-test/suite/galera/t/galera_as_slave_autoinc.test @@ -40,6 +40,14 @@ insert into t1(i) values(null), (null), (null); select * from t1; +SET SESSION auto_increment_increment=7; +insert into t1(i) values(null), (null), (null); + +SET SESSION auto_increment_offset=5; +insert into t1(i) values(null), (null), (null); + +select * from t1; + show variables like 'binlog_format'; show variables like '%auto_increment%'; @@ -47,20 +55,20 @@ show variables like '%auto_increment%'; --let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; --source include/wait_condition.inc ---let $wait_condition = SELECT COUNT(*) = 4 FROM t1; +--let $wait_condition = SELECT COUNT(*) = 10 FROM t1; --source include/wait_condition.inc select * from t1; show variables like 'binlog_format'; -show variables like '%auto_increment%'; +show variables like 'auto_increment_increment'; --connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3 select * from t1; show variables like 'binlog_format'; -show variables like '%auto_increment%'; +show variables like 'auto_increment_increment'; --connection node_1 DROP TABLE t1; @@ -73,7 +81,4 @@ STOP SLAVE; RESET SLAVE ALL; --connection node_1 - -SET GLOBAL binlog_format='ROW'; - RESET MASTER; From ae0fec9c365a7a870b180ebbde6c68b01839fed4 Mon Sep 17 00:00:00 2001 From: sjaakola Date: Fri, 19 Feb 2016 13:02:59 +0200 Subject: [PATCH 19/68] refs: MW-248 - removed the off topic mtr test --- .../r/galera_binlog_stmt_autoinc.result | 74 ------------ .../galera/t/galera_binlog_stmt_autoinc.test | 114 ------------------ 2 files changed, 188 deletions(-) delete mode 100644 mysql-test/suite/galera/r/galera_binlog_stmt_autoinc.result delete mode 100644 mysql-test/suite/galera/t/galera_binlog_stmt_autoinc.test diff --git a/mysql-test/suite/galera/r/galera_binlog_stmt_autoinc.result b/mysql-test/suite/galera/r/galera_binlog_stmt_autoinc.result deleted file mode 100644 index 6237ed7d5d881..0000000000000 --- a/mysql-test/suite/galera/r/galera_binlog_stmt_autoinc.result +++ /dev/null @@ -1,74 +0,0 @@ -SET GLOBAL wsrep_forced_binlog_format='STATEMENT'; -SET GLOBAL wsrep_forced_binlog_format='STATEMENT'; -CREATE TABLE t1 ( -i int(11) NOT NULL AUTO_INCREMENT, -c char(32) DEFAULT 'dummy_text', -PRIMARY KEY (i) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; -insert into t1(i) values(null); -select * from t1; -i c -1 dummy_text -insert into t1(i) values(null), (null), (null); -select * from t1; -i c -1 dummy_text -3 dummy_text -5 dummy_text -7 dummy_text -select * from t1; -i c -1 dummy_text -3 dummy_text -5 dummy_text -7 dummy_text -SET GLOBAL wsrep_forced_binlog_format='none'; -SET GLOBAL wsrep_forced_binlog_format='none'; -drop table t1; -SET SESSION binlog_format='STATEMENT'; -show variables like 'binlog_format'; -Variable_name Value -binlog_format STATEMENT -SET GLOBAL wsrep_auto_increment_control='OFF'; -SET SESSION auto_increment_increment = 3; -SET SESSION auto_increment_offset = 1; -CREATE TABLE t1 ( -i int(11) NOT NULL AUTO_INCREMENT, -c char(32) DEFAULT 'dummy_text', -PRIMARY KEY (i) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; -insert into t1(i) values(null); -select * from t1; -i c -1 dummy_text -insert into t1(i) values(null), (null), (null); -select * from t1; -i c -1 dummy_text -4 dummy_text -7 dummy_text -10 dummy_text -select * from t1; -i c -1 dummy_text -4 dummy_text -7 dummy_text -10 dummy_text -SET GLOBAL wsrep_auto_increment_control='ON'; -SET SESSION binlog_format='ROW'; -show variables like 'binlog_format'; -Variable_name Value -binlog_format ROW -show variables like '%auto_increment%'; -Variable_name Value -auto_increment_increment 2 -auto_increment_offset 1 -wsrep_auto_increment_control ON -SET GLOBAL wsrep_auto_increment_control='OFF'; -show variables like '%auto_increment%'; -Variable_name Value -auto_increment_increment 3 -auto_increment_offset 1 -wsrep_auto_increment_control OFF -SET GLOBAL wsrep_auto_increment_control='ON'; -drop table t1; diff --git a/mysql-test/suite/galera/t/galera_binlog_stmt_autoinc.test b/mysql-test/suite/galera/t/galera_binlog_stmt_autoinc.test deleted file mode 100644 index e35aa4642f53c..0000000000000 --- a/mysql-test/suite/galera/t/galera_binlog_stmt_autoinc.test +++ /dev/null @@ -1,114 +0,0 @@ -## -## Tests the auto-increment with binlog in STATEMENT mode. -## - ---source include/galera_cluster.inc ---source include/have_innodb.inc - -## -## Verify the correct operation of the auto-increment when the binlog -## format artificially set to the 'STATEMENT' (although this mode is -## not recommended in the current version): -## - ---connection node_2 -SET GLOBAL wsrep_forced_binlog_format='STATEMENT'; - ---connection node_1 -SET GLOBAL wsrep_forced_binlog_format='STATEMENT'; - -CREATE TABLE t1 ( - i int(11) NOT NULL AUTO_INCREMENT, - c char(32) DEFAULT 'dummy_text', - PRIMARY KEY (i) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - -insert into t1(i) values(null); - -select * from t1; - -insert into t1(i) values(null), (null), (null); - -select * from t1; - ---connection node_2 - -select * from t1; - -SET GLOBAL wsrep_forced_binlog_format='none'; - ---connection node_1 - -SET GLOBAL wsrep_forced_binlog_format='none'; - -drop table t1; - -## -## Check the operation when the automatic control over the auto-increment -## settings is switched off, that is, when we use the increment step and -## the offset specified by the user. In the current session, the binlog -## format is set to 'STATEMENT'. It is important that the values of the -## auto-increment options does not changed on other node - it allows us -## to check the correct transmission of the auto-increment options to -## other nodes: -## - ---disable_warnings -SET SESSION binlog_format='STATEMENT'; ---enable_warnings - -show variables like 'binlog_format'; - -SET GLOBAL wsrep_auto_increment_control='OFF'; - -SET SESSION auto_increment_increment = 3; -SET SESSION auto_increment_offset = 1; - -CREATE TABLE t1 ( - i int(11) NOT NULL AUTO_INCREMENT, - c char(32) DEFAULT 'dummy_text', - PRIMARY KEY (i) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - -insert into t1(i) values(null); - -select * from t1; - -insert into t1(i) values(null), (null), (null); - -select * from t1; - ---connection node_2 - -select * from t1; - ---connection node_1 - -## -## Verify the return to automatic calculation of the step -## and offset of the auto-increment: -## - -SET GLOBAL wsrep_auto_increment_control='ON'; - -SET SESSION binlog_format='ROW'; - -show variables like 'binlog_format'; -show variables like '%auto_increment%'; - -## -## Verify the recovery of original user-defined values after -## stopping the automatic control over auto-increment: -## - -SET GLOBAL wsrep_auto_increment_control='OFF'; - -show variables like '%auto_increment%'; - -## -## Restore original options and drop test table: -## - -SET GLOBAL wsrep_auto_increment_control='ON'; - -drop table t1; From da9650a36a9e1d9b78a55d6f40a37b984d03bce4 Mon Sep 17 00:00:00 2001 From: sjaakola Date: Fri, 19 Feb 2016 13:08:22 +0200 Subject: [PATCH 20/68] Refs: MW-248 - some more code cleanup --- sql/sql_parse.cc | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index c8f3c5ae4bfa0..3c8254ac65148 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -6803,19 +6803,18 @@ void THD::reset_for_next_command() /* Autoinc variables should be adjusted only for locally executed transactions. Appliers and replayers are either processing ROW - events or get autoinc variable values from Query_log_event. + events or get autoinc variable values from Query_log_event and + mysql slave may be processing STATEMENT format events, but he should + use autoinc values passed in binlog events, not the values forced by + the cluster. */ if (WSREP(thd) && thd->wsrep_exec_mode == LOCAL_STATE && !thd->slave_thread && wsrep_auto_increment_control) { - if (thd->variables.auto_increment_offset != - global_system_variables.auto_increment_offset) - thd->variables.auto_increment_offset= - global_system_variables.auto_increment_offset; - if (thd->variables.auto_increment_increment != - global_system_variables.auto_increment_increment) - thd->variables.auto_increment_increment= - global_system_variables.auto_increment_increment; + thd->variables.auto_increment_offset= + global_system_variables.auto_increment_offset; + thd->variables.auto_increment_increment= + global_system_variables.auto_increment_increment; } #endif /* WITH_WSREP */ thd->query_start_used= 0; From 4290117b79bccec71b4a92c99beb3e15668627e7 Mon Sep 17 00:00:00 2001 From: sjaakola Date: Mon, 29 Feb 2016 15:24:06 +0200 Subject: [PATCH 21/68] Refs MW-252 - enveloped FTWRL processing with wsrep desync/resync calls. This way FTWRL processing node will not cause flow control to kick in - donor servicing thread is unfortunate exception, we must let him to pause provider as part of FTWRL phase, but not desync/resync as this is done as part of donor control on higher level --- sql/lock.cc | 41 ++++++++++++++++++++++++++++++++++++++++- sql/sql_class.cc | 3 ++- sql/sql_class.h | 1 + sql/wsrep_sst.cc | 1 + 4 files changed, 44 insertions(+), 2 deletions(-) diff --git a/sql/lock.cc b/sql/lock.cc index 07ea0b1f6dc7a..f724606a46de1 100644 --- a/sql/lock.cc +++ b/sql/lock.cc @@ -1071,6 +1071,16 @@ void Global_read_lock::unlock_global_read_lock(THD *thd) #ifdef WITH_WSREP wsrep_locked_seqno= WSREP_SEQNO_UNDEFINED; wsrep->resume(wsrep); + if (!wsrep_desync && !thd->wsrep_donor) + { + int ret = wsrep->resync(wsrep); + if (ret != WSREP_OK) + { + WSREP_WARN("resync failed %d for FTWRL: db: %s, query: %s", ret, + (thd->db ? thd->db : "(null)"), thd->query()); + DBUG_VOID_RETURN; + } + } #endif /* WITH_WSREP */ } thd->mdl_context.release_lock(m_mdl_global_shared_lock); @@ -1106,7 +1116,7 @@ bool Global_read_lock::make_global_read_lock_block_commit(THD *thd) */ #ifdef WITH_WSREP - if (m_mdl_blocks_commits_lock) + if (WSREP(thd) && m_mdl_blocks_commits_lock) { WSREP_DEBUG("GRL was in block commit mode when entering " "make_global_read_lock_block_commit"); @@ -1131,6 +1141,35 @@ bool Global_read_lock::make_global_read_lock_block_commit(THD *thd) m_state= GRL_ACQUIRED_AND_BLOCKS_COMMIT; #ifdef WITH_WSREP + /* Native threads should bail out before wsrep oprations to follow. + Donor servicing thread is an exception, it should pause provider but not desync, + as it is already desynced in donor state + */ + if (!WSREP(thd) && !thd->wsrep_donor) + { + DBUG_RETURN(FALSE); + } + + /* if already desynced or donor, avoid double desyncing */ + if (wsrep_desync || thd->wsrep_donor) + { + WSREP_DEBUG("desync set upfont, skipping implicit desync for FTWRL: %d", + wsrep_desync); + } + else + { + int rcode; + WSREP_DEBUG("running implicit desync for node"); + rcode = wsrep->desync(wsrep); + if (rcode != WSREP_OK) + { + WSREP_WARN("FTWRL desync failed %d for schema: %s, query: %s", + rcode, (thd->db ? thd->db : "(null)"), thd->query()); + my_message(ER_LOCK_DEADLOCK, "wsrep desync failed for FTWRL", MYF(0)); + DBUG_RETURN(TRUE); + } + } + long long ret = wsrep->pause(wsrep); if (ret >= 0) { diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 4873586aba55b..6495069971bc8 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -1088,7 +1088,8 @@ THD::THD() wsrep_po_in_trans(FALSE), wsrep_apply_format(0), wsrep_apply_toi(false), - wsrep_skip_append_keys(false) + wsrep_skip_append_keys(false), + wsrep_donor(false) #endif { ulong tmp; diff --git a/sql/sql_class.h b/sql/sql_class.h index ee637b3726d28..6181333e1b27a 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -3880,6 +3880,7 @@ class THD :public Statement, bool wsrep_apply_toi; /* applier processing in TOI */ bool wsrep_skip_append_keys; wsrep_gtid_t wsrep_sync_wait_gtid; + my_bool wsrep_donor; /* true if thread is SST donor servicing */ ulong wsrep_affected_rows; #endif /* WITH_WSREP */ }; diff --git a/sql/wsrep_sst.cc b/sql/wsrep_sst.cc index b697a557476ea..d13148b3d489e 100644 --- a/sql/wsrep_sst.cc +++ b/sql/wsrep_sst.cc @@ -979,6 +979,7 @@ static void* sst_donor_thread (void* a) wsp::thd thd(FALSE); // we turn off wsrep_on for this THD so that it can // operate with wsrep_ready == OFF + thd.ptr->wsrep_donor = true; wsp::process proc(arg->cmd, "r", arg->env); err= proc.error(); From b159b666e5191b22618e631e9ed48159be541f7e Mon Sep 17 00:00:00 2001 From: sjaakola Date: Mon, 29 Feb 2016 16:36:17 +0200 Subject: [PATCH 22/68] Refs MW-252 - Calling FTWRL two times in a row caused desync error, this is fixed by making sub-sequent FTWRL calls bail out before wsrep operations --- sql/lock.cc | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/sql/lock.cc b/sql/lock.cc index f724606a46de1..04529308266d8 100644 --- a/sql/lock.cc +++ b/sql/lock.cc @@ -1120,11 +1120,7 @@ bool Global_read_lock::make_global_read_lock_block_commit(THD *thd) { WSREP_DEBUG("GRL was in block commit mode when entering " "make_global_read_lock_block_commit"); - thd->mdl_context.release_lock(m_mdl_blocks_commits_lock); - m_mdl_blocks_commits_lock= NULL; - wsrep_locked_seqno= WSREP_SEQNO_UNDEFINED; - wsrep->resume(wsrep); - m_state= GRL_ACQUIRED; + DBUG_RETURN(FALSE); } #endif /* WITH_WSREP */ From 8ec50ebda3c558e34f263c08b2661929f0bdad2d Mon Sep 17 00:00:00 2001 From: sjaakola Date: Mon, 29 Feb 2016 22:54:58 +0200 Subject: [PATCH 23/68] Refs MW-252 - reverted from tracking donor servicing thread. With xtrabackup SST, xtrabackup thread will call FTWRL and node is desynced upfront - Skipping desync in FTWRL if node is operating as donor --- sql/lock.cc | 6 +++--- sql/sql_class.cc | 3 +-- sql/sql_class.h | 1 - sql/wsrep_mysqld.cc | 5 +++++ sql/wsrep_mysqld.h | 1 + sql/wsrep_sst.cc | 1 - 6 files changed, 10 insertions(+), 7 deletions(-) diff --git a/sql/lock.cc b/sql/lock.cc index 04529308266d8..8c426deda1705 100644 --- a/sql/lock.cc +++ b/sql/lock.cc @@ -1071,7 +1071,7 @@ void Global_read_lock::unlock_global_read_lock(THD *thd) #ifdef WITH_WSREP wsrep_locked_seqno= WSREP_SEQNO_UNDEFINED; wsrep->resume(wsrep); - if (!wsrep_desync && !thd->wsrep_donor) + if (!wsrep_desync && !wsrep_node_is_donor()) { int ret = wsrep->resync(wsrep); if (ret != WSREP_OK) @@ -1141,13 +1141,13 @@ bool Global_read_lock::make_global_read_lock_block_commit(THD *thd) Donor servicing thread is an exception, it should pause provider but not desync, as it is already desynced in donor state */ - if (!WSREP(thd) && !thd->wsrep_donor) + if (!WSREP(thd) && !wsrep_node_is_donor()) { DBUG_RETURN(FALSE); } /* if already desynced or donor, avoid double desyncing */ - if (wsrep_desync || thd->wsrep_donor) + if (wsrep_desync || wsrep_node_is_donor()) { WSREP_DEBUG("desync set upfont, skipping implicit desync for FTWRL: %d", wsrep_desync); diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 6495069971bc8..4873586aba55b 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -1088,8 +1088,7 @@ THD::THD() wsrep_po_in_trans(FALSE), wsrep_apply_format(0), wsrep_apply_toi(false), - wsrep_skip_append_keys(false), - wsrep_donor(false) + wsrep_skip_append_keys(false) #endif { ulong tmp; diff --git a/sql/sql_class.h b/sql/sql_class.h index 6181333e1b27a..ee637b3726d28 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -3880,7 +3880,6 @@ class THD :public Statement, bool wsrep_apply_toi; /* applier processing in TOI */ bool wsrep_skip_append_keys; wsrep_gtid_t wsrep_sync_wait_gtid; - my_bool wsrep_donor; /* true if thread is SST donor servicing */ ulong wsrep_affected_rows; #endif /* WITH_WSREP */ }; diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc index 0dd5c4dba1454..734406080e9c5 100644 --- a/sql/wsrep_mysqld.cc +++ b/sql/wsrep_mysqld.cc @@ -1587,3 +1587,8 @@ wsrep_grant_mdl_exception(MDL_context *requestor_ctx, } return ret; } + +bool wsrep_node_is_donor() +{ + return (WSREP_ON) ? (local_status.get() == 2) : false; +} diff --git a/sql/wsrep_mysqld.h b/sql/wsrep_mysqld.h index 242227fd2a0bd..514c1f32cffcc 100644 --- a/sql/wsrep_mysqld.h +++ b/sql/wsrep_mysqld.h @@ -330,4 +330,5 @@ int wsrep_alter_event_query(THD *thd, uchar** buf, size_t* buf_len); void wsrep_init_sidno(const wsrep_uuid_t&); #endif /* GTID_SUPPORT */ +bool wsrep_node_is_donor(); #endif /* WSREP_MYSQLD_H */ diff --git a/sql/wsrep_sst.cc b/sql/wsrep_sst.cc index d13148b3d489e..b697a557476ea 100644 --- a/sql/wsrep_sst.cc +++ b/sql/wsrep_sst.cc @@ -979,7 +979,6 @@ static void* sst_donor_thread (void* a) wsp::thd thd(FALSE); // we turn off wsrep_on for this THD so that it can // operate with wsrep_ready == OFF - thd.ptr->wsrep_donor = true; wsp::process proc(arg->cmd, "r", arg->env); err= proc.error(); From a03c45fa980ab170cd509d10923916aa9d9c4f86 Mon Sep 17 00:00:00 2001 From: sjaakola Date: Tue, 1 Mar 2016 10:56:21 +0200 Subject: [PATCH 24/68] Refs: MW-252 - if wsrep_on==OFF, unlock tables would resume provider even though it was not passed in FTWRL processing. This is fixed in this patch. --- sql/lock.cc | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/sql/lock.cc b/sql/lock.cc index 8c426deda1705..fea2875373968 100644 --- a/sql/lock.cc +++ b/sql/lock.cc @@ -1069,16 +1069,19 @@ void Global_read_lock::unlock_global_read_lock(THD *thd) thd->mdl_context.release_lock(m_mdl_blocks_commits_lock); m_mdl_blocks_commits_lock= NULL; #ifdef WITH_WSREP - wsrep_locked_seqno= WSREP_SEQNO_UNDEFINED; - wsrep->resume(wsrep); - if (!wsrep_desync && !wsrep_node_is_donor()) + if (WSREP(thd) || wsrep_node_is_donor()) { - int ret = wsrep->resync(wsrep); - if (ret != WSREP_OK) + wsrep_locked_seqno= WSREP_SEQNO_UNDEFINED; + wsrep->resume(wsrep); + if (!wsrep_desync && !wsrep_node_is_donor()) { - WSREP_WARN("resync failed %d for FTWRL: db: %s, query: %s", ret, - (thd->db ? thd->db : "(null)"), thd->query()); - DBUG_VOID_RETURN; + int ret = wsrep->resync(wsrep); + if (ret != WSREP_OK) + { + WSREP_WARN("resync failed %d for FTWRL: db: %s, query: %s", ret, + (thd->db ? thd->db : "(null)"), thd->query()); + DBUG_VOID_RETURN; + } } } #endif /* WITH_WSREP */ From fe6ebb657ea02fcb5993ca5d503161056c5a5b86 Mon Sep 17 00:00:00 2001 From: Philip Stoev Date: Tue, 1 Mar 2016 08:32:06 -0800 Subject: [PATCH 25/68] Refs: MW-252 MTR tests for FTWRL and desync --- mysql-test/suite/galera/r/MW-252.result | 7 ++++ .../galera/r/galera_as_slave_nonprim.result | 2 +- .../suite/galera/r/galera_gcs_fc_limit.result | 2 +- .../galera/r/galera_var_desync_on.result | 2 + mysql-test/suite/galera/t/MW-252.test | 41 +++++++++++++++++++ .../galera/t/galera_as_slave_nonprim.test | 2 +- .../suite/galera/t/galera_gcs_fc_limit.test | 2 +- .../suite/galera/t/galera_var_desync_on.test | 4 ++ 8 files changed, 58 insertions(+), 4 deletions(-) create mode 100644 mysql-test/suite/galera/r/MW-252.result create mode 100644 mysql-test/suite/galera/t/MW-252.test diff --git a/mysql-test/suite/galera/r/MW-252.result b/mysql-test/suite/galera/r/MW-252.result new file mode 100644 index 0000000000000..c422edcb82a77 --- /dev/null +++ b/mysql-test/suite/galera/r/MW-252.result @@ -0,0 +1,7 @@ +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +FLUSH TABLES WITH READ LOCK; +SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +VARIABLE_VALUE = 2 +1 +UNLOCK TABLES; +DROP TABLE t1; diff --git a/mysql-test/suite/galera/r/galera_as_slave_nonprim.result b/mysql-test/suite/galera/r/galera_as_slave_nonprim.result index fd20f8db2f9a1..365ea31f2922d 100644 --- a/mysql-test/suite/galera/r/galera_as_slave_nonprim.result +++ b/mysql-test/suite/galera/r/galera_as_slave_nonprim.result @@ -12,7 +12,7 @@ STOP SLAVE; RESET SLAVE ALL; CALL mtr.add_suppression("Slave SQL: Error 'Unknown command' on query"); CALL mtr.add_suppression("Slave: Unknown command Error_code: 1047"); -CALL mtr.add_suppression("Send action {\\(nil\\), 328, TORDERED} returned -107 \\(Transport endpoint is not connected\\)"); +CALL mtr.add_suppression("Transport endpoint is not connected"); CALL mtr.add_suppression("Slave SQL: Error in Xid_log_event: Commit could not be completed, 'Deadlock found when trying to get lock; try restarting transaction', Error_code: 1213"); CALL mtr.add_suppression("Slave SQL: Node has dropped from cluster, Error_code: 1047"); RESET MASTER; diff --git a/mysql-test/suite/galera/r/galera_gcs_fc_limit.result b/mysql-test/suite/galera/r/galera_gcs_fc_limit.result index ad60ead4b8a84..9463b5f8eef8d 100644 --- a/mysql-test/suite/galera/r/galera_gcs_fc_limit.result +++ b/mysql-test/suite/galera/r/galera_gcs_fc_limit.result @@ -4,7 +4,7 @@ SELECT COUNT(*) = 1 FROM t1; COUNT(*) = 1 1 SET GLOBAL wsrep_provider_options = 'gcs.fc_limit=1'; -FLUSH TABLES WITH READ LOCK; +LOCK TABLE t1 WRITE; INSERT INTO t1 VALUES (2); INSERT INTO t1 VALUES (3); INSERT INTO t1 VALUES (4); diff --git a/mysql-test/suite/galera/r/galera_var_desync_on.result b/mysql-test/suite/galera/r/galera_var_desync_on.result index 0b5f34688b79f..f286ae723081e 100644 --- a/mysql-test/suite/galera/r/galera_var_desync_on.result +++ b/mysql-test/suite/galera/r/galera_var_desync_on.result @@ -26,4 +26,6 @@ INSERT INTO t1 VALUES (11); SELECT COUNT(*) = 11 FROM t1; COUNT(*) = 11 1 +CALL mtr.add_suppression("Protocol violation"); DROP TABLE t1; +CALL mtr.add_suppression("Protocol violation"); diff --git a/mysql-test/suite/galera/t/MW-252.test b/mysql-test/suite/galera/t/MW-252.test new file mode 100644 index 0000000000000..3137aea70115e --- /dev/null +++ b/mysql-test/suite/galera/t/MW-252.test @@ -0,0 +1,41 @@ +# +# MW-252 - Check that FTWRL causes the node to become desynced +# and not subject to flow control +# + +--source include/galera_cluster.inc + +--connection node_1 +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; + +FLUSH TABLES WITH READ LOCK; + +# Node #1 is now desynced +--let $wait_condition = SELECT VARIABLE_VALUE = 'Donor/Desynced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment' +--source include/wait_condition.inc + +SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; + +# Node #2 can issue updates without flow control kicking in +--connection node_2 + +--let $count = 100 +--disable_query_log +while ($count) +{ + INSERT INTO t1 VALUES (1); + --dec $count +} +--enable_query_log + +# Restore cluster +--connection node_1 +UNLOCK TABLES; + +--let $wait_condition = SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment' +--source include/wait_condition.inc + +--let $wait_condition = SELECT COUNT(*) = 100 FROM t1 +--source include/wait_condition.inc + +DROP TABLE t1; 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 5914e52d851ce..46a9345827103 100644 --- a/mysql-test/suite/galera/t/galera_as_slave_nonprim.test +++ b/mysql-test/suite/galera/t/galera_as_slave_nonprim.test @@ -87,7 +87,7 @@ RESET SLAVE ALL; CALL mtr.add_suppression("Slave SQL: Error 'Unknown command' on query"); CALL mtr.add_suppression("Slave: Unknown command Error_code: 1047"); -CALL mtr.add_suppression("Send action {\\(nil\\), 328, TORDERED} returned -107 \\(Transport endpoint is not connected\\)"); +CALL mtr.add_suppression("Transport endpoint is not connected"); CALL mtr.add_suppression("Slave SQL: Error in Xid_log_event: Commit could not be completed, 'Deadlock found when trying to get lock; try restarting transaction', Error_code: 1213"); CALL mtr.add_suppression("Slave SQL: Node has dropped from cluster, Error_code: 1047"); diff --git a/mysql-test/suite/galera/t/galera_gcs_fc_limit.test b/mysql-test/suite/galera/t/galera_gcs_fc_limit.test index fd77ec0a0eb55..721d84ecb0530 100644 --- a/mysql-test/suite/galera/t/galera_gcs_fc_limit.test +++ b/mysql-test/suite/galera/t/galera_gcs_fc_limit.test @@ -16,7 +16,7 @@ SELECT COUNT(*) = 1 FROM t1; SET GLOBAL wsrep_provider_options = 'gcs.fc_limit=1'; # Block the slave applier thread -FLUSH TABLES WITH READ LOCK; +LOCK TABLE t1 WRITE; --connection node_1 diff --git a/mysql-test/suite/galera/t/galera_var_desync_on.test b/mysql-test/suite/galera/t/galera_var_desync_on.test index fb0fb9f762a1b..06c5d30a769e2 100644 --- a/mysql-test/suite/galera/t/galera_var_desync_on.test +++ b/mysql-test/suite/galera/t/galera_var_desync_on.test @@ -55,4 +55,8 @@ INSERT INTO t1 VALUES (11); # Replication continues normally SELECT COUNT(*) = 11 FROM t1; +CALL mtr.add_suppression("Protocol violation"); DROP TABLE t1; + +--connection node_1 +CALL mtr.add_suppression("Protocol violation"); From 65cf1d354a5089ed3df328db69c79bd87b891278 Mon Sep 17 00:00:00 2001 From: Nirbhay Choubey Date: Thu, 11 Aug 2016 22:28:57 -0400 Subject: [PATCH 26/68] Refs: MW-252 Test fix post-merge --- mysql-test/suite/galera/t/MW-252.test | 1 + 1 file changed, 1 insertion(+) diff --git a/mysql-test/suite/galera/t/MW-252.test b/mysql-test/suite/galera/t/MW-252.test index 3137aea70115e..dfb82e8070a26 100644 --- a/mysql-test/suite/galera/t/MW-252.test +++ b/mysql-test/suite/galera/t/MW-252.test @@ -4,6 +4,7 @@ # --source include/galera_cluster.inc +--source include/have_innodb.inc --connection node_1 CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; From 8b998a48ccee617b7eb1232cf2793d6da67ccead Mon Sep 17 00:00:00 2001 From: Nirbhay Choubey Date: Fri, 12 Aug 2016 12:56:41 -0400 Subject: [PATCH 27/68] Update galera version-dependent tests. --- mysql-test/suite/galera/r/galera_defaults.result | 5 +++-- mysql-test/suite/galera/t/galera_defaults.test | 2 +- mysql-test/suite/wsrep/r/variables.result | 2 ++ mysql-test/suite/wsrep/t/variables.test | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/mysql-test/suite/galera/r/galera_defaults.result b/mysql-test/suite/galera/r/galera_defaults.result index 3b89ccb7dbed7..a4e6d31d406a6 100644 --- a/mysql-test/suite/galera/r/galera_defaults.result +++ b/mysql-test/suite/galera/r/galera_defaults.result @@ -47,12 +47,12 @@ 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 = PT90S; 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; gcomm.thread_prio = ; 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; socket.recv_buf_size = 212992; SELECT COUNT(*) FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME LIKE 'wsrep_%' AND VARIABLE_NAME != 'wsrep_debug_sync_waiters'; COUNT(*) -57 +58 SELECT VARIABLE_NAME FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME LIKE 'wsrep_%' AND VARIABLE_NAME != 'wsrep_debug_sync_waiters' @@ -73,6 +73,7 @@ WSREP_COMMIT_OOOE WSREP_COMMIT_OOOL WSREP_COMMIT_WINDOW WSREP_CONNECTED +WSREP_DESYNC_COUNT WSREP_EVS_DELAYED WSREP_EVS_EVICT_LIST WSREP_EVS_REPL_LATENCY diff --git a/mysql-test/suite/galera/t/galera_defaults.test b/mysql-test/suite/galera/t/galera_defaults.test index 9897d0d55dc32..87eddedafe980 100644 --- a/mysql-test/suite/galera/t/galera_defaults.test +++ b/mysql-test/suite/galera/t/galera_defaults.test @@ -13,7 +13,7 @@ # Make sure that the test is operating on the right version of galera library. --disable_query_log ---let $galera_version=3.9 +--let $galera_version=25.3.17 source ../wsrep/include/check_galera_version.inc; --enable_query_log diff --git a/mysql-test/suite/wsrep/r/variables.result b/mysql-test/suite/wsrep/r/variables.result index 9c047177ca8ce..ab2692bed1e32 100644 --- a/mysql-test/suite/wsrep/r/variables.result +++ b/mysql-test/suite/wsrep/r/variables.result @@ -60,6 +60,7 @@ wsrep_cert_index_size # wsrep_causal_reads # wsrep_cert_interval # wsrep_incoming_addresses # +wsrep_debug_sync_waiters # wsrep_cluster_conf_id # wsrep_cluster_size # wsrep_cluster_state_uuid # @@ -115,6 +116,7 @@ wsrep_cert_index_size # wsrep_causal_reads # wsrep_cert_interval # wsrep_incoming_addresses # +wsrep_debug_sync_waiters # wsrep_cluster_conf_id # wsrep_cluster_size # wsrep_cluster_state_uuid # diff --git a/mysql-test/suite/wsrep/t/variables.test b/mysql-test/suite/wsrep/t/variables.test index 6922e2d1444d1..19e900b3f78aa 100644 --- a/mysql-test/suite/wsrep/t/variables.test +++ b/mysql-test/suite/wsrep/t/variables.test @@ -28,7 +28,7 @@ CALL mtr.add_suppression("WSREP: Could not open saved state file for reading.*") --disable_query_log eval SET GLOBAL wsrep_provider= '$WSREP_PROVIDER'; ---let $galera_version=3.9 +--let $galera_version=25.3.17 source include/check_galera_version.inc; --enable_query_log From f3444c4a436ecab23b535bb2ef24e02298aa7ae9 Mon Sep 17 00:00:00 2001 From: Philip Stoev Date: Fri, 4 Mar 2016 14:20:58 +0200 Subject: [PATCH 28/68] Bump WSREP_PATCH_VERSION to 14 --- cmake/wsrep.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/wsrep.cmake b/cmake/wsrep.cmake index 61e4177816637..6c256471115a8 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 d246630d739717a58d9b1c33705ce7f1d8504b43 Mon Sep 17 00:00:00 2001 From: sjaakola Date: Mon, 7 Mar 2016 23:34:03 +0200 Subject: [PATCH 29/68] Refs MW-252 - changed the condition when to do implicit desync as part of FTWRL to cover only case when node is PC and synced. Donor node has alreaydy desycned and other states mean that node is not in cluster, so desync is not even possible. --- sql/lock.cc | 9 ++++++--- sql/wsrep_mysqld.cc | 4 ++++ sql/wsrep_mysqld.h | 1 + 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/sql/lock.cc b/sql/lock.cc index fea2875373968..7153b85d74077 100644 --- a/sql/lock.cc +++ b/sql/lock.cc @@ -1073,7 +1073,8 @@ void Global_read_lock::unlock_global_read_lock(THD *thd) { wsrep_locked_seqno= WSREP_SEQNO_UNDEFINED; wsrep->resume(wsrep); - if (!wsrep_desync && !wsrep_node_is_donor()) + /* resync here only if we did implicit desync earlier */ + if (!wsrep_desync && wsrep_node_is_synced()) { int ret = wsrep->resync(wsrep); if (ret != WSREP_OK) @@ -1149,8 +1150,10 @@ bool Global_read_lock::make_global_read_lock_block_commit(THD *thd) DBUG_RETURN(FALSE); } - /* if already desynced or donor, avoid double desyncing */ - if (wsrep_desync || wsrep_node_is_donor()) + /* if already desynced or donor, avoid double desyncing + if not in PC and synced, desyncing is not possible either + */ + if (wsrep_desync || !wsrep_node_is_synced()) { WSREP_DEBUG("desync set upfont, skipping implicit desync for FTWRL: %d", wsrep_desync); diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc index 734406080e9c5..e392aef32eb45 100644 --- a/sql/wsrep_mysqld.cc +++ b/sql/wsrep_mysqld.cc @@ -1592,3 +1592,7 @@ bool wsrep_node_is_donor() { return (WSREP_ON) ? (local_status.get() == 2) : false; } +bool wsrep_node_is_synced() +{ + return (WSREP_ON) ? (local_status.get() == 4) : false; +} diff --git a/sql/wsrep_mysqld.h b/sql/wsrep_mysqld.h index 514c1f32cffcc..f499443ca2c8d 100644 --- a/sql/wsrep_mysqld.h +++ b/sql/wsrep_mysqld.h @@ -331,4 +331,5 @@ void wsrep_init_sidno(const wsrep_uuid_t&); #endif /* GTID_SUPPORT */ bool wsrep_node_is_donor(); +bool wsrep_node_is_synced(); #endif /* WSREP_MYSQLD_H */ From 4e4ad17163709a50314cbf72d72cec2596467513 Mon Sep 17 00:00:00 2001 From: sjaakola Date: Tue, 8 Mar 2016 18:10:21 +0200 Subject: [PATCH 30/68] Refs MW-255 - popping PS reprepare observer before BF aborted PS replaying begins dangling observer will cause failure in open_table() ater on - test case for this anomaly --- .../galera/r/galera_transaction_replay.result | 27 ++++++++++ .../galera/t/galera_transaction_replay.test | 53 +++++++++++++++++++ sql/wsrep_thd.cc | 9 ++++ 3 files changed, 89 insertions(+) diff --git a/mysql-test/suite/galera/r/galera_transaction_replay.result b/mysql-test/suite/galera/r/galera_transaction_replay.result index bfafa506fe600..eec9ba03ef5b4 100644 --- a/mysql-test/suite/galera/r/galera_transaction_replay.result +++ b/mysql-test/suite/galera/r/galera_transaction_replay.result @@ -30,3 +30,30 @@ SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'c'; COUNT(*) = 1 1 DROP TABLE t1; +CREATE TABLE t1 (i int primary key, j int) ENGINE=INNODB; +INSERT INTO t1 VALUES (1, 0), (3, 0); +SELECT * FROM t1; +i j +1 0 +3 0 +PREPARE stmt1 FROM "UPDATE t1 SET j = 1 where i > 0"; +SET GLOBAL wsrep_provider_options = 'dbug=d,commit_monitor_enter_sync'; +EXECUTE stmt1;; +SET SESSION wsrep_sync_wait = 0; +SET SESSION wsrep_on = 0; +SET SESSION wsrep_on = 1; +INSERT INTO t1 VALUES(2,2); +SET GLOBAL wsrep_provider_options = 'dbug='; +SET GLOBAL wsrep_provider_options = 'signal=commit_monitor_enter_sync'; +SELECT * FROM t1; +i j +1 1 +2 2 +3 1 +SELECT * FROM t1; +i j +1 1 +2 2 +3 1 +DEALLOCATE PREPARE stmt1; +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/galera_transaction_replay.test b/mysql-test/suite/galera/t/galera_transaction_replay.test index bd5288a51c681..8e9bfa4c44911 100644 --- a/mysql-test/suite/galera/t/galera_transaction_replay.test +++ b/mysql-test/suite/galera/t/galera_transaction_replay.test @@ -69,3 +69,56 @@ SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'b'; SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'c'; DROP TABLE t1; + +#echo "# test for PS replaying" + +# +# test replaying of prepared statements +# +--connection node_1 +CREATE TABLE t1 (i int primary key, j int) ENGINE=INNODB; +INSERT INTO t1 VALUES (1, 0), (3, 0); +SELECT * FROM t1; + +PREPARE stmt1 FROM "UPDATE t1 SET j = 1 where i > 0"; + +# block the commit of PS +--connection node_1a +--let $galera_sync_point = commit_monitor_enter_sync +--source include/galera_set_sync_point.inc + +--connection node_1 +--send EXECUTE stmt1; + +# Wait until commit is blocked +--connection node_1a +SET SESSION wsrep_sync_wait = 0; +--source include/galera_wait_sync_point.inc + +# Issue a conflicting update on node_2 +--connection node_2 +#UPDATE t1 SET j=2; +INSERT INTO t1 VALUES(2,2); + + +# Wait until applying begins in node_1 +--connection node_1a +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE LIKE 'Write_rows_log_event::write_row%'; +--source include/wait_condition.inc + +# Unblock the PS commit +--connection node_1a +--source include/galera_clear_sync_point.inc +--source include/galera_signal_sync_point.inc + +# Commit succeeds +--connection node_1 +--reap +SELECT * FROM t1; + +--connection node_2 +SELECT * FROM t1; + +--connection node_1 +DEALLOCATE PREPARE stmt1; +DROP TABLE t1; diff --git a/sql/wsrep_thd.cc b/sql/wsrep_thd.cc index 9c2fa4ba85603..09ffdbd54f59c 100644 --- a/sql/wsrep_thd.cc +++ b/sql/wsrep_thd.cc @@ -185,6 +185,7 @@ static void wsrep_return_from_bf_mode(THD *thd, struct wsrep_thd_shadow* shadow) void wsrep_replay_transaction(THD *thd) { + DBUG_ENTER("wsrep_replay_transaction"); /* checking if BF trx must be replayed */ if (thd->wsrep_conflict_state== MUST_REPLAY) { DBUG_ASSERT(wsrep_thd_trx_seqno(thd)); @@ -193,6 +194,13 @@ void wsrep_replay_transaction(THD *thd) { WSREP_ERROR("replay issue, thd has reported status already"); } + + /* + PS reprepare observer should have been removed already. + open_table() will fail if we have dangling observer here. + */ + DBUG_ASSERT(thd->m_reprepare_observer == NULL); + thd->get_stmt_da()->reset_diagnostics_area(); thd->wsrep_conflict_state= REPLAYING; @@ -299,6 +307,7 @@ void wsrep_replay_transaction(THD *thd) mysql_mutex_unlock(&LOCK_wsrep_replaying); } } + DBUG_VOID_RETURN; } static void wsrep_replication_process(THD *thd) From b758e9238aac8d8b167621a9787b6d2dd92cb082 Mon Sep 17 00:00:00 2001 From: Nirbhay Choubey Date: Fri, 12 Aug 2016 13:42:12 -0400 Subject: [PATCH 31/68] Fix galera_transaction_replay.test. --- mysql-test/suite/galera/t/galera_transaction_replay.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/suite/galera/t/galera_transaction_replay.test b/mysql-test/suite/galera/t/galera_transaction_replay.test index 8e9bfa4c44911..29870829ba344 100644 --- a/mysql-test/suite/galera/t/galera_transaction_replay.test +++ b/mysql-test/suite/galera/t/galera_transaction_replay.test @@ -40,7 +40,7 @@ UPDATE t1 SET f2 = 'c' WHERE f1 = 2; # Wait for both transactions to be blocked --connection node_1a ---let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE = 'System lock'; +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE LIKE 'Update_rows_log_event::find_row%'; --source include/wait_condition.inc --let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE = 'init' AND INFO = 'COMMIT'; From a00f4b29b5a50c46641fa522c2b3235fe72ae697 Mon Sep 17 00:00:00 2001 From: Philip Stoev Date: Tue, 15 Mar 2016 03:38:31 -0700 Subject: [PATCH 32/68] Refs codership/galera#105 An MTR test for ist.recv_bind --- .../galera/r/galera_ist_recv_bind.result | 13 +++++ .../suite/galera/t/galera_ist_recv_bind.cnf | 8 +++ .../suite/galera/t/galera_ist_recv_bind.test | 53 +++++++++++++++++++ 3 files changed, 74 insertions(+) create mode 100644 mysql-test/suite/galera/r/galera_ist_recv_bind.result create mode 100644 mysql-test/suite/galera/t/galera_ist_recv_bind.cnf create mode 100644 mysql-test/suite/galera/t/galera_ist_recv_bind.test diff --git a/mysql-test/suite/galera/r/galera_ist_recv_bind.result b/mysql-test/suite/galera/r/galera_ist_recv_bind.result new file mode 100644 index 0000000000000..de4e07fbe4194 --- /dev/null +++ b/mysql-test/suite/galera/r/galera_ist_recv_bind.result @@ -0,0 +1,13 @@ +SELECT @@wsrep_provider_options LIKE '%ist.recv_bind = 127.0.0.1%'; +@@wsrep_provider_options LIKE '%ist.recv_bind = 127.0.0.1%' +1 +SELECT @@wsrep_provider_options LIKE '%ist.recv_bind = 127.0.0.1%'; +@@wsrep_provider_options LIKE '%ist.recv_bind = 127.0.0.1%' +1 +SET GLOBAL wsrep_provider_options = 'gmcast.isolate = 1'; +SET SESSION wsrep_on = OFF; +SET SESSION wsrep_on = ON; +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +SET GLOBAL wsrep_provider_options = 'gmcast.isolate = 0'; +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/galera_ist_recv_bind.cnf b/mysql-test/suite/galera/t/galera_ist_recv_bind.cnf new file mode 100644 index 0000000000000..2628f05eaef6a --- /dev/null +++ b/mysql-test/suite/galera/t/galera_ist_recv_bind.cnf @@ -0,0 +1,8 @@ +!include ../galera_2nodes.cnf + +[mysqld.1] +wsrep_provider_options='base_port=@mysqld.1.#galera_port;ist.recv_bind=127.0.0.1;pc.ignore_sb=true' + +[mysqld.2] +wsrep_provider_options='base_port=@mysqld.2.#galera_port;ist.recv_bind=127.0.0.1' + diff --git a/mysql-test/suite/galera/t/galera_ist_recv_bind.test b/mysql-test/suite/galera/t/galera_ist_recv_bind.test new file mode 100644 index 0000000000000..c04238d6ccadd --- /dev/null +++ b/mysql-test/suite/galera/t/galera_ist_recv_bind.test @@ -0,0 +1,53 @@ +# +# Test ist.recv_bind option. Since MTR can not do proper testing with multiple interfaces and such, we +# simply confirm that the option can be set (in the galera_ist_recv_bind.cnf file) and that IST works as expected +# + +--source include/galera_cluster.inc + +--connection node_1 +SELECT @@wsrep_provider_options LIKE '%ist.recv_bind = 127.0.0.1%'; + +--connection node_2 +SELECT @@wsrep_provider_options LIKE '%ist.recv_bind = 127.0.0.1%'; + +# Isolate node #2 + +SET GLOBAL wsrep_provider_options = 'gmcast.isolate = 1'; +--connection node_1 +--let $wait_condition = SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +--source include/wait_condition.inc + +--connection node_2 +SET SESSION wsrep_on = OFF; +--let $wait_condition = SELECT VARIABLE_VALUE = 'non-Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; +--source include/wait_condition.inc +SET SESSION wsrep_on = ON; + +# Node #2 is now isolated. Run some transactions to accumulate writesets for IST + +--connection node_1 +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); + +# Restore node #2 + +--connection node_2 +SET GLOBAL wsrep_provider_options = 'gmcast.isolate = 0'; + +--connection node_1 +--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +--source include/wait_condition.inc + +--connection node_2 +--let $wait_condition = SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; +--source include/wait_condition.inc + +# Confirm that IST has taken place + +--let $wait_condition = SELECT COUNT(*) = 1 FROM t1; +--source include/wait_condition.inc + +# Cleanup + +DROP TABLE t1; From 90d92d2b49eb54ea3c8d17e7db2525f20e475e94 Mon Sep 17 00:00:00 2001 From: Alexey Yurchenko Date: Sat, 2 Apr 2016 21:51:26 -0300 Subject: [PATCH 33/68] MW-258 - RSU DDL should not rely on the global wsrep_desync variable value and should always try to desync on its own. --- mysql-test/suite/galera/r/MW-258.result | 42 ++++++++++++++++++++++ mysql-test/suite/galera/t/MW-258.test | 43 ++++++++++++++++++++++ sql/wsrep_mysqld.cc | 47 ++++++++++--------------- 3 files changed, 104 insertions(+), 28 deletions(-) create mode 100644 mysql-test/suite/galera/r/MW-258.result create mode 100644 mysql-test/suite/galera/t/MW-258.test diff --git a/mysql-test/suite/galera/r/MW-258.result b/mysql-test/suite/galera/r/MW-258.result new file mode 100644 index 0000000000000..28b1e4049abf3 --- /dev/null +++ b/mysql-test/suite/galera/r/MW-258.result @@ -0,0 +1,42 @@ +CREATE TABLE t1 (f1 INTEGER); +LOCK TABLE t1 WRITE; +value prior to RSU: +SHOW STATUS LIKE 'wsrep_desync_count'; +Variable_name Value +wsrep_desync_count 0 +SHOW VARIABLES LIKE 'wsrep_desync'; +Variable_name Value +wsrep_desync OFF +SET SESSION wsrep_sync_wait = 0; +SET SESSION wsrep_osu_method = RSU; +ALTER TABLE t1 ADD COLUMN f2 INTEGER;; +SET SESSION wsrep_sync_wait = 0; +SET SESSION wsrep_osu_method = RSU; +ALTER TABLE t1 ADD COLUMN f3 INTEGER;; +value during RSU: +SHOW STATUS LIKE 'wsrep_desync_count'; +Variable_name Value +wsrep_desync_count 2 +SHOW VARIABLES LIKE 'wsrep_desync'; +Variable_name Value +wsrep_desync OFF +SHOW PROCESSLIST; +Id User Host db Command Time State Info Progress +# system user # NULL Sleep # NULL NULL 0.000 +# system user # NULL Sleep # wsrep aborter idle NULL 0.000 +# root # test Sleep # NULL 0.000 +# root # test Query # init SHOW PROCESSLIST 0.000 +# root # test Query # Waiting for table metadata lock ALTER TABLE t1 ADD COLUMN f2 INTEGER 0.000 +# root # test Query # checking permissions ALTER TABLE t1 ADD COLUMN f3 INTEGER 0.000 +UNLOCK TABLES; +value after RSU: +SHOW STATUS LIKE 'wsrep_desync_count'; +Variable_name Value +wsrep_desync_count 0 +SHOW VARIABLES LIKE 'wsrep_desync'; +Variable_name Value +wsrep_desync OFF +SET GLOBAL wsrep_desync=0; +Warnings: +Warning 1231 'wsrep_desync' is already OFF. +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/MW-258.test b/mysql-test/suite/galera/t/MW-258.test new file mode 100644 index 0000000000000..7745ef5ea9f73 --- /dev/null +++ b/mysql-test/suite/galera/t/MW-258.test @@ -0,0 +1,43 @@ +--source include/galera_cluster.inc +--source include/have_innodb.inc + +--connection node_1 +CREATE TABLE t1 (f1 INTEGER); +LOCK TABLE t1 WRITE; +--echo value prior to RSU: +SHOW STATUS LIKE 'wsrep_desync_count'; +SHOW VARIABLES LIKE 'wsrep_desync'; + +--connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1 +--connection node_1a +SET SESSION wsrep_sync_wait = 0; +SET SESSION wsrep_osu_method = RSU; +--send ALTER TABLE t1 ADD COLUMN f2 INTEGER; + +--connect node_1b, 127.0.0.1, root, , test, $NODE_MYPORT_1 +--connection node_1b +SET SESSION wsrep_sync_wait = 0; +SET SESSION wsrep_osu_method = RSU; +--send ALTER TABLE t1 ADD COLUMN f3 INTEGER; + +--sleep 5 +--connection node_1 +--echo value during RSU: +SHOW STATUS LIKE 'wsrep_desync_count'; +SHOW VARIABLES LIKE 'wsrep_desync'; +--replace_column 1 # 3 # 6 # +SHOW PROCESSLIST; +UNLOCK TABLES; + +--connection node_1a +--reap +--connection node_1b +--reap + +--connection node_1 +--echo value after RSU: +SHOW STATUS LIKE 'wsrep_desync_count'; +SHOW VARIABLES LIKE 'wsrep_desync'; +SET GLOBAL wsrep_desync=0; + +DROP TABLE t1; diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc index e392aef32eb45..17e3577a6eba6 100644 --- a/sql/wsrep_mysqld.cc +++ b/sql/wsrep_mysqld.cc @@ -1308,19 +1308,15 @@ 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() ); - if (!wsrep_desync) + ret = wsrep->desync(wsrep); + if (ret != WSREP_OK) { - 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); - } + 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); @@ -1335,15 +1331,13 @@ static int wsrep_RSU_begin(THD *thd, char *db_, char *table_) wsrep_replaying--; mysql_mutex_unlock(&LOCK_wsrep_replaying); - if (!wsrep_desync) + ret = wsrep->resync(wsrep); + if (ret != WSREP_OK) { - 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()); - } + 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); } @@ -1379,18 +1373,15 @@ static void wsrep_RSU_end(THD *thd) (thd->db ? thd->db : "(null)"), thd->query()); } - if (!wsrep_desync) + + ret = wsrep->resync(wsrep); + if (ret != WSREP_OK) { - 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; - } + 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 4582a4bccf406776702a3f866a8f21aa4daaaff9 Mon Sep 17 00:00:00 2001 From: Nirbhay Choubey Date: Fri, 12 Aug 2016 14:03:24 -0400 Subject: [PATCH 34/68] Fix galera_ist_recv_bind.test. --- mysql-test/suite/galera/t/galera_ist_recv_bind.test | 1 + 1 file changed, 1 insertion(+) diff --git a/mysql-test/suite/galera/t/galera_ist_recv_bind.test b/mysql-test/suite/galera/t/galera_ist_recv_bind.test index c04238d6ccadd..cb7329073ad36 100644 --- a/mysql-test/suite/galera/t/galera_ist_recv_bind.test +++ b/mysql-test/suite/galera/t/galera_ist_recv_bind.test @@ -4,6 +4,7 @@ # --source include/galera_cluster.inc +--source include/have_innodb.inc --connection node_1 SELECT @@wsrep_provider_options LIKE '%ist.recv_bind = 127.0.0.1%'; From d45b58263ddf815aa04d4dbc9255ed1081e33bdb Mon Sep 17 00:00:00 2001 From: Alexey Yurchenko Date: Sat, 2 Apr 2016 22:37:22 -0300 Subject: [PATCH 35/68] MW-259 - moved wsrep desync/resync calls from wsrep_desync_update() to wsrep_desync_check() method which does not hold the lock and is arguably a more fitting place to change provider state - before changing the actual variable value. --- mysql-test/suite/galera/r/MW-259.result | 12 +++++++ mysql-test/suite/galera/t/MW-259.test | 42 +++++++++++++++++++++++++ sql/wsrep_var.cc | 13 ++++---- 3 files changed, 61 insertions(+), 6 deletions(-) create mode 100644 mysql-test/suite/galera/r/MW-259.result create mode 100644 mysql-test/suite/galera/t/MW-259.test diff --git a/mysql-test/suite/galera/r/MW-259.result b/mysql-test/suite/galera/r/MW-259.result new file mode 100644 index 0000000000000..df76e959de551 --- /dev/null +++ b/mysql-test/suite/galera/r/MW-259.result @@ -0,0 +1,12 @@ +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;; +SET DEBUG_SYNC= 'now SIGNAL continue'; +DROP TABLE t1; +SET GLOBAL wsrep_desync=0; +SET DEBUG_SYNC= 'RESET'; diff --git a/mysql-test/suite/galera/t/MW-259.test b/mysql-test/suite/galera/t/MW-259.test new file mode 100644 index 0000000000000..ff9a30deed39b --- /dev/null +++ b/mysql-test/suite/galera/t/MW-259.test @@ -0,0 +1,42 @@ +--source include/galera_cluster.inc +--source include/have_innodb.inc +--source include/have_debug_sync.inc + +--connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1 +--connect node_1b, 127.0.0.1, root, , test, $NODE_MYPORT_1 + +--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 + +# wsrep_desync=1 will block +--send SET GLOBAL wsrep_desync=1; + +--connection node_1b +--sleep 2 +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE = 'exit open_tables()' and INFO = 'SET GLOBAL wsrep_desync=1' +--source include/wait_condition.inc + +SET DEBUG_SYNC= 'now SIGNAL continue'; +DROP TABLE t1; +SET GLOBAL wsrep_desync=0; + +--connection node_1 +--reap + +--connection node_1a +--reap + +# Cleanup +SET DEBUG_SYNC= 'RESET'; + diff --git a/sql/wsrep_var.cc b/sql/wsrep_var.cc index 44d17e3e78ade..2f13ffd6747bd 100644 --- a/sql/wsrep_var.cc +++ b/sql/wsrep_var.cc @@ -529,14 +529,10 @@ bool wsrep_desync_check (sys_var *self, THD* thd, set_var* var) ER_WRONG_VALUE_FOR_VAR, "'wsrep_desync' is already OFF."); } + return false; } - return 0; -} - -bool wsrep_desync_update (sys_var *self, THD* thd, enum_var_type type) -{ wsrep_status_t ret(WSREP_WARNING); - if (wsrep_desync) { + if (new_wsrep_desync) { ret = wsrep->desync (wsrep); if (ret != WSREP_OK) { WSREP_WARN ("SET desync failed %d for schema: %s, query: %s", ret, @@ -558,6 +554,11 @@ bool wsrep_desync_update (sys_var *self, THD* thd, enum_var_type type) return false; } +bool wsrep_desync_update (sys_var *self, THD* thd, enum_var_type type) +{ + return false; +} + bool wsrep_max_ws_size_update (sys_var *self, THD *thd, enum_var_type) { char max_ws_size_opt[128]; From dda114461ecb3f8ea3448a61b3dad7d059dbdaec Mon Sep 17 00:00:00 2001 From: Philip Stoev Date: Mon, 4 Apr 2016 05:14:13 -0700 Subject: [PATCH 36/68] Galera MTR Tests: Fixed tests to account for GAL-391 , GAL-374 --- .../galera/r/galera_rsu_wsrep_desync.result | 7 +++-- .../galera/t/galera_rsu_wsrep_desync.test | 26 ++++++++++++------- 2 files changed, 20 insertions(+), 13 deletions(-) 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 62e327ffdee1f..089803893929c 100644 --- a/mysql-test/suite/galera/r/galera_rsu_wsrep_desync.result +++ b/mysql-test/suite/galera/r/galera_rsu_wsrep_desync.result @@ -22,12 +22,11 @@ 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'; +SET DEBUG_SYNC = 'alter_table_before_create_table_no_lock 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 GLOBAL wsrep_desync=1;; SET DEBUG_SYNC= 'now SIGNAL continue'; +SET GLOBAL wsrep_desync=0; SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( 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 36ec8563cbe18..dc7ff11a9f55a 100644 --- a/mysql-test/suite/galera/t/galera_rsu_wsrep_desync.test +++ b/mysql-test/suite/galera/t/galera_rsu_wsrep_desync.test @@ -17,9 +17,11 @@ 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 +--connect node_1b, 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 @@ -44,24 +46,32 @@ 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'; +SET DEBUG_SYNC = 'alter_table_before_create_table_no_lock 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' +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE = 'debug sync point: alter_table_before_create_table_no_lock' --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; +# wsrep_desync=1 will block +--send SET GLOBAL wsrep_desync=1; + + +--connection node_1b +--sleep 2 +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE = 'exit open_tables()' and INFO = 'SET GLOBAL wsrep_desync=1' +--source include/wait_condition.inc SET DEBUG_SYNC= 'now SIGNAL continue'; --connection node_1 --reap +--connection node_1a +--reap +SET GLOBAL wsrep_desync=0; + SHOW CREATE TABLE t1; # Restore old state @@ -74,5 +84,3 @@ CALL mtr.add_suppression("desync failed"); --connection node_2 CALL mtr.add_suppression("Protocol violation"); - - From fce9217c21527938d279183fb05891505e79b25b Mon Sep 17 00:00:00 2001 From: Philip Stoev Date: Mon, 4 Apr 2016 05:32:50 -0700 Subject: [PATCH 37/68] Galera MTR Test: Fix for MW-258.test - do not use SHOW PROCESSLIST --- mysql-test/suite/galera/r/MW-258.result | 8 -------- mysql-test/suite/galera/t/MW-258.test | 2 -- 2 files changed, 10 deletions(-) diff --git a/mysql-test/suite/galera/r/MW-258.result b/mysql-test/suite/galera/r/MW-258.result index 28b1e4049abf3..1b4d4ae0de89b 100644 --- a/mysql-test/suite/galera/r/MW-258.result +++ b/mysql-test/suite/galera/r/MW-258.result @@ -20,14 +20,6 @@ wsrep_desync_count 2 SHOW VARIABLES LIKE 'wsrep_desync'; Variable_name Value wsrep_desync OFF -SHOW PROCESSLIST; -Id User Host db Command Time State Info Progress -# system user # NULL Sleep # NULL NULL 0.000 -# system user # NULL Sleep # wsrep aborter idle NULL 0.000 -# root # test Sleep # NULL 0.000 -# root # test Query # init SHOW PROCESSLIST 0.000 -# root # test Query # Waiting for table metadata lock ALTER TABLE t1 ADD COLUMN f2 INTEGER 0.000 -# root # test Query # checking permissions ALTER TABLE t1 ADD COLUMN f3 INTEGER 0.000 UNLOCK TABLES; value after RSU: SHOW STATUS LIKE 'wsrep_desync_count'; diff --git a/mysql-test/suite/galera/t/MW-258.test b/mysql-test/suite/galera/t/MW-258.test index 7745ef5ea9f73..f5519f8a08148 100644 --- a/mysql-test/suite/galera/t/MW-258.test +++ b/mysql-test/suite/galera/t/MW-258.test @@ -25,8 +25,6 @@ SET SESSION wsrep_osu_method = RSU; --echo value during RSU: SHOW STATUS LIKE 'wsrep_desync_count'; SHOW VARIABLES LIKE 'wsrep_desync'; ---replace_column 1 # 3 # 6 # -SHOW PROCESSLIST; UNLOCK TABLES; --connection node_1a From 9b42f09902f63249cc14abb173513cf9474e3408 Mon Sep 17 00:00:00 2001 From: Philip Stoev Date: Mon, 4 Apr 2016 07:09:32 -0700 Subject: [PATCH 38/68] Galera MTR Tests: Add test for GAL-382, codership/galera#382 - InnoDB: Failing assertion: xid_seqno > trx_sys_cur_xid_seqno in trx0sys.cc line 356 --- mysql-test/suite/galera/r/GAL-382.result | 6 ++++++ mysql-test/suite/galera/t/GAL-382.test | 15 +++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 mysql-test/suite/galera/r/GAL-382.result create mode 100644 mysql-test/suite/galera/t/GAL-382.test diff --git a/mysql-test/suite/galera/r/GAL-382.result b/mysql-test/suite/galera/r/GAL-382.result new file mode 100644 index 0000000000000..0c7365f3005bb --- /dev/null +++ b/mysql-test/suite/galera/r/GAL-382.result @@ -0,0 +1,6 @@ +create table t1 (i int, j int, k int, primary key pk(i)) engine=innodb; +insert into t1 values (1, 1, 1), (2, 2, 2), (3, 3, 3); +create table t2 (i int, j int, k int, primary key pk(i, j, k), index idx(i, k, j)) engine=innodb; +replace into t2 (i, j, k) select /*!99997 */ i, k, j from t1; +DROP TABLE t1; +DROP TABLE t2; diff --git a/mysql-test/suite/galera/t/GAL-382.test b/mysql-test/suite/galera/t/GAL-382.test new file mode 100644 index 0000000000000..0cc90e2611888 --- /dev/null +++ b/mysql-test/suite/galera/t/GAL-382.test @@ -0,0 +1,15 @@ +# +# GAL-382 InnoDB: Failing assertion: xid_seqno > trx_sys_cur_xid_seqno in trx0sys.cc line 356 +# + +--source include/galera_cluster.inc + +--connection node_1 + +create table t1 (i int, j int, k int, primary key pk(i)) engine=innodb; +insert into t1 values (1, 1, 1), (2, 2, 2), (3, 3, 3); +create table t2 (i int, j int, k int, primary key pk(i, j, k), index idx(i, k, j)) engine=innodb; +replace into t2 (i, j, k) select /*!99997 */ i, k, j from t1; + +DROP TABLE t1; +DROP TABLE t2; From 3f22e743c560676e6948bb1c7f9074134c2552e5 Mon Sep 17 00:00:00 2001 From: Nirbhay Choubey Date: Mon, 15 Aug 2016 11:14:57 -0400 Subject: [PATCH 39/68] Fix galera/GAL-382 test post-merge. --- mysql-test/suite/galera/t/GAL-382.test | 1 + 1 file changed, 1 insertion(+) diff --git a/mysql-test/suite/galera/t/GAL-382.test b/mysql-test/suite/galera/t/GAL-382.test index 0cc90e2611888..05cc7346055db 100644 --- a/mysql-test/suite/galera/t/GAL-382.test +++ b/mysql-test/suite/galera/t/GAL-382.test @@ -3,6 +3,7 @@ # --source include/galera_cluster.inc +--source include/have_innodb.inc --connection node_1 From f49500a80337cad9aec1f5c9cf8caf7ace927dc1 Mon Sep 17 00:00:00 2001 From: Teemu Ollakka Date: Tue, 5 Apr 2016 14:08:39 +0300 Subject: [PATCH 40/68] MW-44 Disable general log for applier threads --- sql/wsrep_thd.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sql/wsrep_thd.cc b/sql/wsrep_thd.cc index 09ffdbd54f59c..5e530e84d43bd 100644 --- a/sql/wsrep_thd.cc +++ b/sql/wsrep_thd.cc @@ -139,6 +139,9 @@ static void wsrep_prepare_bf_thd(THD *thd, struct wsrep_thd_shadow* shadow) shadow->wsrep_exec_mode = thd->wsrep_exec_mode; shadow->vio = thd->net.vio; + // Disable general logging on applier threads + thd->variables.option_bits |= OPTION_LOG_OFF; + // Enable binlogging if opt_log_slave_updates is set if (opt_log_slave_updates) thd->variables.option_bits|= OPTION_BIN_LOG; else From 675bcf3b6d654861d7f9ca0279a3f56847587696 Mon Sep 17 00:00:00 2001 From: Philip Stoev Date: Thu, 14 Apr 2016 01:03:37 -0700 Subject: [PATCH 41/68] Galera MTR Tests: A test for MW-44 - Disable general log for applier threads --- mysql-test/suite/galera/r/MW-44.result | 14 +++++++++++++ mysql-test/suite/galera/t/MW-44-master.opt | 1 + mysql-test/suite/galera/t/MW-44.test | 24 ++++++++++++++++++++++ 3 files changed, 39 insertions(+) create mode 100644 mysql-test/suite/galera/r/MW-44.result create mode 100644 mysql-test/suite/galera/t/MW-44-master.opt create mode 100644 mysql-test/suite/galera/t/MW-44.test diff --git a/mysql-test/suite/galera/r/MW-44.result b/mysql-test/suite/galera/r/MW-44.result new file mode 100644 index 0000000000000..28a6f1ac8dd23 --- /dev/null +++ b/mysql-test/suite/galera/r/MW-44.result @@ -0,0 +1,14 @@ +TRUNCATE TABLE mysql.general_log; +TRUNCATE TABLE mysql.general_log; +SET SESSION wsrep_osu_method=TOI; +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +SET SESSION wsrep_osu_method=RSU; +ALTER TABLE t1 ADD COLUMN f2 INTEGER; +SET SESSION wsrep_osu_method=TOI; +SELECT COUNT(*) = 2 FROM mysql.general_log WHERE argument LIKE 'CREATE%' OR argument LIKE 'ALTER%'; +COUNT(*) = 2 +1 +SELECT COUNT(*) = 0 FROM mysql.general_log WHERE argument NOT LIKE 'SELECT%'; +COUNT(*) = 0 +1 +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/MW-44-master.opt b/mysql-test/suite/galera/t/MW-44-master.opt new file mode 100644 index 0000000000000..a15aa0a99d9fb --- /dev/null +++ b/mysql-test/suite/galera/t/MW-44-master.opt @@ -0,0 +1 @@ +--log-output=TABLE diff --git a/mysql-test/suite/galera/t/MW-44.test b/mysql-test/suite/galera/t/MW-44.test new file mode 100644 index 0000000000000..843d33ae52565 --- /dev/null +++ b/mysql-test/suite/galera/t/MW-44.test @@ -0,0 +1,24 @@ +# +# MW-44: DDL is logged in the general_log on the slave +# + +--source include/galera_cluster.inc + +--connection node_1 +TRUNCATE TABLE mysql.general_log; + +--connection node_2 +TRUNCATE TABLE mysql.general_log; + +--connection node_1 +SET SESSION wsrep_osu_method=TOI; +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +SET SESSION wsrep_osu_method=RSU; +ALTER TABLE t1 ADD COLUMN f2 INTEGER; +SET SESSION wsrep_osu_method=TOI; + +SELECT COUNT(*) = 2 FROM mysql.general_log WHERE argument LIKE 'CREATE%' OR argument LIKE 'ALTER%'; + +--connection node_2 +SELECT COUNT(*) = 0 FROM mysql.general_log WHERE argument NOT LIKE 'SELECT%'; +DROP TABLE t1; From 182787f39e8f73781caeb6eaf536697fb747c9a0 Mon Sep 17 00:00:00 2001 From: Philip Stoev Date: Thu, 14 Apr 2016 01:25:54 -0700 Subject: [PATCH 42/68] Galera MTR Tests: Adjust galera_log_output_csv.test to account for the fix for MW-44 --- mysql-test/suite/galera/r/galera_log_output_csv.result | 3 --- mysql-test/suite/galera/t/galera_log_output_csv.test | 3 --- 2 files changed, 6 deletions(-) diff --git a/mysql-test/suite/galera/r/galera_log_output_csv.result b/mysql-test/suite/galera/r/galera_log_output_csv.result index 07a78469578a5..cdb5ee49f3e73 100644 --- a/mysql-test/suite/galera/r/galera_log_output_csv.result +++ b/mysql-test/suite/galera/r/galera_log_output_csv.result @@ -9,9 +9,6 @@ SELECT 1 = 1 FROM t1; SELECT COUNT(*) = 1 FROM mysql.slow_log WHERE sql_text = 'SELECT 1 = 1 FROM t1'; COUNT(*) = 1 1 -SELECT COUNT(*) > 0 FROM mysql.general_log WHERE argument = 'CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB'; -COUNT(*) > 0 -1 SELECT 2 = 2 FROM t1; 2 = 2 1 diff --git a/mysql-test/suite/galera/t/galera_log_output_csv.test b/mysql-test/suite/galera/t/galera_log_output_csv.test index 00009396f6a4a..94ae3dd61685c 100644 --- a/mysql-test/suite/galera/t/galera_log_output_csv.test +++ b/mysql-test/suite/galera/t/galera_log_output_csv.test @@ -17,9 +17,6 @@ SELECT COUNT(*) = 1 FROM mysql.slow_log WHERE sql_text = 'SELECT 1 = 1 FROM t1'; --connection node_2 -# CREATE TABLE from master is also present in the slave query log, but is logged twice, mysql-wsrep#44 -SELECT COUNT(*) > 0 FROM mysql.general_log WHERE argument = 'CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB'; - SELECT 2 = 2 FROM t1; SELECT COUNT(*) = 1 FROM mysql.slow_log WHERE sql_text = 'SELECT 2 = 2 FROM t1'; From 81174c9ab196e42b2f400d564eb5940fc888f38c Mon Sep 17 00:00:00 2001 From: Nirbhay Choubey Date: Mon, 15 Aug 2016 11:29:48 -0400 Subject: [PATCH 43/68] Fix galera/MW-44 test post-merge. --- mysql-test/suite/galera/t/MW-44.test | 1 + 1 file changed, 1 insertion(+) diff --git a/mysql-test/suite/galera/t/MW-44.test b/mysql-test/suite/galera/t/MW-44.test index 843d33ae52565..55a3fd57f8023 100644 --- a/mysql-test/suite/galera/t/MW-44.test +++ b/mysql-test/suite/galera/t/MW-44.test @@ -3,6 +3,7 @@ # --source include/galera_cluster.inc +--source include/have_innodb.inc --connection node_1 TRUNCATE TABLE mysql.general_log; From db837fde87093f7b985568bd26ce57627b74e752 Mon Sep 17 00:00:00 2001 From: Philip Stoev Date: Sun, 1 May 2016 23:29:55 -0700 Subject: [PATCH 44/68] Galera MTR Tests: Adjust tests for xtrabackup 2.4.2 --- .../suite/galera_3nodes/t/galera_innobackupex_backup.test | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mysql-test/suite/galera_3nodes/t/galera_innobackupex_backup.test b/mysql-test/suite/galera_3nodes/t/galera_innobackupex_backup.test index af4a5fbf9d692..a6660bd08d164 100644 --- a/mysql-test/suite/galera_3nodes/t/galera_innobackupex_backup.test +++ b/mysql-test/suite/galera_3nodes/t/galera_innobackupex_backup.test @@ -13,8 +13,8 @@ INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); SELECT COUNT(*) = 10 FROM t1; --exec rm -rf $MYSQL_TMP_DIR/innobackupex_backup ---exec innobackupex $MYSQL_TMP_DIR/innobackupex_backup --galera-info --defaults-file=$MYSQLTEST_VARDIR/my.cnf --defaults-group=mysqld.2 --port=$NODE_MYPORT_2 --host=127.0.0.1 --no-timestamp > $MYSQL_TMP_DIR/innobackupex-backup.log ---exec innobackupex $MYSQL_TMP_DIR/innobackupex_backup --apply-log --galera-info --defaults-file=$MYSQLTEST_VARDIR/my.cnf --defaults-group=mysqld.2 --port=$NODE_MYPORT_2 --host=127.0.0.1 --no-timestamp > $MYSQL_TMP_DIR/innobackupex-apply.log +--exec innobackupex --defaults-file=$MYSQLTEST_VARDIR/my.cnf --defaults-group=mysqld.2 $MYSQL_TMP_DIR/innobackupex_backup --galera-info --port=$NODE_MYPORT_2 --host=127.0.0.1 --no-timestamp > $MYSQL_TMP_DIR/innobackupex-backup.log +--exec innobackupex --defaults-file=$MYSQLTEST_VARDIR/my.cnf --defaults-group=mysqld.2 $MYSQL_TMP_DIR/innobackupex_backup --apply-log --galera-info --port=$NODE_MYPORT_2 --host=127.0.0.1 --no-timestamp > $MYSQL_TMP_DIR/innobackupex-apply.log --source include/kill_galera.inc --sleep 1 @@ -23,7 +23,7 @@ SELECT COUNT(*) = 10 FROM t1; INSERT INTO t1 VALUES (11),(12),(13),(14),(15),(16),(17),(18),(19),(20); --exec rm -rf $MYSQLTEST_VARDIR/mysqld.2/data/* ---exec innobackupex --copy-back $MYSQL_TMP_DIR/innobackupex_backup --defaults-file=$MYSQLTEST_VARDIR/my.cnf --defaults-group=mysqld.2 --port=$NODE_MYPORT_2 --host=127.0.0.1 > $MYSQL_TMP_DIR/innobackupex-restore.log +--exec innobackupex --defaults-file=$MYSQLTEST_VARDIR/my.cnf --defaults-group=mysqld.2 --copy-back $MYSQL_TMP_DIR/innobackupex_backup --port=$NODE_MYPORT_2 --host=127.0.0.1 > $MYSQL_TMP_DIR/innobackupex-restore.log # # Convert the xtrabackup_galera_info into a grastate.dat file From 137af55ca1064a605fed608572b34135823de6ac Mon Sep 17 00:00:00 2001 From: Philip Stoev Date: Tue, 17 May 2016 22:23:51 -0700 Subject: [PATCH 45/68] Galera MTR Tests: stability fixes --- mysql-test/suite/galera/r/galera_repl_max_ws_size.result | 4 ++++ mysql-test/suite/galera/r/galera_ssl_upgrade.result | 9 --------- mysql-test/suite/galera/t/galera_repl_max_ws_size.test | 4 ++++ mysql-test/suite/galera/t/galera_ssl_upgrade.test | 9 ++++++--- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/mysql-test/suite/galera/r/galera_repl_max_ws_size.result b/mysql-test/suite/galera/r/galera_repl_max_ws_size.result index 6cfd10bdedd15..70c09bda3f90b 100644 --- a/mysql-test/suite/galera/r/galera_repl_max_ws_size.result +++ b/mysql-test/suite/galera/r/galera_repl_max_ws_size.result @@ -6,3 +6,7 @@ SELECT COUNT(*) = 0 FROM t1; COUNT(*) = 0 1 DROP TABLE t1; +CALL mtr.add_suppression("Maximum writeset size exceeded by"); +CALL mtr.add_suppression("transaction size limit"); +CALL mtr.add_suppression("transaction size exceeded"); +CALL mtr.add_suppression("rbr write fail"); diff --git a/mysql-test/suite/galera/r/galera_ssl_upgrade.result b/mysql-test/suite/galera/r/galera_ssl_upgrade.result index c0f2e84dc6f75..b24671d120df1 100644 --- a/mysql-test/suite/galera/r/galera_ssl_upgrade.result +++ b/mysql-test/suite/galera/r/galera_ssl_upgrade.result @@ -4,21 +4,12 @@ VARIABLE_VALUE = 'Synced' SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; VARIABLE_VALUE = 2 1 -SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment'; -VARIABLE_VALUE = 'Synced' -1 SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; VARIABLE_VALUE = 2 1 -SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment'; -VARIABLE_VALUE = 'Synced' -1 SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; VARIABLE_VALUE = 2 1 -SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment'; -VARIABLE_VALUE = 'Synced' -1 SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; VARIABLE_VALUE = 2 1 diff --git a/mysql-test/suite/galera/t/galera_repl_max_ws_size.test b/mysql-test/suite/galera/t/galera_repl_max_ws_size.test index 37a2f7d4ce3c0..60b866ae01893 100644 --- a/mysql-test/suite/galera/t/galera_repl_max_ws_size.test +++ b/mysql-test/suite/galera/t/galera_repl_max_ws_size.test @@ -23,3 +23,7 @@ SELECT COUNT(*) = 0 FROM t1; DROP TABLE t1; +CALL mtr.add_suppression("Maximum writeset size exceeded by"); +CALL mtr.add_suppression("transaction size limit"); +CALL mtr.add_suppression("transaction size exceeded"); +CALL mtr.add_suppression("rbr write fail"); diff --git a/mysql-test/suite/galera/t/galera_ssl_upgrade.test b/mysql-test/suite/galera/t/galera_ssl_upgrade.test index 07aac0fbe92d0..a424942da30ab 100644 --- a/mysql-test/suite/galera/t/galera_ssl_upgrade.test +++ b/mysql-test/suite/galera/t/galera_ssl_upgrade.test @@ -18,7 +18,8 @@ SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_N --source include/start_mysqld.inc --source include/wait_until_connected_again.inc -SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment'; +--let $wait_condition = SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment'; +--source include/wait_condition.inc SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; # 3. Restart node #2 with the new socket.ssl_ca , socket.ssl_cert and socket.ssl_key @@ -29,7 +30,8 @@ SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_N --source include/start_mysqld.inc --source include/wait_until_connected_again.inc -SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment'; +--let $wait_condition = SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment'; +--source include/wait_condition.inc SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; # 4. Restart node #1 with the new socket.ssl_ca , socket.ssl_cert and socket.ssl_key @@ -40,7 +42,8 @@ SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_N --source include/start_mysqld.inc --source include/wait_until_connected_again.inc -SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment'; +--let $wait_condition = SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment'; +--source include/wait_condition.inc SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; # Upgrade complete. Both nodes now use the new key and certificate From 92162e6d8761d8586299cfd88682a7704df2d7fa Mon Sep 17 00:00:00 2001 From: Daniele Sciascia Date: Wed, 18 May 2016 11:07:58 +0200 Subject: [PATCH 46/68] MW-175 Fix definitively lost memory in wsrep_get_params --- mysql-test/valgrind.supp | 110 --------------------------------------- sql/wsrep_var.cc | 1 + wsrep/wsrep_dummy.c | 2 +- 3 files changed, 2 insertions(+), 111 deletions(-) diff --git a/mysql-test/valgrind.supp b/mysql-test/valgrind.supp index fc3a2d08213af..1cc5d1779720c 100644 --- a/mysql-test/valgrind.supp +++ b/mysql-test/valgrind.supp @@ -1228,25 +1228,6 @@ fun:dlopen@@GLIBC_2.2.5 } -{ - GitHub codership/mysql-wsrep#176 - Memcheck:Leak - fun:_Z16wsrep_get_paramsRKN6galera10ReplicatorE - fun:galera_parameters_get - fun:_ZL24refresh_provider_optionsv - fun:_Z29wsrep_provider_options_updateP7sys_varP3THD13enum_var_type - fun:_ZN7sys_var6updateEP3THDP7set_var - fun:_ZN7set_var6updateEP3THD - fun:_Z17sql_set_variablesP3THDP4ListI12set_var_baseE - fun:_Z21mysql_execute_commandP3THD - fun:_Z11mysql_parseP3THDPcjP12Parser_state - fun:_ZL17wsrep_mysql_parseP3THDPcjP12Parser_state - fun:_Z16dispatch_command19enum_server_commandP3THDPcj - fun:_Z10do_commandP3THD - fun:_Z24do_handle_one_connectionP3THD - fun:handle_one_connection -} - { GitHub codership/galera#330 Memcheck:Leak @@ -1340,31 +1321,6 @@ g codership/mysql-wsrep/issues#176 fun:_Z16wsrep_set_paramsRN6galera10ReplicatorEPKc } -{ - codership/mysql-wsrep/issues#176 - Memcheck:Leak - fun:_Z16wsrep_get_paramsRKN6galera10ReplicatorE -} - -{ - codership/mysql-wsrep/issues#176 - Memcheck:Leak - fun:_Z16wsrep_get_paramsRKN6galera10ReplicatorE - fun:galera_parameters_get - fun:_ZL24refresh_provider_optionsv - fun:_Z21wsrep_provider_updateP7sys_varP3THD13enum_var_type - fun:_ZN7sys_var6updateEP3THDP7set_var - fun:_ZN7set_var6updateEP3THD - fun:_Z17sql_set_variablesP3THDP4ListI12set_var_baseE - fun:_Z21mysql_execute_commandP3THD - fun:_Z11mysql_parseP3THDPcjP12Parser_state - fun:_ZL17wsrep_mysql_parseP3THDPcjP12Parser_state - fun:_Z16dispatch_command19enum_server_commandP3THDPcj - fun:_Z10do_commandP3THD - fun:_Z24do_handle_one_connectionP3THD - fun:handle_one_connection -} - { codership/mysql-wsrep/issues#176 Memcheck:Leak @@ -1475,72 +1431,6 @@ g codership/mysql-wsrep/issues#176 fun:_Z24do_handle_one_connectionP3THD } -{ - codership/mysql-wsrep/issues#176 - Memcheck:Leak - match-leak-kinds: possible - fun:malloc - fun:strdup - fun:_Z16wsrep_get_paramsRKN6galera10ReplicatorE - fun:galera_parameters_get - fun:_ZL24refresh_provider_optionsv - fun:_Z29wsrep_provider_options_updateP7sys_varP3THD13enum_var_type - fun:_ZN7sys_var6updateEP3THDP7set_var - fun:_ZN7set_var6updateEP3THD - fun:_Z17sql_set_variablesP3THDP4ListI12set_var_baseE - fun:_Z21mysql_execute_commandP3THD - fun:_Z11mysql_parseP3THDPcjP12Parser_state - fun:_ZL17wsrep_mysql_parseP3THDPcjP12Parser_state - fun:_Z16dispatch_command19enum_server_commandP3THDPcj - fun:_Z10do_commandP3THD - fun:_Z24do_handle_one_connectionP3THD - fun:handle_one_connection -} - -{ - codership/mysql-wsrep/issues#176 - Memcheck:Leak - match-leak-kinds: definite - fun:malloc - fun:strdup - fun:_Z16wsrep_get_paramsRKN6galera10ReplicatorE - fun:galera_parameters_get - fun:_ZL24refresh_provider_optionsv - fun:_Z29wsrep_provider_options_updateP7sys_varP3THD13enum_var_type - fun:_ZN7sys_var6updateEP3THDP7set_var - fun:_ZN7set_var6updateEP3THD - fun:_Z17sql_set_variablesP3THDP4ListI12set_var_baseE - fun:_Z21mysql_execute_commandP3THD - fun:_Z11mysql_parseP3THDPcjP12Parser_state - fun:_ZL17wsrep_mysql_parseP3THDPcjP12Parser_state - fun:_Z16dispatch_command19enum_server_commandP3THDPcj - fun:_Z10do_commandP3THD - fun:_Z24do_handle_one_connectionP3THD - fun:handle_one_connection -} - -{ - codership/mysql-wsrep/issues#176 - Memcheck:Leak - match-leak-kinds: definite - fun:malloc - fun:strdup - fun:_Z16wsrep_get_paramsRKN6galera10ReplicatorE - fun:galera_parameters_get - fun:_ZL24refresh_provider_optionsv - fun:_Z21wsrep_provider_updateP7sys_varP3THD13enum_var_type - fun:_ZN7sys_var6updateEP3THDP7set_var - fun:_ZN7set_var6updateEP3THD - fun:_Z17sql_set_variablesP3THDP4ListI12set_var_baseE - fun:_Z21mysql_execute_commandP3THD - fun:_Z11mysql_parseP3THDPcjP12Parser_state - fun:_ZL17wsrep_mysql_parseP3THDPcjP12Parser_state - fun:_Z16dispatch_command19enum_server_commandP3THDPcj - fun:_Z10do_commandP3THD - fun:_Z24do_handle_one_connectionP3THD - fun:handle_one_connection -} - { codership/galera#331 Memcheck:Leak diff --git a/sql/wsrep_var.cc b/sql/wsrep_var.cc index 2f13ffd6747bd..8a507711daf0f 100644 --- a/sql/wsrep_var.cc +++ b/sql/wsrep_var.cc @@ -216,6 +216,7 @@ static bool refresh_provider_options() get_provider_option_value(wsrep_provider_options, (char*)"repl.max_ws_size", &wsrep_max_ws_size); + free(opts); } else { diff --git a/wsrep/wsrep_dummy.c b/wsrep/wsrep_dummy.c index bab5329dc028d..5f1ea63cc4037 100644 --- a/wsrep/wsrep_dummy.c +++ b/wsrep/wsrep_dummy.c @@ -86,7 +86,7 @@ static wsrep_status_t dummy_options_set( static char* dummy_options_get (wsrep_t* w) { WSREP_DBUG_ENTER(w); - return WSREP_DUMMY(w)->options; + return strdup(WSREP_DUMMY(w)->options); } static wsrep_status_t dummy_connect( From 1cb01fe7d2fd5651abf9df743c38fcae4541bd2a Mon Sep 17 00:00:00 2001 From: Philip Stoev Date: Thu, 2 Jun 2016 23:39:12 -0700 Subject: [PATCH 47/68] Galera MTR Tests: Fortify galera_restart_nochanges.test against sporadic failures due to node not being ready immediately after restart --- mysql-test/suite/galera/t/galera_restart_nochanges.test | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mysql-test/suite/galera/t/galera_restart_nochanges.test b/mysql-test/suite/galera/t/galera_restart_nochanges.test index a61332cefd684..ba12c4c409c1e 100644 --- a/mysql-test/suite/galera/t/galera_restart_nochanges.test +++ b/mysql-test/suite/galera/t/galera_restart_nochanges.test @@ -18,6 +18,10 @@ INSERT INTO t1 VALUES (1); --connection node_2 --source include/restart_mysqld.inc +--connection node_1 +--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +--source include/wait_condition.inc + --let $galera_connection_name = node_2a --let $galera_server_number = 2 --source include/galera_connect.inc From 5609020c7101f2ffb9ec68dfc68896b242da3de1 Mon Sep 17 00:00:00 2001 From: Philip Stoev Date: Thu, 2 Jun 2016 23:56:16 -0700 Subject: [PATCH 48/68] Galera MTR Tests: fortify galera_parallel_simple.test against sporadic failures --- .../suite/galera/r/galera_parallel_simple.result | 7 ++++--- .../suite/galera/t/galera_parallel_simple.test | 13 ++++++++++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/mysql-test/suite/galera/r/galera_parallel_simple.result b/mysql-test/suite/galera/r/galera_parallel_simple.result index 294a94baed314..6d023c38a572b 100644 --- a/mysql-test/suite/galera/r/galera_parallel_simple.result +++ b/mysql-test/suite/galera/r/galera_parallel_simple.result @@ -1,6 +1,7 @@ CREATE TABLE t1 (id INT) ENGINE=InnoDB; CREATE TABLE t2 (id INT) ENGINE=InnoDB; SET GLOBAL wsrep_slave_threads = 2; +LOCK TABLE t1 WRITE; INSERT INTO t1 VALUES (1); INSERT INTO t2 VALUES (1); INSERT INTO t1 VALUES (1); @@ -13,15 +14,15 @@ INSERT INTO t1 VALUES (1); INSERT INTO t2 VALUES (1); INSERT INTO t1 VALUES (1); INSERT INTO t2 VALUES (1); +SET SESSION wsrep_sync_wait = 0; +UNLOCK TABLES; +SET SESSION wsrep_sync_wait = 7; SELECT COUNT(*) = 10 FROM t1; COUNT(*) = 10 0 SELECT COUNT(*) = 10 FROM t2; COUNT(*) = 10 0 -SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE LIKE 'committed%'; -COUNT(*) = 2 -1 SET GLOBAL wsrep_slave_threads = 1;; DROP TABLE t1; DROP TABLE t2; diff --git a/mysql-test/suite/galera/t/galera_parallel_simple.test b/mysql-test/suite/galera/t/galera_parallel_simple.test index b1dc14deb5bb9..e078a342c167a 100644 --- a/mysql-test/suite/galera/t/galera_parallel_simple.test +++ b/mysql-test/suite/galera/t/galera_parallel_simple.test @@ -13,6 +13,7 @@ CREATE TABLE t2 (id INT) ENGINE=InnoDB; --connection node_2 SET GLOBAL wsrep_slave_threads = 2; +LOCK TABLE t1 WRITE; --connection node_1 INSERT INTO t1 VALUES (1); @@ -34,10 +35,20 @@ INSERT INTO t1 VALUES (1); INSERT INTO t2 VALUES (1); --connection node_2 +SET SESSION wsrep_sync_wait = 0; + +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE LIKE 'Waiting for table metadata lock%'; +--source include/wait_condition.inc + +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE LIKE 'applied write set%'; +--source include/wait_condition.inc + +UNLOCK TABLES; + +SET SESSION wsrep_sync_wait = 7; SELECT COUNT(*) = 10 FROM t1; SELECT COUNT(*) = 10 FROM t2; -SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE LIKE 'committed%'; --eval SET GLOBAL wsrep_slave_threads = $wsrep_slave_threads_orig; From 0e83726edb4437fb40fcbb043ccf3721ac60fbac Mon Sep 17 00:00:00 2001 From: Philip Stoev Date: Fri, 3 Jun 2016 04:26:17 -0700 Subject: [PATCH 49/68] Galera MTR Tests: force galera_3nodes.galera_pc_bootstrap.test to run on a fresh cluster in order to avoid interaction with galera_3nodes.galera_innobackupex_backup.test --- mysql-test/suite/galera_3nodes/t/galera_pc_bootstrap.cnf | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 mysql-test/suite/galera_3nodes/t/galera_pc_bootstrap.cnf diff --git a/mysql-test/suite/galera_3nodes/t/galera_pc_bootstrap.cnf b/mysql-test/suite/galera_3nodes/t/galera_pc_bootstrap.cnf new file mode 100644 index 0000000000000..d560b67542767 --- /dev/null +++ b/mysql-test/suite/galera_3nodes/t/galera_pc_bootstrap.cnf @@ -0,0 +1,5 @@ +# We need a dedicated .cnf file, even if empty, in order to force this test to run +# alone on a freshly started cluster. Otherwise there are adverse interactions with +# prior tests such as galera_3nodes.galera_innobackupex_backup + +!include ../galera_3nodes.cnf From 5996c7baad2cc936881442ccb26bdde3b04ad6f2 Mon Sep 17 00:00:00 2001 From: sjaakola Date: Tue, 7 Jun 2016 10:46:14 +0300 Subject: [PATCH 50/68] refs: MW-279 - At startup time global wsrep_on is set too late and some wsrep paths may be executed because of this. e.g. replication slave restart could happen before wsrep_on state is defined. - This fix checks both global wsrep_on and wsrep_provider values to determine if wsrep processing should happen - Fix affects all instances where WSREP_ON macro is used --- sql/mysqld.cc | 2 +- sql/wsrep_mysqld.h | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index f28225f5dad6f..1bd2a039ce8dd 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -9205,7 +9205,7 @@ static int mysql_init_variables(void) strmake_buf(mysql_home, tmpenv); #endif #ifdef WITH_WSREP - if (WSREP_ON && wsrep_init_vars()) + if (wsrep_init_vars()) return 1; #endif return 0; diff --git a/sql/wsrep_mysqld.h b/sql/wsrep_mysqld.h index f499443ca2c8d..57382d27e98e8 100644 --- a/sql/wsrep_mysqld.h +++ b/sql/wsrep_mysqld.h @@ -200,8 +200,10 @@ extern void wsrep_prepend_PATH (const char* path); /* Other global variables */ extern wsrep_seqno_t wsrep_locked_seqno; -#define WSREP_ON \ - (global_system_variables.wsrep_on) +#define WSREP_ON \ + ((global_system_variables.wsrep_on) && \ + wsrep_provider && \ + strcmp(wsrep_provider, WSREP_NONE)) #define WSREP(thd) \ (WSREP_ON && wsrep && (thd && thd->variables.wsrep_on)) From a12fa57d35c00897fd883434e6573a65e6edfb41 Mon Sep 17 00:00:00 2001 From: Philip Stoev Date: Mon, 13 Jun 2016 06:17:33 -0700 Subject: [PATCH 51/68] Galera MTR Tests: Run galera_pc_weight on freshly started servers in order to prevent interaction with other tests --- mysql-test/suite/galera_3nodes/t/galera_pc_weight.cnf | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 mysql-test/suite/galera_3nodes/t/galera_pc_weight.cnf diff --git a/mysql-test/suite/galera_3nodes/t/galera_pc_weight.cnf b/mysql-test/suite/galera_3nodes/t/galera_pc_weight.cnf new file mode 100644 index 0000000000000..57026ce69287c --- /dev/null +++ b/mysql-test/suite/galera_3nodes/t/galera_pc_weight.cnf @@ -0,0 +1,5 @@ +# We need a dedicated .cnf file, even if empty, in order to force this test to run +# alone on a freshly started cluster. Otherwise there are adverse interactions with +# following tests such as galera_3nodes.galera_var_dirty_reads2 + +!include ../galera_3nodes.cnf From 88a1592b0a785aff0941540a9543ef2964caaf21 Mon Sep 17 00:00:00 2001 From: Daniele Sciascia Date: Tue, 14 Jun 2016 17:18:21 +0200 Subject: [PATCH 52/68] MW-286 Avoid spurious deadlock errors when wsrep_on is disabled If a conflict happens under wsrep_on, the THD's wsrep_conflict_state is typically set to MUST_ABORT and cleared later, when transaction is aborted. However, when wsrep_on is disabled, no check is performed to see whether wsrep_conflict_state is set. So this potentially creates spurious deadlock errors on the subsequent statement that runs with wsrep_on enabled. To avoid this problem wsrep_thd_set_conflict_state() sets the conflict state only if wsrep_on is enabled. --- mysql-test/suite/galera/r/MW-286.result | 13 ++++++++++ mysql-test/suite/galera/t/MW-286.test | 32 +++++++++++++++++++++++++ sql/sql_class.cc | 2 +- 3 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 mysql-test/suite/galera/r/MW-286.result create mode 100644 mysql-test/suite/galera/t/MW-286.test diff --git a/mysql-test/suite/galera/r/MW-286.result b/mysql-test/suite/galera/r/MW-286.result new file mode 100644 index 0000000000000..adc996c1cbe0f --- /dev/null +++ b/mysql-test/suite/galera/r/MW-286.result @@ -0,0 +1,13 @@ +CREATE TABLE ten (f1 INTEGER); +INSERT INTO ten VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +CREATE TABLE t1 (f1 INTEGER) Engine=InnoDB; +INSERT INTO t1 (f1) SELECT 000000 + (10000 * a1.f1) + (1000 * a2.f1) + (100 * a3.f1) + (10 * a4.f1) + a5.f1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5; +INSERT INTO t1 (f1) SELECT 100000 + (10000 * a1.f1) + (1000 * a2.f1) + (100 * a3.f1) + (10 * a4.f1) + a5.f1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5;; +SET GLOBAL wsrep_desync = TRUE; +SET wsrep_on = FALSE; +ALTER TABLE t1 ADD PRIMARY KEY (f1); +ERROR 70100: Query execution was interrupted +SET wsrep_on = TRUE; +SET GLOBAL wsrep_desync = FALSE; +DROP TABLE t1; +DROP TABLE ten; diff --git a/mysql-test/suite/galera/t/MW-286.test b/mysql-test/suite/galera/t/MW-286.test new file mode 100644 index 0000000000000..1b2e322f078f8 --- /dev/null +++ b/mysql-test/suite/galera/t/MW-286.test @@ -0,0 +1,32 @@ +# +# MW-286 Spurious deadlock error after error with wsrep_desync and wsrep_on +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc +--source include/big_test.inc + +--connection node_1 +CREATE TABLE ten (f1 INTEGER); +INSERT INTO ten VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); + +CREATE TABLE t1 (f1 INTEGER) Engine=InnoDB; + +# Insert some values before the ALTER +INSERT INTO t1 (f1) SELECT 000000 + (10000 * a1.f1) + (1000 * a2.f1) + (100 * a3.f1) + (10 * a4.f1) + a5.f1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5; + +# Insert more values while the ALTER is running +--send INSERT INTO t1 (f1) SELECT 100000 + (10000 * a1.f1) + (1000 * a2.f1) + (100 * a3.f1) + (10 * a4.f1) + a5.f1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5; + +--connection node_2 +SET GLOBAL wsrep_desync = TRUE; +SET wsrep_on = FALSE; + +--error ER_QUERY_INTERRUPTED +ALTER TABLE t1 ADD PRIMARY KEY (f1); + +SET wsrep_on = TRUE; +SET GLOBAL wsrep_desync = FALSE; + +DROP TABLE t1; +DROP TABLE ten; diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 4873586aba55b..37bacc986f7d3 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -846,7 +846,7 @@ extern "C" void wsrep_thd_set_query_state( extern "C" void wsrep_thd_set_conflict_state( THD *thd, enum wsrep_conflict_state state) { - thd->wsrep_conflict_state= state; + if (WSREP(thd)) thd->wsrep_conflict_state= state; } From c9ac48f8451d213cdf7fd4cee091025846306526 Mon Sep 17 00:00:00 2001 From: Krunal Bauskar Date: Thu, 2 Jun 2016 16:44:54 +0530 Subject: [PATCH 53/68] - PXC#592: Tried closing fk-reference-table that was never opened. Function "wsrep_row_upd_check_foreign_constraints" tried to mark fk-reference-table opened without ensuring it table is really opened. --- storage/innobase/row/row0upd.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/storage/innobase/row/row0upd.cc b/storage/innobase/row/row0upd.cc index 44b3faa76c0a5..8d13d436ab8ea 100644 --- a/storage/innobase/row/row0upd.cc +++ b/storage/innobase/row/row0upd.cc @@ -410,7 +410,7 @@ wsrep_row_upd_check_foreign_constraints( dict_table_open_on_name( foreign->referenced_table_name_lookup, FALSE, FALSE, DICT_ERR_IGNORE_NONE); - opened = TRUE; + opened = (foreign->referenced_table) ? TRUE : FALSE; } if (foreign->referenced_table) { @@ -433,7 +433,7 @@ wsrep_row_upd_check_foreign_constraints( ->n_foreign_key_checks_running); if (opened == TRUE) { - dict_table_close(foreign->referenced_table, TRUE, FALSE); + dict_table_close(foreign->referenced_table, FALSE, FALSE); opened = FALSE; } } From dfa9012abbaaec15e99e3fb8cbe3c90cf6dc8e3b Mon Sep 17 00:00:00 2001 From: Daniele Sciascia Date: Mon, 20 Jun 2016 14:35:22 +0200 Subject: [PATCH 54/68] MW-285 MTR test case for broken foreign key constraints --- mysql-test/suite/galera/r/MW-285.result | 19 +++++++++++++++ mysql-test/suite/galera/t/MW-285.test | 31 +++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 mysql-test/suite/galera/r/MW-285.result create mode 100644 mysql-test/suite/galera/t/MW-285.test diff --git a/mysql-test/suite/galera/r/MW-285.result b/mysql-test/suite/galera/r/MW-285.result new file mode 100644 index 0000000000000..8c5a21fcbeec2 --- /dev/null +++ b/mysql-test/suite/galera/r/MW-285.result @@ -0,0 +1,19 @@ +CREATE TABLE parent1 ( id INT PRIMARY KEY, KEY (id) ) ENGINE=InnoDB; +CREATE TABLE parent2 ( id INT PRIMARY KEY, KEY (id) ) ENGINE=InnoDB; +CREATE TABLE child ( +id INT PRIMARY KEY, +parent1_id INT, +parent2_id INT, +FOREIGN KEY (parent1_id) REFERENCES parent1(id), +FOREIGN KEY (parent1_id) REFERENCES parent2(id) +) ENGINE=InnoDB; +INSERT INTO parent1 VALUES (1); +INSERT INTO parent2 VALUES (1); +INSERT INTO child VALUES (1,1,1); +INSERT INTO child VALUES (2,1,1); +SET foreign_key_checks=OFF; +DROP TABLE parent1; +UPDATE child SET parent1_id=2 WHERE id=1; +DROP TABLE child; +DROP TABLE parent2; +SET foreign_key_checks=ON; diff --git a/mysql-test/suite/galera/t/MW-285.test b/mysql-test/suite/galera/t/MW-285.test new file mode 100644 index 0000000000000..1c567f7b25011 --- /dev/null +++ b/mysql-test/suite/galera/t/MW-285.test @@ -0,0 +1,31 @@ +# +# Broken FK constraints cause assertions +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +CREATE TABLE parent1 ( id INT PRIMARY KEY, KEY (id) ) ENGINE=InnoDB; +CREATE TABLE parent2 ( id INT PRIMARY KEY, KEY (id) ) ENGINE=InnoDB; + +CREATE TABLE child ( + id INT PRIMARY KEY, + parent1_id INT, + parent2_id INT, + FOREIGN KEY (parent1_id) REFERENCES parent1(id), + FOREIGN KEY (parent1_id) REFERENCES parent2(id) +) ENGINE=InnoDB; + +INSERT INTO parent1 VALUES (1); +INSERT INTO parent2 VALUES (1); +INSERT INTO child VALUES (1,1,1); +INSERT INTO child VALUES (2,1,1); + +SET foreign_key_checks=OFF; +DROP TABLE parent1; + +UPDATE child SET parent1_id=2 WHERE id=1; + +DROP TABLE child; +DROP TABLE parent2; +SET foreign_key_checks=ON; From bf19492e3b3d73af6ea6c9ff61aa1838a55965ea Mon Sep 17 00:00:00 2001 From: Daniele Sciascia Date: Mon, 13 Jun 2016 17:49:42 +0200 Subject: [PATCH 55/68] GCF-837 Check wsrep interface version before loading provider --- wsrep/wsrep_loader.c | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/wsrep/wsrep_loader.c b/wsrep/wsrep_loader.c index 0825d7e9ecf51..5f98b0ace6a7f 100644 --- a/wsrep/wsrep_loader.c +++ b/wsrep/wsrep_loader.c @@ -37,6 +37,22 @@ static wsrep_log_cb_t logger = default_logger; * Library loader **************************************************************************/ +static int wsrep_check_iface_version(const char* found, const char* iface_ver) +{ + const size_t msg_len = 128; + char msg[128]; + + if (strcmp(found, iface_ver)) { + snprintf (msg, msg_len, + "provider interface version mismatch: need '%s', found '%s'", + iface_ver, found); + logger (WSREP_LOG_ERROR, msg); + return EINVAL; + } + + return 0; +} + static int verify(const wsrep_t *wh, const char *iface_ver) { char msg[128]; @@ -50,13 +66,8 @@ static int verify(const wsrep_t *wh, const char *iface_ver) VERIFY(wh); VERIFY(wh->version); - if (strcmp(wh->version, iface_ver)) { - snprintf (msg, sizeof(msg), - "provider interface version mismatch: need '%s', found '%s'", - iface_ver, wh->version); - logger (WSREP_LOG_ERROR, msg); + if (wsrep_check_iface_version(wh->version, iface_ver)) return EINVAL; - } VERIFY(wh->init); VERIFY(wh->options_set); @@ -107,6 +118,15 @@ static wsrep_loader_fun wsrep_dlf(void *dlh, const char *sym) return alias.dlfun; } +static int wsrep_check_version_symbol(void *dlh) +{ + char** dlversion = NULL; + dlversion = (char**) dlsym(dlh, "wsrep_interface_version"); + if (dlversion == NULL) + return 0; + return wsrep_check_iface_version(*dlversion, WSREP_INTERFACE_VERSION); +} + extern int wsrep_dummy_loader(wsrep_t *w); int wsrep_load(const char *spec, wsrep_t **hptr, wsrep_log_cb_t log_cb) @@ -151,6 +171,11 @@ int wsrep_load(const char *spec, wsrep_t **hptr, wsrep_log_cb_t log_cb) goto out; } + if (wsrep_check_version_symbol(dlh) != 0) { + ret = EINVAL; + goto out; + } + if ((ret = (*dlfun)(*hptr)) != 0) { snprintf(msg, sizeof(msg), "wsrep_load(): loader failed: %s", strerror(ret)); From ea3ff73031dd14664045bcbe7ad922b780d229c9 Mon Sep 17 00:00:00 2001 From: Daniele Sciascia Date: Thu, 9 Jun 2016 09:21:43 +0200 Subject: [PATCH 56/68] GCF-837 Fix crash when loading wrong provider version mysqld would crash with "double free or corrruption message" if wrong provider version was given. --- sql/wsrep_mysqld.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc index 17e3577a6eba6..3c2b2c07d55b2 100644 --- a/sql/wsrep_mysqld.cc +++ b/sql/wsrep_mysqld.cc @@ -484,8 +484,7 @@ int wsrep_init() WSREP_ERROR("wsrep_load(%s) failed: %s (%d). Reverting to no provider.", wsrep_provider, strerror(rcode), rcode); strcpy((char*)wsrep_provider, WSREP_NONE); // damn it's a dirty hack - (void) wsrep_init(); - return rcode; + return wsrep_init(); } else /* this is for recursive call above */ { @@ -671,6 +670,9 @@ void wsrep_init_startup (bool first) wsrep_thr_lock_init(wsrep_thd_is_BF, wsrep_abort_thd, wsrep_debug, wsrep_convert_LOCK_to_trx, wsrep_on); + /* Skip replication start if dummy wsrep provider is loaded */ + if (!strcmp(wsrep_provider, WSREP_NONE)) return; + /* Skip replication start if no cluster address */ if (!wsrep_cluster_address || strlen(wsrep_cluster_address) == 0) return; From 85b9718b22adcc26952c13509d81fa61fa107f44 Mon Sep 17 00:00:00 2001 From: Philip Stoev Date: Wed, 13 Jul 2016 03:19:20 -0700 Subject: [PATCH 57/68] Galera MTR Tests: Test case for galera#414 - crash on shutdown with gcs.max_packet_size=2 --- mysql-test/suite/galera/r/galera#414.result | 5 ++++ mysql-test/suite/galera/t/galera#414.cnf | 8 ++++++ mysql-test/suite/galera/t/galera#414.test | 32 +++++++++++++++++++++ 3 files changed, 45 insertions(+) create mode 100644 mysql-test/suite/galera/r/galera#414.result create mode 100644 mysql-test/suite/galera/t/galera#414.cnf create mode 100644 mysql-test/suite/galera/t/galera#414.test diff --git a/mysql-test/suite/galera/r/galera#414.result b/mysql-test/suite/galera/r/galera#414.result new file mode 100644 index 0000000000000..029961f94639b --- /dev/null +++ b/mysql-test/suite/galera/r/galera#414.result @@ -0,0 +1,5 @@ +SET SESSION wsrep_sync_wait = 0; +SET SESSION wsrep_on = OFF; +SET SESSION wsrep_on = ON; +CALL mtr.add_suppression("Failed to set packet size"); +CALL mtr.add_suppression("Failed to set packet size"); diff --git a/mysql-test/suite/galera/t/galera#414.cnf b/mysql-test/suite/galera/t/galera#414.cnf new file mode 100644 index 0000000000000..fbd1c58754f45 --- /dev/null +++ b/mysql-test/suite/galera/t/galera#414.cnf @@ -0,0 +1,8 @@ +!include ../galera_2nodes.cnf + +[mysqld.1] +wsrep_provider_options='base_port=@mysqld.1.#galera_port;gcs.max_packet_size=2' + +[mysqld.2] +wsrep_provider_options='base_port=@mysqld.2.#galera_port;gcs.max_packet_size=2' + diff --git a/mysql-test/suite/galera/t/galera#414.test b/mysql-test/suite/galera/t/galera#414.test new file mode 100644 index 0000000000000..b426e6510b645 --- /dev/null +++ b/mysql-test/suite/galera/t/galera#414.test @@ -0,0 +1,32 @@ +# +# codership/galera#414 Shutdown crashes node if the node started with `gcs.max_packet_size=2` +# + +--source include/big_test.inc +--source include/galera_cluster.inc + +# We perform the shutdown/restart sequence in here. If there was a crash during shutdown, MTR will detect it + +--connection node_2 +--source include/shutdown_mysqld.inc + +--connection node_1 +SET SESSION wsrep_sync_wait = 0; +SET SESSION wsrep_on = OFF; +--let $wait_condition = SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +--source include/wait_condition.inc + +--connection node_2 +--source include/start_mysqld.inc + +--connection node_1 +SET SESSION wsrep_on = ON; +--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +--source include/wait_condition.inc + +--connection node_1 +CALL mtr.add_suppression("Failed to set packet size"); + +--connection node_2 +CALL mtr.add_suppression("Failed to set packet size"); + From 065645313528fcb8a996b6a5f08686193b0b696c Mon Sep 17 00:00:00 2001 From: Philip Stoev Date: Fri, 22 Jul 2016 04:16:09 -0700 Subject: [PATCH 58/68] Galera MTR Tests: increase timeouts and adjust some sporadically-failing tests so that the Galera suites can be run with --parallel=4 --- mysql-test/suite/galera/galera_2nodes.cnf | 4 ++-- mysql-test/suite/galera/r/galera_defaults.result | 2 +- mysql-test/suite/galera_3nodes/galera_3nodes.cnf | 6 +++--- .../suite/galera_3nodes/r/galera_pc_bootstrap.result | 3 --- mysql-test/suite/galera_3nodes/r/galera_pc_weight.result | 2 ++ mysql-test/suite/galera_3nodes/t/galera_pc_bootstrap.test | 3 ++- mysql-test/suite/galera_3nodes/t/galera_pc_weight.test | 7 ++++++- 7 files changed, 16 insertions(+), 11 deletions(-) diff --git a/mysql-test/suite/galera/galera_2nodes.cnf b/mysql-test/suite/galera/galera_2nodes.cnf index d20080589f1aa..956e09e7b8278 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='repl.causal_read_timeout=PT90S;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;evs.suspect_timeout=PT10S' 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='repl.causal_read_timeout=PT90S;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;evs.suspect_timeout=PT10S' 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_defaults.result b/mysql-test/suite/galera/r/galera_defaults.result index a4e6d31d406a6..3d75b86172a3a 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; gcomm.thread_prio = ; 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; socket.recv_buf_size = 212992; +; ; ; 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 = PT10S; 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; gcomm.thread_prio = ; 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; socket.recv_buf_size = 212992; SELECT COUNT(*) FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME LIKE 'wsrep_%' AND VARIABLE_NAME != 'wsrep_debug_sync_waiters'; diff --git a/mysql-test/suite/galera_3nodes/galera_3nodes.cnf b/mysql-test/suite/galera_3nodes/galera_3nodes.cnf index 689fd4db26cc4..f19277bb36ad8 100644 --- a/mysql-test/suite/galera_3nodes/galera_3nodes.cnf +++ b/mysql-test/suite/galera_3nodes/galera_3nodes.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='base_port=@mysqld.1.#galera_port;gcache.size=10M;evs.suspect_timeout=PT10S' 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='base_port=@mysqld.2.#galera_port;gcache.size=10M;evs.suspect_timeout=PT10S' wsrep_node_incoming_address=127.0.0.1:@mysqld.2.port wsrep_sst_receive_address='127.0.0.1:@mysqld.2.#sst_port' @@ -34,7 +34,7 @@ wsrep_sst_receive_address='127.0.0.1:@mysqld.2.#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.3.#galera_port;gcache.size=10M' +wsrep_provider_options='base_port=@mysqld.3.#galera_port;gcache.size=10M;evs.suspect_timeout=PT10S' wsrep_node_incoming_address=127.0.0.1:@mysqld.3.port wsrep_sst_receive_address='127.0.0.1:@mysqld.3.#sst_port' diff --git a/mysql-test/suite/galera_3nodes/r/galera_pc_bootstrap.result b/mysql-test/suite/galera_3nodes/r/galera_pc_bootstrap.result index f5a4cad4a23d2..69995acb982af 100644 --- a/mysql-test/suite/galera_3nodes/r/galera_pc_bootstrap.result +++ b/mysql-test/suite/galera_3nodes/r/galera_pc_bootstrap.result @@ -3,9 +3,6 @@ SET GLOBAL wsrep_provider_options = 'gmcast.isolate=1'; SET GLOBAL wsrep_provider_options = 'gmcast.isolate=1'; SET GLOBAL wsrep_provider_options = 'gmcast.isolate=1'; SET SESSION wsrep_sync_wait = 0; -SHOW STATUS LIKE 'wsrep_cluster_status'; -Variable_name Value -wsrep_cluster_status non-Primary SET GLOBAL wsrep_provider_options = 'pc.bootstrap=1'; SHOW STATUS LIKE 'wsrep_cluster_size'; Variable_name Value diff --git a/mysql-test/suite/galera_3nodes/r/galera_pc_weight.result b/mysql-test/suite/galera_3nodes/r/galera_pc_weight.result index 85f923ad55e26..6fb931638ef49 100644 --- a/mysql-test/suite/galera_3nodes/r/galera_pc_weight.result +++ b/mysql-test/suite/galera_3nodes/r/galera_pc_weight.result @@ -1,6 +1,8 @@ SET GLOBAL wsrep_provider_options = 'pc.weight=3'; Suspending node ... SET SESSION wsrep_sync_wait=0; +SET SESSION wsrep_on=OFF; +SET SESSION wsrep_on=ON; SHOW STATUS LIKE 'wsrep_cluster_size'; Variable_name Value wsrep_cluster_size 2 diff --git a/mysql-test/suite/galera_3nodes/t/galera_pc_bootstrap.test b/mysql-test/suite/galera_3nodes/t/galera_pc_bootstrap.test index 6172ffcc74302..f8381a3324bea 100644 --- a/mysql-test/suite/galera_3nodes/t/galera_pc_bootstrap.test +++ b/mysql-test/suite/galera_3nodes/t/galera_pc_bootstrap.test @@ -23,7 +23,8 @@ SET GLOBAL wsrep_provider_options = 'gmcast.isolate=1'; # Node #2 should be non-primary SET SESSION wsrep_sync_wait = 0; -SHOW STATUS LIKE 'wsrep_cluster_status'; +--let $wait_condition = SELECT variable_value = 'non-Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE variable_name = 'wsrep_cluster_status'; +--source include/wait_condition.inc # Signal node #2 to bootstrap --connection node_2 diff --git a/mysql-test/suite/galera_3nodes/t/galera_pc_weight.test b/mysql-test/suite/galera_3nodes/t/galera_pc_weight.test index 6585f1934a40d..c118b7481bca2 100644 --- a/mysql-test/suite/galera_3nodes/t/galera_pc_weight.test +++ b/mysql-test/suite/galera_3nodes/t/galera_pc_weight.test @@ -19,6 +19,11 @@ SET GLOBAL wsrep_provider_options = 'pc.weight=3'; SET SESSION wsrep_sync_wait=0; --source include/wait_until_connected_again.inc +SET SESSION wsrep_on=OFF; +--let $wait_condition = SELECT VARIABLE_VALUE = 'non-Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status' +--source include/wait_condition.inc +SET SESSION wsrep_on=ON; + # We can not use SELECT queries here, as only SHOW is allowed to run. # For nodes #2 and #3, we expect a non-primary component of size 2 @@ -45,7 +50,7 @@ SHOW STATUS LIKE 'wsrep_local_state_comment'; --connection node_1 --source include/galera_resume.inc ---sleep 5 +--sleep 10 --source include/wait_until_connected_again.inc # For Node #1, we expect a primary component of size 1 From 30c6ac3cd152c1280fe9ccfb86b42e8048e3dc91 Mon Sep 17 00:00:00 2001 From: Philip Stoev Date: Wed, 3 Aug 2016 02:52:39 -0700 Subject: [PATCH 59/68] Galera MTR Tests: Attempt to fortify galera_kill_ddl.test against sporadic failures --- mysql-test/suite/galera/r/galera_kill_ddl.result | 3 --- mysql-test/suite/galera/t/galera_kill_ddl.test | 7 ++++++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/mysql-test/suite/galera/r/galera_kill_ddl.result b/mysql-test/suite/galera/r/galera_kill_ddl.result index 8dd36497dfb88..b83226bbd425b 100644 --- a/mysql-test/suite/galera/r/galera_kill_ddl.result +++ b/mysql-test/suite/galera/r/galera_kill_ddl.result @@ -5,7 +5,4 @@ ALTER TABLE t1 ADD COLUMN f2 INTEGER; SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='t1'; COUNT(*) = 2 1 -SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; -VARIABLE_VALUE = 2 -1 DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/galera_kill_ddl.test b/mysql-test/suite/galera/t/galera_kill_ddl.test index 3c2bce5b9c9ed..90f3f30cc7678 100644 --- a/mysql-test/suite/galera/t/galera_kill_ddl.test +++ b/mysql-test/suite/galera/t/galera_kill_ddl.test @@ -28,8 +28,13 @@ ALTER TABLE t1 ADD COLUMN f2 INTEGER; --source include/galera_connect.inc --connection node_2a +--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +--source include/wait_condition.inc + +--let $wait_condition = SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; +--source include/wait_condition.inc + SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='t1'; -SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; --connection node_1 --disable_query_log From f01a16b54196ef5f816ca5a1bb590262ce0381e6 Mon Sep 17 00:00:00 2001 From: Philip Stoev Date: Thu, 4 Aug 2016 00:33:12 -0700 Subject: [PATCH 60/68] Galera MTR Tests: fortify galera_bf_abort_flush_for_export against sporadic failures. --- .../suite/galera/r/galera_bf_abort_flush_for_export.result | 7 ++++--- .../suite/galera/t/galera_bf_abort_flush_for_export.test | 5 ++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/mysql-test/suite/galera/r/galera_bf_abort_flush_for_export.result b/mysql-test/suite/galera/r/galera_bf_abort_flush_for_export.result index 8c07d87eec324..96ed226c3ab93 100644 --- a/mysql-test/suite/galera/r/galera_bf_abort_flush_for_export.result +++ b/mysql-test/suite/galera/r/galera_bf_abort_flush_for_export.result @@ -6,9 +6,10 @@ SET SESSION wsrep_sync_wait = 0; UNLOCK TABLES; COMMIT; SET AUTOCOMMIT=ON; -SELECT * FROM t1; -f1 -2 +SET SESSION wsrep_sync_wait = 7; +SELECT COUNT(*) = 1 FROM t1; +COUNT(*) = 1 +1 wsrep_local_aborts_increment 1 DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/galera_bf_abort_flush_for_export.test b/mysql-test/suite/galera/t/galera_bf_abort_flush_for_export.test index dbbe3b3c483d6..e32089ce21eef 100644 --- a/mysql-test/suite/galera/t/galera_bf_abort_flush_for_export.test +++ b/mysql-test/suite/galera/t/galera_bf_abort_flush_for_export.test @@ -27,9 +27,8 @@ UNLOCK TABLES; COMMIT; SET AUTOCOMMIT=ON; ---let $wait_condition = SELECT COUNT(*) = 1 FROM t1 ---source include/wait_condition.inc -SELECT * FROM t1; +SET SESSION wsrep_sync_wait = 7; +SELECT COUNT(*) = 1 FROM t1; --let $wsrep_local_bf_aborts_after = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_bf_aborts'` From 2e56c7f3cdfc882aad25b606a4d14f9cb6295451 Mon Sep 17 00:00:00 2001 From: Philip Stoev Date: Tue, 9 Aug 2016 12:34:03 +0300 Subject: [PATCH 61/68] Bump WSREP_PATCH_VERSION to 16 --- cmake/wsrep.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/wsrep.cmake b/cmake/wsrep.cmake index 6c256471115a8..eeb602c9c4873 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 "14") +SET(WSREP_PATCH_VERSION "16") # MariaDB addition: Revision number of the last revision merged from # codership branch visible in @@visible_comment. From fec296cc10f0d1319e032b72e92e3c824b7fc390 Mon Sep 17 00:00:00 2001 From: Damien Ciabrini Date: Fri, 12 Aug 2016 10:57:58 +0200 Subject: [PATCH 62/68] refs codership/mysql-wsrep#267 Fix Galera crash at startup when compiled with gcc 6 --- sql/wsrep_mysqld.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc index 3c2b2c07d55b2..91a9a1f210d04 100644 --- a/sql/wsrep_mysqld.cc +++ b/sql/wsrep_mysqld.cc @@ -87,7 +87,7 @@ my_bool wsrep_creating_startup_threads = 0; */ my_bool wsrep_inited = 0; // initialized ? -static const wsrep_uuid_t cluster_uuid = WSREP_UUID_UNDEFINED; +static wsrep_uuid_t cluster_uuid = WSREP_UUID_UNDEFINED; static char cluster_uuid_str[40]= { 0, }; static const char* cluster_status_str[WSREP_VIEW_MAX] = { From 415823a41cb7f302e9620f2b0fb57bcc69140d3f Mon Sep 17 00:00:00 2001 From: sjaakola Date: Wed, 8 Jun 2016 15:19:01 +0300 Subject: [PATCH 63/68] Refs: MW-279 - fixes in innodb to skip wsrep processing (like kill victim) when running in native mysql mode - similar fixes in mysql server side - forcing tc_log_dummy in native mysql mode when no binlog used. wsrep hton messes up handler counter and used to lead in using tc_log_mmap instead. Bad news is that tc_log_mmap does not seem to work at all --- sql/mysqld.cc | 11 +++++++++-- sql/wsrep_hton.cc | 10 +++------- storage/innobase/lock/lock0lock.cc | 22 +++++++++++++++------- storage/xtradb/lock/lock0lock.cc | 22 +++++++++++++++------- 4 files changed, 42 insertions(+), 23 deletions(-) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 1bd2a039ce8dd..6fc03e6e9f85c 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -5288,8 +5288,15 @@ static int init_server_components() tc_log= get_tc_log_implementation(); #ifdef WITH_WSREP - if (WSREP_ON && tc_log == &tc_log_mmap) - tc_log= &tc_log_dummy; + if (tc_log == &tc_log_mmap) + { + /* + wsrep hton raises total_ha_2pc count to 2, even in native mysql mode. + Have to force using tc_log_dummy here, as tc_log_mmap segfaults. + */ + if (WSREP_ON || total_ha_2pc <= 2) + tc_log= &tc_log_dummy; + } WSREP_DEBUG("Initial TC log open: %s", (tc_log == &mysql_bin_log) ? "binlog" : diff --git a/sql/wsrep_hton.cc b/sql/wsrep_hton.cc index e1bf63cd31f34..9f8c328c35324 100644 --- a/sql/wsrep_hton.cc +++ b/sql/wsrep_hton.cc @@ -37,6 +37,8 @@ enum wsrep_trx_status wsrep_run_wsrep_commit(THD *thd, handlerton *hton, */ void wsrep_cleanup_transaction(THD *thd) { + if (!WSREP(thd)) return; + if (wsrep_emulate_bin_log) thd_binlog_trx_reset(thd); thd->wsrep_ws_handle.trx_id= WSREP_UNDEFINED_TRX_ID; thd->wsrep_trx_meta.gtid= WSREP_GTID_UNDEFINED; @@ -112,13 +114,7 @@ void wsrep_register_hton(THD* thd, bool all) */ void wsrep_post_commit(THD* thd, bool all) { - /* - TODO: It can perhaps be fixed in a more elegant fashion by turning off - wsrep_emulate_binlog if wsrep_on=0 on server start. - https://github.com/codership/mysql-wsrep/issues/112 - */ - if (!WSREP_ON) - return; + if (!WSREP(thd)) return; switch (thd->wsrep_exec_mode) { diff --git a/storage/innobase/lock/lock0lock.cc b/storage/innobase/lock/lock0lock.cc index ea26298da0111..c44aa490a81c8 100644 --- a/storage/innobase/lock/lock0lock.cc +++ b/storage/innobase/lock/lock0lock.cc @@ -1685,6 +1685,10 @@ wsrep_kill_victim( { ut_ad(lock_mutex_own()); ut_ad(trx_mutex_own(lock->trx)); + + /* quit for native mysql */ + if (!wsrep_on(trx->mysql_thd)) return; + my_bool bf_this = wsrep_thd_is_BF(trx->mysql_thd, FALSE); my_bool bf_other = wsrep_thd_is_BF(lock->trx->mysql_thd, TRUE); @@ -1771,9 +1775,11 @@ lock_rec_other_has_conflicting( #ifdef WITH_WSREP if (lock_rec_has_to_wait(TRUE, trx, mode, lock, is_supremum)) { - trx_mutex_enter(lock->trx); - wsrep_kill_victim(trx, lock); - trx_mutex_exit(lock->trx); + if (wsrep_on(trx->mysql_thd)) { + trx_mutex_enter(lock->trx); + wsrep_kill_victim(trx, lock); + trx_mutex_exit(lock->trx); + } #else if (lock_rec_has_to_wait(trx, mode, lock, is_supremum)) { #endif /* WITH_WSREP */ @@ -2067,7 +2073,9 @@ lock_rec_create( ut_ad(index->table->n_ref_count > 0 || !index->table->can_be_evicted); #ifdef WITH_WSREP - if (c_lock && wsrep_thd_is_BF(trx->mysql_thd, FALSE)) { + if (c_lock && + wsrep_on(trx->mysql_thd) && + wsrep_thd_is_BF(trx->mysql_thd, FALSE)) { lock_t *hash = (lock_t *)c_lock->hash; lock_t *prev = NULL; @@ -4630,10 +4638,10 @@ lock_table_create( trx_mutex_exit(c_lock->trx); } } else { - UT_LIST_ADD_LAST(un_member.tab_lock.locks, table->locks, lock); - } -#else +#endif /* WITH_WSREP */ UT_LIST_ADD_LAST(un_member.tab_lock.locks, table->locks, lock); +#ifdef WITH_WSREP + } #endif /* WITH_WSREP */ if (UNIV_UNLIKELY(type_mode & LOCK_WAIT)) { diff --git a/storage/xtradb/lock/lock0lock.cc b/storage/xtradb/lock/lock0lock.cc index c9b9eea3808f2..b5b9f27e3aaf9 100644 --- a/storage/xtradb/lock/lock0lock.cc +++ b/storage/xtradb/lock/lock0lock.cc @@ -1695,6 +1695,10 @@ wsrep_kill_victim( { ut_ad(lock_mutex_own()); ut_ad(trx_mutex_own(lock->trx)); + + /* quit for native mysql */ + if (!wsrep_on(trx->mysql_thd)) return; + my_bool bf_this = wsrep_thd_is_BF(trx->mysql_thd, FALSE); my_bool bf_other = wsrep_thd_is_BF(lock->trx->mysql_thd, TRUE); @@ -1781,9 +1785,11 @@ lock_rec_other_has_conflicting( #ifdef WITH_WSREP if (lock_rec_has_to_wait(TRUE, trx, mode, lock, is_supremum)) { - trx_mutex_enter(lock->trx); - wsrep_kill_victim((trx_t *)trx, (lock_t *)lock); - trx_mutex_exit(lock->trx); + if (wsrep_on(trx->mysql_thd)) { + trx_mutex_enter(lock->trx); + wsrep_kill_victim(trx, lock); + trx_mutex_exit(lock->trx); + } #else if (lock_rec_has_to_wait(trx, mode, lock, is_supremum)) { #endif /* WITH_WSREP */ @@ -2089,7 +2095,9 @@ lock_rec_create( ut_ad(index->table->n_ref_count > 0 || !index->table->can_be_evicted); #ifdef WITH_WSREP - if (c_lock && wsrep_thd_is_BF(trx->mysql_thd, FALSE)) { + if (c_lock && + wsrep_on(trx->mysql_thd) && + wsrep_thd_is_BF(trx->mysql_thd, FALSE)) { lock_t *hash = (lock_t *)c_lock->hash; lock_t *prev = NULL; @@ -4667,10 +4675,10 @@ lock_table_create( trx_mutex_exit(c_lock->trx); } } else { - UT_LIST_ADD_LAST(un_member.tab_lock.locks, table->locks, lock); - } -#else +#endif /* WITH_WSREP */ UT_LIST_ADD_LAST(un_member.tab_lock.locks, table->locks, lock); +#ifdef WITH_WSREP + } #endif /* WITH_WSREP */ if (UNIV_UNLIKELY(type_mode & LOCK_WAIT)) { From cced23cf23f013bee9f137001f1d51142bace964 Mon Sep 17 00:00:00 2001 From: Nirbhay Choubey Date: Wed, 29 Jun 2016 16:50:53 -0400 Subject: [PATCH 64/68] MDEV-9423: cannot add new node to the cluser: Binlog.. .. file '/var/log/mysql/mariadb-bin.000001' not found in binlog index, needed for recovery. Aborting. In Galera cluster, while preparing for rsync/xtrabackup based SST, the donor node takes an FTWRL followed by (REFRESH_ENGINE_LOG in rsync based state transfer and) REFRESH_BINARY_LOG. The latter rotates the binary log and logs Binlog_checkpoint_log_event corresponding to the penultimate binary log file into the new file. The checkpoint event for the current file is later logged synchronously by binlog_background_thread. Now, since in rsync/xtrabackup based snapshot state transfer methods, only the last binary log file is transferred to the joiner node; the file could get transferred even before the checkpoint event for the same file gets written to it. As a result, the joiner node would fail to start complaining about the missing binlog file needed for recovery. In order to fix this, a mechanism has been put in place to make REFRESH_BINARY_LOG operation wait for Binlog_checkpoint_log_event to be logged for the current binary log file if the node is part of a Galera cluster. As further safety, during rsync based state transfer the donor node now acquires and owns LOCK_log for the duration of file transfer during SST. --- sql/log.cc | 29 ++++++++++++++++++++++++++--- sql/log.h | 1 + sql/sql_reload.cc | 6 ++++++ sql/wsrep_sst.cc | 20 ++++++++++++++++++++ 4 files changed, 53 insertions(+), 3 deletions(-) diff --git a/sql/log.cc b/sql/log.cc index 1d11b6ff01b43..2479208b395e2 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -3687,7 +3687,10 @@ bool MYSQL_BIN_LOG::open(const char *log_name, new_xid_list_entry->binlog_id= current_binlog_id; /* Remove any initial entries with no pending XIDs. */ while ((b= binlog_xid_count_list.head()) && b->xid_count == 0) + { my_free(binlog_xid_count_list.get()); + } + mysql_cond_broadcast(&COND_xid_list); binlog_xid_count_list.push_back(new_xid_list_entry); mysql_mutex_unlock(&LOCK_xid_list); @@ -4208,6 +4211,7 @@ bool MYSQL_BIN_LOG::reset_logs(THD* thd, bool create_new_log, DBUG_ASSERT(b->xid_count == 0); my_free(binlog_xid_count_list.get()); } + mysql_cond_broadcast(&COND_xid_list); reset_master_pending--; mysql_mutex_unlock(&LOCK_xid_list); } @@ -4218,6 +4222,26 @@ bool MYSQL_BIN_LOG::reset_logs(THD* thd, bool create_new_log, } +void MYSQL_BIN_LOG::wait_for_last_checkpoint_event() +{ + mysql_mutex_lock(&LOCK_xid_list); + for (;;) + { + if (binlog_xid_count_list.is_last(binlog_xid_count_list.head())) + break; + mysql_cond_wait(&COND_xid_list, &LOCK_xid_list); + } + mysql_mutex_unlock(&LOCK_xid_list); + + /* + LOCK_xid_list and LOCK_log are chained, so the LOCK_log will only be + obtained after mark_xid_done() has written the last checkpoint event. + */ + mysql_mutex_lock(&LOCK_log); + mysql_mutex_unlock(&LOCK_log); +} + + /** Delete relay log files prior to rli->group_relay_log_name (i.e. all logs which are not involved in a non-finished group @@ -9260,7 +9284,7 @@ TC_LOG_BINLOG::mark_xid_done(ulong binlog_id, bool write_checkpoint) */ if (unlikely(reset_master_pending)) { - mysql_cond_signal(&COND_xid_list); + mysql_cond_broadcast(&COND_xid_list); mysql_mutex_unlock(&LOCK_xid_list); DBUG_VOID_RETURN; } @@ -9298,8 +9322,7 @@ TC_LOG_BINLOG::mark_xid_done(ulong binlog_id, bool write_checkpoint) mysql_mutex_lock(&LOCK_log); mysql_mutex_lock(&LOCK_xid_list); --mark_xid_done_waiting; - if (unlikely(reset_master_pending)) - mysql_cond_signal(&COND_xid_list); + mysql_cond_broadcast(&COND_xid_list); /* We need to reload current_binlog_id due to release/re-take of lock. */ current= current_binlog_id; diff --git a/sql/log.h b/sql/log.h index 7f44113f66d0c..9eb9f88031df3 100644 --- a/sql/log.h +++ b/sql/log.h @@ -774,6 +774,7 @@ class MYSQL_BIN_LOG: public TC_LOG, private MYSQL_LOG bool need_mutex); bool reset_logs(THD* thd, bool create_new_log, rpl_gtid *init_state, uint32 init_state_len); + void wait_for_last_checkpoint_event(); void close(uint exiting); void clear_inuse_flag_when_closing(File file); diff --git a/sql/sql_reload.cc b/sql/sql_reload.cc index f8c04af56bbfc..a83e91680daeb 100644 --- a/sql/sql_reload.cc +++ b/sql/sql_reload.cc @@ -155,6 +155,12 @@ bool reload_acl_and_cache(THD *thd, unsigned long long options, { if (mysql_bin_log.rotate_and_purge(true)) *write_to_binlog= -1; + + if (WSREP_ON) + { + /* Wait for last binlog checkpoint event to be logged. */ + mysql_bin_log.wait_for_last_checkpoint_event(); + } } } if (options & REFRESH_RELAY_LOG) diff --git a/sql/wsrep_sst.cc b/sql/wsrep_sst.cc index b697a557476ea..877a93eec4414 100644 --- a/sql/wsrep_sst.cc +++ b/sql/wsrep_sst.cc @@ -1006,6 +1006,16 @@ static void* sst_donor_thread (void* a) if (!err) { sst_disallow_writes (thd.ptr, true); + /* + Lets also keep statements that modify binary logs (like RESET LOGS, + RESET MASTER) from proceeding until the files have been transferred + to the joiner node. + */ + if (mysql_bin_log.is_open()) + { + mysql_mutex_lock(mysql_bin_log.get_log_lock()); + } + locked= true; goto wait_signal; } @@ -1014,6 +1024,11 @@ static void* sst_donor_thread (void* a) { if (locked) { + if (mysql_bin_log.is_open()) + { + mysql_mutex_assert_owner(mysql_bin_log.get_log_lock()); + mysql_mutex_unlock(mysql_bin_log.get_log_lock()); + } sst_disallow_writes (thd.ptr, false); thd.ptr->global_read_lock.unlock_global_read_lock (thd.ptr); locked= false; @@ -1046,6 +1061,11 @@ static void* sst_donor_thread (void* a) if (locked) // don't forget to unlock server before return { + if (mysql_bin_log.is_open()) + { + mysql_mutex_assert_owner(mysql_bin_log.get_log_lock()); + mysql_mutex_unlock(mysql_bin_log.get_log_lock()); + } sst_disallow_writes (thd.ptr, false); thd.ptr->global_read_lock.unlock_global_read_lock (thd.ptr); } From 3f481e52e41deecb05874989a51d6b009fda1a23 Mon Sep 17 00:00:00 2001 From: Nirbhay Choubey Date: Sun, 21 Aug 2016 20:09:05 -0400 Subject: [PATCH 65/68] Fixes for failing tests (post-merge). --- mysql-test/suite/galera/disabled.def | 1 + mysql-test/suite/galera/r/MW-284.result | 1 + mysql-test/suite/galera/r/galera_as_master.result | 1 + .../suite/galera/r/galera_as_slave_autoinc.result | 4 +--- mysql-test/suite/galera/t/MW-284.test | 1 + mysql-test/suite/galera/t/galera_as_master.test | 3 +++ .../suite/galera/t/galera_as_slave_autoinc.test | 5 ++--- .../suite/galera/t/galera_ist_restart_joiner.test | 15 +++++++++++++++ .../t/galera_ist_gcache_rollover.test | 2 ++ .../suite/sys_vars/r/wsrep_desync_basic.result | 8 ++++++-- .../sys_vars/r/wsrep_max_ws_size_basic.result | 4 +++- .../suite/sys_vars/t/wsrep_max_ws_size_basic.test | 2 ++ sql/sql_class.h | 1 - storage/xtradb/row/row0upd.cc | 4 ++-- wsrep/wsrep_dummy.c | 11 +++++++++-- 15 files changed, 49 insertions(+), 14 deletions(-) diff --git a/mysql-test/suite/galera/disabled.def b/mysql-test/suite/galera/disabled.def index 25f20e01521d5..4aa15d27661f6 100644 --- a/mysql-test/suite/galera/disabled.def +++ b/mysql-test/suite/galera/disabled.def @@ -28,3 +28,4 @@ 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 +galera_binlog_stmt_autoinc : TODO: investigate \ No newline at end of file diff --git a/mysql-test/suite/galera/r/MW-284.result b/mysql-test/suite/galera/r/MW-284.result index 8b5119663ce35..3ff131674ea62 100644 --- a/mysql-test/suite/galera/r/MW-284.result +++ b/mysql-test/suite/galera/r/MW-284.result @@ -11,3 +11,4 @@ DROP TABLE t1; STOP SLAVE; RESET SLAVE ALL; CALL mtr.add_suppression('failed registering on master'); +CALL mtr.add_suppression('You need to use --log-bin to make --binlog-format work'); diff --git a/mysql-test/suite/galera/r/galera_as_master.result b/mysql-test/suite/galera/r/galera_as_master.result index aba93573ecfea..bd7d63ad1ab0e 100644 --- a/mysql-test/suite/galera/r/galera_as_master.result +++ b/mysql-test/suite/galera/r/galera_as_master.result @@ -5,3 +5,4 @@ INSERT INTO t1 VALUES(2); DROP TABLE t1; STOP SLAVE; RESET SLAVE ALL; +CALL mtr.add_suppression('You need to use --log-bin to make --binlog-format work'); diff --git a/mysql-test/suite/galera/r/galera_as_slave_autoinc.result b/mysql-test/suite/galera/r/galera_as_slave_autoinc.result index a8f5ec8e37e32..b6314b862c2d2 100644 --- a/mysql-test/suite/galera/r/galera_as_slave_autoinc.result +++ b/mysql-test/suite/galera/r/galera_as_slave_autoinc.result @@ -1,6 +1,4 @@ -START SLAVE USER='root'; -Warnings: -Note 1759 Sending passwords in plain text without SSL/TLS is extremely insecure. +START SLAVE; SET SESSION binlog_format='STATEMENT'; CREATE TABLE t1 ( i int(11) NOT NULL AUTO_INCREMENT, diff --git a/mysql-test/suite/galera/t/MW-284.test b/mysql-test/suite/galera/t/MW-284.test index 5998e22ed1eb4..f3ce1b0dc9171 100644 --- a/mysql-test/suite/galera/t/MW-284.test +++ b/mysql-test/suite/galera/t/MW-284.test @@ -55,3 +55,4 @@ STOP SLAVE; RESET SLAVE ALL; CALL mtr.add_suppression('failed registering on master'); +CALL mtr.add_suppression('You need to use --log-bin to make --binlog-format work'); diff --git a/mysql-test/suite/galera/t/galera_as_master.test b/mysql-test/suite/galera/t/galera_as_master.test index c42dbbf9683d2..b8f989d497bf0 100644 --- a/mysql-test/suite/galera/t/galera_as_master.test +++ b/mysql-test/suite/galera/t/galera_as_master.test @@ -36,3 +36,6 @@ DROP TABLE t1; STOP SLAVE; RESET SLAVE ALL; + +CALL mtr.add_suppression('You need to use --log-bin to make --binlog-format work'); + diff --git a/mysql-test/suite/galera/t/galera_as_slave_autoinc.test b/mysql-test/suite/galera/t/galera_as_slave_autoinc.test index bf04b274ca7d1..9292badc4804b 100644 --- a/mysql-test/suite/galera/t/galera_as_slave_autoinc.test +++ b/mysql-test/suite/galera/t/galera_as_slave_autoinc.test @@ -5,7 +5,6 @@ # --source include/have_innodb.inc ---source include/have_log_bin.inc # As node #1 is not a Galera node, we connect to node #2 in order to run include/galera_cluster.inc --connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2 @@ -13,9 +12,9 @@ --connection node_2 --disable_query_log ---eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$NODE_MYPORT_1; +--eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_USER='root', MASTER_PORT=$NODE_MYPORT_1; --enable_query_log -START SLAVE USER='root'; +START SLAVE; --connection node_1 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 eae28bdbcd767..11664affe7c8d 100644 --- a/mysql-test/suite/galera/t/galera_ist_restart_joiner.test +++ b/mysql-test/suite/galera/t/galera_ist_restart_joiner.test @@ -9,6 +9,12 @@ --source include/have_debug_sync.inc --source suite/galera/include/galera_have_debug_sync.inc +# Save original auto_increment_offset values. +--connection node_1 +let $auto_increment_offset_node_1 = `SELECT @@global.auto_increment_offset`; +--connection node_2 +let $auto_increment_offset_node_2 = `SELECT @@global.auto_increment_offset`; + CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 CHAR(1)); INSERT INTO t1 VALUES (1, 'a'), (2, 'a'), (3, 'a'), (4, 'a'), (5, 'a'),(6, 'a'); @@ -106,3 +112,12 @@ SELECT COUNT(*) = 0 FROM t3; --connection node_1 DROP TABLE t1, t2, t3; + +# Restore original auto_increment_offset values. +--disable_query_log +--connection node_1 +--eval SET @@global.auto_increment_offset = $auto_increment_offset_node_1; +--connection node_2 +--eval SET @@global.auto_increment_offset = $auto_increment_offset_node_2; +--enable_query_log + 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 7d8bbb39e3577..8575d99f066d3 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 @@ -82,6 +82,8 @@ INSERT INTO t1 VALUES (51), (52), (53), (54), (55); --connection node_3 --source include/wait_until_connected_again.inc +sleep 5; + # Final checks --connection node_2 SELECT COUNT(*) = 30 FROM t1; diff --git a/mysql-test/suite/sys_vars/r/wsrep_desync_basic.result b/mysql-test/suite/sys_vars/r/wsrep_desync_basic.result index 6225b444cfdad..5cd2a2e57203f 100644 --- a/mysql-test/suite/sys_vars/r/wsrep_desync_basic.result +++ b/mysql-test/suite/sys_vars/r/wsrep_desync_basic.result @@ -22,10 +22,12 @@ SET @@global.wsrep_desync=ON; ERROR HY000: Operation 'desync' failed for SET @@global.wsrep_desync=ON SELECT @@global.wsrep_desync; @@global.wsrep_desync -1 +0 # valid values SET @@global.wsrep_desync='OFF'; +Warnings: +Warning 1231 'wsrep_desync' is already OFF. SELECT @@global.wsrep_desync; @@global.wsrep_desync 0 @@ -33,8 +35,10 @@ SET @@global.wsrep_desync=ON; ERROR HY000: Operation 'desync' failed for SET @@global.wsrep_desync=ON SELECT @@global.wsrep_desync; @@global.wsrep_desync -1 +0 SET @@global.wsrep_desync=default; +Warnings: +Warning 1231 'wsrep_desync' is already OFF. SELECT @@global.wsrep_desync; @@global.wsrep_desync 0 diff --git a/mysql-test/suite/sys_vars/r/wsrep_max_ws_size_basic.result b/mysql-test/suite/sys_vars/r/wsrep_max_ws_size_basic.result index 26d8d823a5cdd..d7e72869be372 100644 --- a/mysql-test/suite/sys_vars/r/wsrep_max_ws_size_basic.result +++ b/mysql-test/suite/sys_vars/r/wsrep_max_ws_size_basic.result @@ -3,10 +3,11 @@ # # save the initial value SET @wsrep_max_ws_size_global_saved = @@global.wsrep_max_ws_size; +SET @wsrep_provider_options_saved = @@global.wsrep_provider_options; # default SELECT @@global.wsrep_max_ws_size; @@global.wsrep_max_ws_size -1073741824 +2147483647 # scope SELECT @@session.wsrep_max_ws_size; @@ -55,4 +56,5 @@ NULL # restore the initial value SET @@global.wsrep_max_ws_size = @wsrep_max_ws_size_global_saved; +SET @@global.wsrep_provider_options = @wsrep_provider_options_saved; # End of test diff --git a/mysql-test/suite/sys_vars/t/wsrep_max_ws_size_basic.test b/mysql-test/suite/sys_vars/t/wsrep_max_ws_size_basic.test index e7af4558f24d5..2e302015136a4 100644 --- a/mysql-test/suite/sys_vars/t/wsrep_max_ws_size_basic.test +++ b/mysql-test/suite/sys_vars/t/wsrep_max_ws_size_basic.test @@ -6,6 +6,7 @@ --echo # save the initial value SET @wsrep_max_ws_size_global_saved = @@global.wsrep_max_ws_size; +SET @wsrep_provider_options_saved = @@global.wsrep_provider_options; --echo # default SELECT @@global.wsrep_max_ws_size; @@ -41,5 +42,6 @@ SELECT @global.wsrep_max_ws_size; --echo --echo # restore the initial value SET @@global.wsrep_max_ws_size = @wsrep_max_ws_size_global_saved; +SET @@global.wsrep_provider_options = @wsrep_provider_options_saved; --echo # End of test diff --git a/sql/sql_class.h b/sql/sql_class.h index ee637b3726d28..bf3d043cc1a3a 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -660,7 +660,6 @@ typedef struct system_variables uint wsrep_sync_wait; ulong wsrep_retry_autocommit; ulong wsrep_OSU_method; - ulong wsrep_auto_increment_control; #endif double long_query_time_double; diff --git a/storage/xtradb/row/row0upd.cc b/storage/xtradb/row/row0upd.cc index 16795aed0dbe7..e28cae052f327 100644 --- a/storage/xtradb/row/row0upd.cc +++ b/storage/xtradb/row/row0upd.cc @@ -412,7 +412,7 @@ wsrep_row_upd_check_foreign_constraints( dict_table_open_on_name( foreign->referenced_table_name_lookup, FALSE, FALSE, DICT_ERR_IGNORE_NONE); - opened = TRUE; + opened = (foreign->referenced_table) ? TRUE : FALSE; } if (foreign->referenced_table) { @@ -435,7 +435,7 @@ wsrep_row_upd_check_foreign_constraints( ->n_foreign_key_checks_running); if (opened == TRUE) { - dict_table_close(foreign->referenced_table, TRUE, FALSE); + dict_table_close(foreign->referenced_table, FALSE, FALSE); opened = FALSE; } } diff --git a/wsrep/wsrep_dummy.c b/wsrep/wsrep_dummy.c index 5f1ea63cc4037..1780e91f89dca 100644 --- a/wsrep/wsrep_dummy.c +++ b/wsrep/wsrep_dummy.c @@ -85,8 +85,15 @@ static wsrep_status_t dummy_options_set( static char* dummy_options_get (wsrep_t* w) { - WSREP_DBUG_ENTER(w); - return strdup(WSREP_DUMMY(w)->options); + char *options; + + WSREP_DBUG_ENTER(w); + options= WSREP_DUMMY(w)->options; + + if (options) + options= strdup(WSREP_DUMMY(w)->options); + + return options; } static wsrep_status_t dummy_connect( From f381ad5230e0537c63ad721d39aab1681e0a213a Mon Sep 17 00:00:00 2001 From: Nirbhay Choubey Date: Sun, 21 Aug 2016 20:13:51 -0400 Subject: [PATCH 66/68] 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 eeb602c9c4873..f54efc274fb64 100644 --- a/cmake/wsrep.cmake +++ b/cmake/wsrep.cmake @@ -23,7 +23,7 @@ SET(WSREP_PATCH_VERSION "16") # 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 "af7f02e") # Should be updated on every merge. +SET(WSREP_PATCH_REVNO "c3fc46e") # Should be updated on every merge. # MariaDB: Obtain patch revision number: # Update WSREP_PATCH_REVNO if WSREP_REV environment variable is set. From 1b7c5dedf7266d73c9c402cefee681251aea1e18 Mon Sep 17 00:00:00 2001 From: Nirbhay Choubey Date: Wed, 24 Aug 2016 15:32:48 -0400 Subject: [PATCH 67/68] MDEV-10566: Create role statement replicated inconsistently in Galera Cluster In galera cluster, the definer (and thus binlog invoker) must be set for CREATE ROLE before Query_log_event is created during TOI on the originating node. --- mysql-test/suite/galera/r/galera_roles.result | 41 ++++++++++++++++++- mysql-test/suite/galera/t/galera_roles.test | 32 +++++++++++++++ sql/sql_class.cc | 4 ++ sql/wsrep_mysqld.cc | 6 +++ 4 files changed, 82 insertions(+), 1 deletion(-) diff --git a/mysql-test/suite/galera/r/galera_roles.result b/mysql-test/suite/galera/r/galera_roles.result index c0cdbc0e3386c..d8c137587978a 100644 --- a/mysql-test/suite/galera/r/galera_roles.result +++ b/mysql-test/suite/galera/r/galera_roles.result @@ -69,8 +69,8 @@ SET ROLE role1; FLUSH TABLES; SELECT * FROM mysql.roles_mapping; Host User Role Admin_option - role1 Y localhost foo role1 N +localhost root role1 Y SHOW TABLES FROM test1; Tables_in_test1 t1 @@ -153,4 +153,43 @@ role1 # Connect with node_1 DROP USER foo@localhost; DROP DATABASE test1; +# +# MDEV-10566: Create role statement replicated inconsistently in Galera Cluster +# + +# On node_1 +CREATE USER foo@localhost; +CREATE ROLE role1; +CREATE ROLE role2 WITH ADMIN CURRENT_USER; +CREATE ROLE role3 WITH ADMIN foo@localhost; +CREATE ROLE role4 WITH ADMIN role1; +SELECT * FROM mysql.roles_mapping; +Host User Role Admin_option + role1 role4 Y +localhost foo role3 Y +localhost root role1 Y +localhost root role2 Y +SELECT * FROM INFORMATION_SCHEMA.APPLICABLE_ROLES; +GRANTEE ROLE_NAME IS_GRANTABLE +role1 role4 YES +root@localhost role1 YES +root@localhost role2 YES + +# On node_2 +SELECT * FROM mysql.roles_mapping; +Host User Role Admin_option + role1 role4 Y +localhost foo role3 Y +localhost root role1 Y +localhost root role2 Y +SELECT * FROM INFORMATION_SCHEMA.APPLICABLE_ROLES; +GRANTEE ROLE_NAME IS_GRANTABLE +role1 role4 YES +root@localhost role1 YES +root@localhost role2 YES +DROP ROLE role1; +DROP ROLE role2; +DROP ROLE role3; +DROP ROLE role4; +DROP USER foo@localhost; # End of test diff --git a/mysql-test/suite/galera/t/galera_roles.test b/mysql-test/suite/galera/t/galera_roles.test index f9a15126e5ecd..16e417d1fdb64 100644 --- a/mysql-test/suite/galera/t/galera_roles.test +++ b/mysql-test/suite/galera/t/galera_roles.test @@ -163,5 +163,37 @@ disconnect foo_node_2; DROP USER foo@localhost; DROP DATABASE test1; +--echo # +--echo # MDEV-10566: Create role statement replicated inconsistently in Galera Cluster +--echo # +--echo +--echo # On node_1 +--connection node_1 +CREATE USER foo@localhost; +CREATE ROLE role1; +CREATE ROLE role2 WITH ADMIN CURRENT_USER; +CREATE ROLE role3 WITH ADMIN foo@localhost; +CREATE ROLE role4 WITH ADMIN role1; + +--sorted_result +SELECT * FROM mysql.roles_mapping; +--sorted_result +SELECT * FROM INFORMATION_SCHEMA.APPLICABLE_ROLES; + +--echo +--echo # On node_2 +--connection node_2 +--sorted_result +SELECT * FROM mysql.roles_mapping; +--sorted_result +SELECT * FROM INFORMATION_SCHEMA.APPLICABLE_ROLES; + +# Cleanup +DROP ROLE role1; +DROP ROLE role2; +DROP ROLE role3; +DROP ROLE role4; +DROP USER foo@localhost; + --source include/galera_end.inc --echo # End of test diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 37bacc986f7d3..76f8b98c55e5b 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -5249,7 +5249,11 @@ void THD::get_definer(LEX_USER *definer, bool role) { binlog_invoker(role); #if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) +#ifdef WITH_WSREP + if ((wsrep_applier || slave_thread) && has_invoker()) +#else if (slave_thread && has_invoker()) +#endif { definer->user = invoker_user; definer->host= invoker_host; diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc index 91a9a1f210d04..4117d5231f4ba 100644 --- a/sql/wsrep_mysqld.cc +++ b/sql/wsrep_mysqld.cc @@ -1236,6 +1236,12 @@ static int wsrep_TOI_begin(THD *thd, char *db_, char *table_, case SQLCOM_ALTER_EVENT: buf_err= wsrep_alter_event_query(thd, &buf, &buf_len); break; + case SQLCOM_CREATE_ROLE: + if (sp_process_definer(thd)) + { + WSREP_WARN("Failed to set CREATE ROLE definer for TOI."); + } + /* fallthrough */ default: buf_err= wsrep_to_buf_helper(thd, thd->query(), thd->query_length(), &buf, &buf_len); From 8b09db8bfb81f1e7695cfcfa6ce2bec45247171f Mon Sep 17 00:00:00 2001 From: Nirbhay Choubey Date: Wed, 24 Aug 2016 17:13:20 -0400 Subject: [PATCH 68/68] Fixes/improvements in galera test suite --- .../include/auto_increment_offset_restore.inc | 35 ++++++++++++++++++ .../include/auto_increment_offset_save.inc | 37 +++++++++++++++++++ .../galera/t/galera_ist_restart_joiner.test | 16 +++----- .../suite/galera/t/galera_pc_ignore_sb.test | 17 ++++----- .../galera/t/galera_restart_nochanges.test | 17 ++++----- .../suite/galera/t/galera_split_brain.test | 21 +++++------ .../suite/galera/t/galera_suspend_slave.test | 15 +++----- .../galera/t/galera_var_dirty_reads.test | 16 ++------ mysql-test/suite/galera/t/mysql-wsrep#31.test | 14 +++++++ .../t/galera_certification_ccc.test | 21 ++++------- 10 files changed, 131 insertions(+), 78 deletions(-) create mode 100644 mysql-test/suite/galera/include/auto_increment_offset_restore.inc create mode 100644 mysql-test/suite/galera/include/auto_increment_offset_save.inc diff --git a/mysql-test/suite/galera/include/auto_increment_offset_restore.inc b/mysql-test/suite/galera/include/auto_increment_offset_restore.inc new file mode 100644 index 0000000000000..6218dfd6f2c56 --- /dev/null +++ b/mysql-test/suite/galera/include/auto_increment_offset_restore.inc @@ -0,0 +1,35 @@ +# See auto_increment_offset_restore.inc for details. + +if (!$node_1) +{ + --die ERROR IN TEST: $node_1 must be set before sourcing auto_increment_offset_save.inc +} + +if (!$node_2) +{ + --die ERROR IN TEST: $node_2 must be set before sourcing auto_increment_offset_save.inc +} + +if (!$auto_increment_offset_node_1) +{ + --die ERROR IN TEST: $auto_increment_offset_node_1 must be set before sourcing auto_increment_offset_save.inc +} + +if (!$auto_increment_offset_node_2) +{ + --die ERROR IN TEST: $auto_increment_offset_node_2 must be set before sourcing auto_increment_offset_save.inc +} + +# Restore original auto_increment_offset values. +--disable_query_log +--connection $node_1 +--eval SET @@global.auto_increment_offset = $auto_increment_offset_node_1; +--connection $node_2 +--eval SET @@global.auto_increment_offset = $auto_increment_offset_node_2; + +if ($node_3) +{ +--connection $node_3 +--eval SET @@global.auto_increment_offset = $auto_increment_offset_node_3; +} +--enable_query_log diff --git a/mysql-test/suite/galera/include/auto_increment_offset_save.inc b/mysql-test/suite/galera/include/auto_increment_offset_save.inc new file mode 100644 index 0000000000000..3c4db3f381cd1 --- /dev/null +++ b/mysql-test/suite/galera/include/auto_increment_offset_save.inc @@ -0,0 +1,37 @@ +# This file can be used to save the @@global.auto_increment_offset value at +# the beginning of any test that intends to restart any of the participating +# nodes. This is required as the node may get auto-assigned a different +# auto_increment_offset value on restart, which could cause MTR's internal +# post-check to fail. auto_increment_offset_restore.inc can be used at the +# end of the test to restore these saved values. + +# Parameters +# ---------- +# $node_1 +# Connection handle for 1st node +# $node_2 +# Connection handle for 2nd node +# $node_3 (optional) +# Connection handle for 3rd node + +if (!$node_1) +{ + --die ERROR IN TEST: $node_1 must be set before sourcing auto_increment_offset_save.inc +} + +if (!$node_2) +{ + --die ERROR IN TEST: $node_2 must be set before sourcing auto_increment_offset_save.inc +} + +--connection $node_1 +let $auto_increment_offset_node_1 = `SELECT @@global.auto_increment_offset`; +--connection $node_2 +let $auto_increment_offset_node_2 = `SELECT @@global.auto_increment_offset`; + +if ($node_3) +{ + --connection $node_3 + let $auto_increment_offset_node_3 = `SELECT @@global.auto_increment_offset`; +} + 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 11664affe7c8d..931daaad30d80 100644 --- a/mysql-test/suite/galera/t/galera_ist_restart_joiner.test +++ b/mysql-test/suite/galera/t/galera_ist_restart_joiner.test @@ -10,10 +10,9 @@ --source suite/galera/include/galera_have_debug_sync.inc # Save original auto_increment_offset values. ---connection node_1 -let $auto_increment_offset_node_1 = `SELECT @@global.auto_increment_offset`; ---connection node_2 -let $auto_increment_offset_node_2 = `SELECT @@global.auto_increment_offset`; +--let $node_1=node_1 +--let $node_2=node_2 +--source include/auto_increment_offset_save.inc CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 CHAR(1)); INSERT INTO t1 VALUES (1, 'a'), (2, 'a'), (3, 'a'), (4, 'a'), (5, 'a'),(6, 'a'); @@ -114,10 +113,7 @@ SELECT COUNT(*) = 0 FROM t3; DROP TABLE t1, t2, t3; # Restore original auto_increment_offset values. ---disable_query_log ---connection node_1 ---eval SET @@global.auto_increment_offset = $auto_increment_offset_node_1; ---connection node_2 ---eval SET @@global.auto_increment_offset = $auto_increment_offset_node_2; ---enable_query_log +--source include/auto_increment_offset_restore.inc + +--source include/galera_end.inc diff --git a/mysql-test/suite/galera/t/galera_pc_ignore_sb.test b/mysql-test/suite/galera/t/galera_pc_ignore_sb.test index f63215ebe4a68..84fd3a9185707 100644 --- a/mysql-test/suite/galera/t/galera_pc_ignore_sb.test +++ b/mysql-test/suite/galera/t/galera_pc_ignore_sb.test @@ -6,10 +6,9 @@ --source include/have_innodb.inc # Save original auto_increment_offset values. ---connection node_1 -let $auto_increment_offset_node_1 = `SELECT @@global.auto_increment_offset`; ---connection node_2 -let $auto_increment_offset_node_2 = `SELECT @@global.auto_increment_offset`; +--let $node_1=node_1 +--let $node_2=node_2 +--source include/auto_increment_offset_save.inc --connection node_1 --let $wsrep_cluster_address_orig = `SELECT @@wsrep_cluster_address` @@ -40,10 +39,8 @@ SET GLOBAL wsrep_cluster_address = ''; --source include/start_mysqld.inc --source include/wait_until_connected_again.inc ---disable_query_log # Restore original auto_increment_offset values. ---connection node_1 ---eval SET @@global.auto_increment_offset = $auto_increment_offset_node_1; ---connection node_2 ---eval SET @@global.auto_increment_offset = $auto_increment_offset_node_2; ---enable_query_log +--source include/auto_increment_offset_restore.inc + +--source include/galera_end.inc + diff --git a/mysql-test/suite/galera/t/galera_restart_nochanges.test b/mysql-test/suite/galera/t/galera_restart_nochanges.test index ba12c4c409c1e..0a6a0c5ccbeab 100644 --- a/mysql-test/suite/galera/t/galera_restart_nochanges.test +++ b/mysql-test/suite/galera/t/galera_restart_nochanges.test @@ -6,10 +6,9 @@ --source include/have_innodb.inc # Save original auto_increment_offset values. ---connection node_1 -let $auto_increment_offset_node_1 = `SELECT @@global.auto_increment_offset`; ---connection node_2 -let $auto_increment_offset_node_2 = `SELECT @@global.auto_increment_offset`; +--let $node_1=node_1 +--let $node_2=node_2 +--source include/auto_increment_offset_save.inc --connection node_1 CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; @@ -33,11 +32,9 @@ SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_N DROP TABLE t1; ---disable_query_log # Restore original auto_increment_offset values. ---connection node_1 ---eval SET @@global.auto_increment_offset = $auto_increment_offset_node_1; ---connection node_2a ---eval SET @@global.auto_increment_offset = $auto_increment_offset_node_2; ---enable_query_log +--let $node_2=node_2a +--source include/auto_increment_offset_restore.inc + +--source include/galera_end.inc diff --git a/mysql-test/suite/galera/t/galera_split_brain.test b/mysql-test/suite/galera/t/galera_split_brain.test index e0298e5542279..22f6370241ce6 100644 --- a/mysql-test/suite/galera/t/galera_split_brain.test +++ b/mysql-test/suite/galera/t/galera_split_brain.test @@ -6,17 +6,16 @@ --source include/galera_cluster.inc --source include/have_innodb.inc +# Save original auto_increment_offset values. +--let $node_1=node_1 +--let $node_2=node_2 +--source include/auto_increment_offset_save.inc + call mtr.add_suppression("WSREP: TO isolation failed for: "); --connection node_1 --let $wsrep_cluster_address_orig = `SELECT @@wsrep_cluster_address` -# Save original auto_increment_offset values. ---connection node_1 -let $auto_increment_offset_node_1 = `SELECT @@global.auto_increment_offset`; ---connection node_2 -let $auto_increment_offset_node_2 = `SELECT @@global.auto_increment_offset`; - --connection node_2 --source include/kill_galera.inc @@ -44,10 +43,8 @@ SET GLOBAL wsrep_cluster_address = ''; --source include/wait_until_connected_again.inc # Restore original auto_increment_offset values. ---disable_query_log ---connection node_1 ---eval SET @@global.auto_increment_offset = $auto_increment_offset_node_1; ---connection node_2a ---eval SET @@global.auto_increment_offset = $auto_increment_offset_node_2; ---enable_query_log +--let $node_2=node_2a +--source include/auto_increment_offset_restore.inc + +--source include/galera_end.inc diff --git a/mysql-test/suite/galera/t/galera_suspend_slave.test b/mysql-test/suite/galera/t/galera_suspend_slave.test index 236c65b73a7e2..5c62208580453 100644 --- a/mysql-test/suite/galera/t/galera_suspend_slave.test +++ b/mysql-test/suite/galera/t/galera_suspend_slave.test @@ -8,10 +8,9 @@ --source include/have_innodb.inc # Save original auto_increment_offset values. ---connection node_1 -let $auto_increment_offset_node_1 = `SELECT @@global.auto_increment_offset`; ---connection node_2 -let $auto_increment_offset_node_2 = `SELECT @@global.auto_increment_offset`; +--let $node_1=node_1 +--let $node_2=node_2 +--source include/auto_increment_offset_save.inc --connection node_1 CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; @@ -56,11 +55,7 @@ SELECT COUNT(*) = 1 FROM t1; DROP TABLE t1; ---disable_query_log # Restore original auto_increment_offset values. ---connection node_1 ---eval SET @@global.auto_increment_offset = $auto_increment_offset_node_1; ---connection node_2a ---eval SET @@global.auto_increment_offset = $auto_increment_offset_node_2; ---enable_query_log +--let $node_2=node_2a +--source include/auto_increment_offset_restore.inc diff --git a/mysql-test/suite/galera/t/galera_var_dirty_reads.test b/mysql-test/suite/galera/t/galera_var_dirty_reads.test index 9eea8efdaf3a9..dfd8d5ecf2905 100644 --- a/mysql-test/suite/galera/t/galera_var_dirty_reads.test +++ b/mysql-test/suite/galera/t/galera_var_dirty_reads.test @@ -5,13 +5,10 @@ --source include/galera_cluster.inc --source include/have_innodb.inc ---disable_query_log # Save original auto_increment_offset values. ---connection node_1 -let $auto_increment_offset_node_1 = `SELECT @@global.auto_increment_offset`; ---connection node_2 -let $auto_increment_offset_node_2 = `SELECT @@global.auto_increment_offset`; ---enable_query_log +--let $node_1=node_1 +--let $node_2=node_2 +--source include/auto_increment_offset_save.inc --connection node_2 --let $wsrep_cluster_address_saved = `SELECT @@global.wsrep_cluster_address` @@ -49,13 +46,8 @@ SELECT * FROM t1; # Cleanup DROP TABLE t1; ---disable_query_log # Restore original auto_increment_offset values. ---connection node_1 ---eval SET @@global.auto_increment_offset = $auto_increment_offset_node_1; ---connection node_2 ---eval SET @@global.auto_increment_offset = $auto_increment_offset_node_2; ---enable_query_log +--source include/auto_increment_offset_restore.inc --source include/galera_end.inc --echo # End of test diff --git a/mysql-test/suite/galera/t/mysql-wsrep#31.test b/mysql-test/suite/galera/t/mysql-wsrep#31.test index eaace5d50dd14..c669d4834badf 100644 --- a/mysql-test/suite/galera/t/mysql-wsrep#31.test +++ b/mysql-test/suite/galera/t/mysql-wsrep#31.test @@ -1,6 +1,11 @@ --source include/galera_cluster.inc --source include/have_innodb.inc +# Save original auto_increment_offset values. +--let $node_1=node_1 +--let $node_2=node_2 +--source include/auto_increment_offset_save.inc + --connection node_1 CREATE TABLE t1 (f1 CHAR(255)) ENGINE=InnoDB; @@ -36,4 +41,13 @@ if ($galera_wsrep_start_position != $expected_position) DROP TABLE t1; DROP DATABASE db; +--connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2 +--source include/wait_until_connected_again.inc + +# Restore original auto_increment_offset values. +--let $node_2=node_2a +--source include/auto_increment_offset_restore.inc + +--source include/galera_end.inc + diff --git a/mysql-test/suite/galera_3nodes/t/galera_certification_ccc.test b/mysql-test/suite/galera_3nodes/t/galera_certification_ccc.test index e19169a350c64..b4fe10bff0d37 100644 --- a/mysql-test/suite/galera_3nodes/t/galera_certification_ccc.test +++ b/mysql-test/suite/galera_3nodes/t/galera_certification_ccc.test @@ -10,12 +10,10 @@ --source include/galera_connect.inc # Save original auto_increment_offset values. ---connection node_1 -let $auto_increment_offset_node_1 = `SELECT @@global.auto_increment_offset`; ---connection node_2 -let $auto_increment_offset_node_2 = `SELECT @@global.auto_increment_offset`; ---connection node_3 -let $auto_increment_offset_node_3 = `SELECT @@global.auto_increment_offset`; +--let $node_1=node_1 +--let $node_2=node_2 +--let $node_3=node_3 +--source ../galera/include/auto_increment_offset_save.inc --connection node_1 CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; @@ -49,12 +47,7 @@ SELECT COUNT(*) = 2 FROM t1; DROP TABLE t1; # Restore original auto_increment_offset values. ---disable_query_log ---connection node_1 ---eval SET @@global.auto_increment_offset = $auto_increment_offset_node_1; ---connection node_2 ---eval SET @@global.auto_increment_offset = $auto_increment_offset_node_2; ---connection node_3 ---eval SET @@global.auto_increment_offset = $auto_increment_offset_node_3; ---enable_query_log +--source ../galera/include/auto_increment_offset_restore.inc + +--source include/galera_end.inc