From 98bebad67274a87517a94b204cd8684a2e48d8c6 Mon Sep 17 00:00:00 2001 From: Nirbhay Choubey Date: Tue, 18 Aug 2015 17:03:28 -0400 Subject: Fix for a typo. --- mysql-test/suite/wsrep/suite.pm | 4 ++-- sql/mysqld.cc | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mysql-test/suite/wsrep/suite.pm b/mysql-test/suite/wsrep/suite.pm index 1dbe1630a1b..ec7a3e374f5 100644 --- a/mysql-test/suite/wsrep/suite.pm +++ b/mysql-test/suite/wsrep/suite.pm @@ -25,8 +25,8 @@ return "No my_print_defaults" unless $epath; push @::global_suppressions, ( qr(WSREP: Could not open saved state file for reading: ), - qr(WSREP: option --wsrep-casual-reads is deprecated), - qr(WSREP: --wsrep-casual-reads=ON takes precedence over --wsrep-sync-wait=0), + qr(WSREP: option --wsrep-causal-reads is deprecated), + qr(WSREP: --wsrep-causal-reads=ON takes precedence over --wsrep-sync-wait=0), qr|WSREP: access file\(.*gvwstate.dat\) failed\(No such file or directory\)|, ); diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 357b62ff2a8..a59780f8f4f 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -8764,10 +8764,10 @@ static int get_options(int *argc_ptr, char ***argv_ptr) } if (global_system_variables.wsrep_causal_reads) { - WSREP_WARN("option --wsrep-casual-reads is deprecated"); + WSREP_WARN("option --wsrep-causal-reads is deprecated"); if (!(global_system_variables.wsrep_sync_wait & WSREP_SYNC_WAIT_BEFORE_READ)) { - WSREP_WARN("--wsrep-casual-reads=ON takes precedence over --wsrep-sync-wait=%u. " + WSREP_WARN("--wsrep-causal-reads=ON takes precedence over --wsrep-sync-wait=%u. " "WSREP_SYNC_WAIT_BEFORE_READ is on", global_system_variables.wsrep_sync_wait); global_system_variables.wsrep_sync_wait |= WSREP_SYNC_WAIT_BEFORE_READ; -- cgit v1.2.1 From ccd39b2dd3315ce6a7844676907097325b39c0b8 Mon Sep 17 00:00:00 2001 From: Nirbhay Choubey Date: Thu, 20 Aug 2015 09:55:54 -0400 Subject: Backport partition tests from 10.0-galera. --- .../galera/r/galera_var_load_data_splitting.result | 9 +++++ mysql-test/suite/galera/r/partition.result | 23 +++++++++++++ .../galera/t/galera_var_load_data_splitting.test | 38 ++++++++++++++++++++++ mysql-test/suite/galera/t/partition.test | 31 ++++++++++++++++++ 4 files changed, 101 insertions(+) create mode 100644 mysql-test/suite/galera/r/galera_var_load_data_splitting.result create mode 100644 mysql-test/suite/galera/r/partition.result create mode 100644 mysql-test/suite/galera/t/galera_var_load_data_splitting.test create mode 100644 mysql-test/suite/galera/t/partition.test diff --git a/mysql-test/suite/galera/r/galera_var_load_data_splitting.result b/mysql-test/suite/galera/r/galera_var_load_data_splitting.result new file mode 100644 index 00000000000..db145fd1561 --- /dev/null +++ b/mysql-test/suite/galera/r/galera_var_load_data_splitting.result @@ -0,0 +1,9 @@ +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; +SET GLOBAL wsrep_load_data_splitting = TRUE; +SELECT COUNT(*) = 95000 FROM t1; +COUNT(*) = 95000 +1 +wsrep_last_committed_diff +1 +SET GLOBAL wsrep_load_data_splitting = 1;; +DROP TABLE t1; diff --git a/mysql-test/suite/galera/r/partition.result b/mysql-test/suite/galera/r/partition.result new file mode 100644 index 00000000000..60fb2ed298d --- /dev/null +++ b/mysql-test/suite/galera/r/partition.result @@ -0,0 +1,23 @@ +# +# MDEV#4953 Galera: DELETE from a partitioned table is not replicated +# +USE test; +CREATE TABLE t1 (pk INT PRIMARY KEY, i INT) ENGINE=INNODB PARTITION BY HASH(pk) PARTITIONS 2; +INSERT INTO t1 VALUES (1,100), (2,200); +SELECT * FROM t1; +pk i +2 200 +1 100 +DELETE FROM t1; +SELECT * FROM t1; +pk i + +# On node_1 +SELECT * FROM t1; +pk i + +# On node_2 +SELECT * FROM t1; +pk i +DROP TABLE t1; +# End of test diff --git a/mysql-test/suite/galera/t/galera_var_load_data_splitting.test b/mysql-test/suite/galera/t/galera_var_load_data_splitting.test new file mode 100644 index 00000000000..0783dc897f8 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_var_load_data_splitting.test @@ -0,0 +1,38 @@ +--source include/galera_cluster.inc +--source include/have_innodb.inc + +--let $wsrep_load_data_splitting_orig = `SELECT @@wsrep_load_data_splitting` + +# Create a file for LOAD DATA with 95K entries +--perl +open(FILE, ">", "$ENV{'MYSQLTEST_VARDIR'}/tmp/galera_var_load_data_splitting.csv") or die; +foreach my $i (1..95000) { + print FILE "$i\n"; +} +EOF + +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; + +# Record wsrep_last_committed as it was before LOAD DATA +--connection node_2 +--let $wsrep_last_committed_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` + +SET GLOBAL wsrep_load_data_splitting = TRUE; +--disable_query_log +--eval LOAD DATA INFILE '$MYSQLTEST_VARDIR/tmp/galera_var_load_data_splitting.csv' INTO TABLE t1; +--enable_query_log + +--connection node_2 +--let $wsrep_last_committed_after = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` + +SELECT COUNT(*) = 95000 FROM t1; + +# LOAD-ing 95K rows causes 10 commits to be registered +--disable_query_log +--eval SELECT $wsrep_last_committed_after = $wsrep_last_committed_before + 10 AS wsrep_last_committed_diff; +--enable_query_log + +--connection node_1 +--eval SET GLOBAL wsrep_load_data_splitting = $wsrep_load_data_splitting_orig; + +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/partition.test b/mysql-test/suite/galera/t/partition.test new file mode 100644 index 00000000000..048f35a9282 --- /dev/null +++ b/mysql-test/suite/galera/t/partition.test @@ -0,0 +1,31 @@ +--source include/galera_cluster.inc +--source include/have_innodb.inc +--source include/have_partition.inc + +--echo # +--echo # MDEV#4953 Galera: DELETE from a partitioned table is not replicated +--echo # + +USE test; +CREATE TABLE t1 (pk INT PRIMARY KEY, i INT) ENGINE=INNODB PARTITION BY HASH(pk) PARTITIONS 2; +INSERT INTO t1 VALUES (1,100), (2,200); +SELECT * FROM t1; + +DELETE FROM t1; +SELECT * FROM t1; + +--echo +--echo # On node_1 +--connection node_1 +SELECT * FROM t1; + +--echo +--echo # On node_2 +--connection node_2 +SELECT * FROM t1; + +# Cleanup +DROP TABLE t1; + +--source include/galera_end.inc +--echo # End of test -- cgit v1.2.1 From 4ee28865f67c980848bb62f0009440be73ebee7c Mon Sep 17 00:00:00 2001 From: Nirbhay Choubey Date: Thu, 20 Aug 2015 20:55:52 -0400 Subject: MDEV-5146 : Bulk loads into partitioned table not working When wsrep is enabled, for any update on innodb tables, the corresponding keys are appended to galera's transaction writeset (wsrep_append_keys()). However, for LOAD DATA, this got skipped if binary logging was disabled or it was non-ROW based. As a result, while the updates from LOAD DATA on non-partitioned tables replicated fine as wsrep implicitly enables binary logging (if not enabled, explicitly), the same did not work on partitioned tables as for partitioned tables the binary logging gets disabled temporarily (ha_partition::write_row()). Fixed by removing the unwanted conditions from the check. Also backported some changes from 10.0-galera to make sure wsrep_load_data_splitting affects LOAD DATA commands only. --- mysql-test/suite/galera/r/partition.result | 36 +++++++++ mysql-test/suite/galera/t/partition.test | 113 +++++++++++++++++++++++++++++ storage/innobase/handler/ha_innodb.cc | 31 +++++--- storage/xtradb/handler/ha_innodb.cc | 31 +++++--- 4 files changed, 191 insertions(+), 20 deletions(-) diff --git a/mysql-test/suite/galera/r/partition.result b/mysql-test/suite/galera/r/partition.result index 60fb2ed298d..379b82fabf8 100644 --- a/mysql-test/suite/galera/r/partition.result +++ b/mysql-test/suite/galera/r/partition.result @@ -20,4 +20,40 @@ pk i SELECT * FROM t1; pk i DROP TABLE t1; +# +# MDEV-5146: Bulk loads into partitioned table not working +# +# Case 1: wsrep_load_data_splitting = ON & LOAD DATA with 20002 +# entries. +SET GLOBAL wsrep_load_data_splitting = ON; +CREATE TABLE t1 (pk INT PRIMARY KEY) +ENGINE=INNODB PARTITION BY HASH(pk) PARTITIONS 2; +SELECT COUNT(*) = 20002 FROM t1; +COUNT(*) = 20002 +1 +wsrep_last_committed_diff +1 +DROP TABLE t1; +# Case 2: wsrep_load_data_splitting = ON & LOAD DATA with 101 entries. +SET GLOBAL wsrep_load_data_splitting = ON; +CREATE TABLE t1 (pk INT PRIMARY KEY) +ENGINE=INNODB PARTITION BY HASH(pk) PARTITIONS 2; +SELECT COUNT(*) = 101 FROM t1; +COUNT(*) = 101 +1 +wsrep_last_committed_diff +1 +DROP TABLE t1; +# Case 3: wsrep_load_data_splitting = OFF & LOAD DATA with 20002 +# entries. +SET GLOBAL wsrep_load_data_splitting = OFF; +CREATE TABLE t1 (pk INT PRIMARY KEY) +ENGINE=INNODB PARTITION BY HASH(pk) PARTITIONS 2; +SELECT COUNT(*) = 20002 FROM t1; +COUNT(*) = 20002 +1 +wsrep_last_committed_diff +1 +DROP TABLE t1; +SET GLOBAL wsrep_load_data_splitting = 1;; # End of test diff --git a/mysql-test/suite/galera/t/partition.test b/mysql-test/suite/galera/t/partition.test index 048f35a9282..e4775e1e730 100644 --- a/mysql-test/suite/galera/t/partition.test +++ b/mysql-test/suite/galera/t/partition.test @@ -27,5 +27,118 @@ SELECT * FROM t1; # Cleanup DROP TABLE t1; +--echo # +--echo # MDEV-5146: Bulk loads into partitioned table not working +--echo # + +# Create 2 files with 20002 & 101 entries in each. +--perl +open(FILE, ">", "$ENV{'MYSQLTEST_VARDIR'}/tmp/mdev-5146-1.dat") or die; +foreach my $i (1..20002) { + print FILE "$i\n"; +} + +open(FILE, ">", "$ENV{'MYSQLTEST_VARDIR'}/tmp/mdev-5146-2.dat") or die; +foreach my $i (1..101) { + print FILE "$i\n"; +} +EOF + +--connection node_1 + +--let $wsrep_load_data_splitting_orig = `SELECT @@wsrep_load_data_splitting` + +--echo # Case 1: wsrep_load_data_splitting = ON & LOAD DATA with 20002 +--echo # entries. + +SET GLOBAL wsrep_load_data_splitting = ON; + +CREATE TABLE t1 (pk INT PRIMARY KEY) + ENGINE=INNODB PARTITION BY HASH(pk) PARTITIONS 2; + +# Record wsrep_last_committed as it was before LOAD DATA +--let $wsrep_last_committed_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` + +--disable_query_log +--eval LOAD DATA INFILE '$MYSQLTEST_VARDIR/tmp/mdev-5146-1.dat' INTO TABLE t1; +--enable_query_log + +--let $wsrep_last_committed_after = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` + +--connection node_2 +SELECT COUNT(*) = 20002 FROM t1; + +# LOAD-ing 20002 rows causes 3 commits to be registered +--disable_query_log +--eval SELECT $wsrep_last_committed_after = $wsrep_last_committed_before + 3 AS wsrep_last_committed_diff; +--enable_query_log + +DROP TABLE t1; + +--echo # Case 2: wsrep_load_data_splitting = ON & LOAD DATA with 101 entries. + +--connection node_1 + +SET GLOBAL wsrep_load_data_splitting = ON; + +CREATE TABLE t1 (pk INT PRIMARY KEY) + ENGINE=INNODB PARTITION BY HASH(pk) PARTITIONS 2; + +# Record wsrep_last_committed as it was before LOAD DATA +--let $wsrep_last_committed_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` + +--disable_query_log +--eval LOAD DATA INFILE '$MYSQLTEST_VARDIR/tmp/mdev-5146-2.dat' INTO TABLE t1; +--enable_query_log + +--let $wsrep_last_committed_after = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` + +--connection node_2 +SELECT COUNT(*) = 101 FROM t1; + +# LOAD-ing 101 rows causes 1 commit to be registered +--disable_query_log +--eval SELECT $wsrep_last_committed_after = $wsrep_last_committed_before + 1 AS wsrep_last_committed_diff; +--enable_query_log + +DROP TABLE t1; + +--echo # Case 3: wsrep_load_data_splitting = OFF & LOAD DATA with 20002 +--echo # entries. + +--connection node_1 + +SET GLOBAL wsrep_load_data_splitting = OFF; + +CREATE TABLE t1 (pk INT PRIMARY KEY) + ENGINE=INNODB PARTITION BY HASH(pk) PARTITIONS 2; + +# Record wsrep_last_committed as it was before LOAD DATA +--let $wsrep_last_committed_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` + +--disable_query_log +--eval LOAD DATA INFILE '$MYSQLTEST_VARDIR/tmp/mdev-5146-1.dat' INTO TABLE t1; +--enable_query_log + +--let $wsrep_last_committed_after = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` + +--connection node_2 +SELECT COUNT(*) = 20002 FROM t1; + +# LOAD-ing 20002 rows causes 1 commit to be registered +--disable_query_log +--eval SELECT $wsrep_last_committed_after = $wsrep_last_committed_before + 1 AS wsrep_last_committed_diff; +--enable_query_log + +DROP TABLE t1; + +--connection node_1 +# Restore the original value +--eval SET GLOBAL wsrep_load_data_splitting = $wsrep_load_data_splitting_orig; + +# Cleanup +remove_file '$MYSQLTEST_VARDIR/tmp/mdev-5146-1.dat'; +remove_file '$MYSQLTEST_VARDIR/tmp/mdev-5146-2.dat'; + --source include/galera_end.inc --echo # End of test diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 773e74e9ab0..0fce4e4c4f6 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -5753,7 +5753,12 @@ no_commit: ; } else if (src_table == prebuilt->table) { #ifdef WITH_WSREP - if (wsrep_on(user_thd)) { + if (wsrep_on(user_thd) && + wsrep_load_data_splitting && + sql_command == SQLCOM_LOAD && + !thd_test_options(user_thd, + OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) + { switch (wsrep_run_wsrep_commit(user_thd, wsrep_hton, 1)) { case WSREP_TRX_OK: @@ -5780,7 +5785,12 @@ no_commit: prebuilt->sql_stat_start = TRUE; } else { #ifdef WITH_WSREP - if (wsrep_on(user_thd)) { + if (wsrep_on(user_thd) && + wsrep_load_data_splitting && + sql_command == SQLCOM_LOAD && + !thd_test_options(user_thd, + OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) + { switch (wsrep_run_wsrep_commit(user_thd, wsrep_hton, 1)) { case WSREP_TRX_OK: @@ -5990,14 +6000,15 @@ report_error: prebuilt->table->flags, user_thd); #ifdef WITH_WSREP - if (!error_result && wsrep_thd_exec_mode(user_thd) == LOCAL_STATE && - wsrep_on(user_thd) && !wsrep_consistency_check(user_thd) && - (sql_command != SQLCOM_LOAD || - thd_binlog_format(user_thd) == BINLOG_FORMAT_ROW)) { - - if (wsrep_append_keys(user_thd, false, record, NULL)) { - DBUG_PRINT("wsrep", ("row key failed")); - error_result = HA_ERR_INTERNAL_ERROR; + if (!error_result && + wsrep_thd_exec_mode(user_thd) == LOCAL_STATE && + wsrep_on(user_thd) && + !wsrep_consistency_check(user_thd)) + { + if (wsrep_append_keys(user_thd, false, record, NULL)) + { + DBUG_PRINT("wsrep", ("row key failed")); + error_result = HA_ERR_INTERNAL_ERROR; goto wsrep_error; } } diff --git a/storage/xtradb/handler/ha_innodb.cc b/storage/xtradb/handler/ha_innodb.cc index 49c9790c435..3ae440c8cf7 100644 --- a/storage/xtradb/handler/ha_innodb.cc +++ b/storage/xtradb/handler/ha_innodb.cc @@ -6717,7 +6717,12 @@ no_commit: ; } else if (src_table == prebuilt->table) { #ifdef WITH_WSREP - if (wsrep_on(user_thd)) { + if (wsrep_on(user_thd) && + wsrep_load_data_splitting && + sql_command == SQLCOM_LOAD && + !thd_test_options(user_thd, + OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) + { switch (wsrep_run_wsrep_commit(user_thd, wsrep_hton, 1)) { case WSREP_TRX_OK: @@ -6744,7 +6749,12 @@ no_commit: prebuilt->sql_stat_start = TRUE; } else { #ifdef WITH_WSREP - if (wsrep_on(user_thd)) { + if (wsrep_on(user_thd) && + wsrep_load_data_splitting && + sql_command == SQLCOM_LOAD && + !thd_test_options(user_thd, + OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) + { switch (wsrep_run_wsrep_commit(user_thd, wsrep_hton, 1)) { case WSREP_TRX_OK: @@ -6960,14 +6970,15 @@ report_error: prebuilt->table->flags, user_thd); #ifdef WITH_WSREP - if (!error_result && wsrep_thd_exec_mode(user_thd) == LOCAL_STATE && - wsrep_on(user_thd) && !wsrep_consistency_check(user_thd) && - (sql_command != SQLCOM_LOAD || - thd_binlog_format(user_thd) == BINLOG_FORMAT_ROW)) { - - if (wsrep_append_keys(user_thd, false, record, NULL)) { - DBUG_PRINT("wsrep", ("row key failed")); - error_result = HA_ERR_INTERNAL_ERROR; + if (!error_result && + wsrep_thd_exec_mode(user_thd) == LOCAL_STATE && + wsrep_on(user_thd) && + !wsrep_consistency_check(user_thd)) + { + if (wsrep_append_keys(user_thd, false, record, NULL)) + { + DBUG_PRINT("wsrep", ("row key failed")); + error_result = HA_ERR_INTERNAL_ERROR; goto wsrep_error; } } -- cgit v1.2.1 From 472d66320d8538f2d1850bb50caceed18181024a Mon Sep 17 00:00:00 2001 From: Nirbhay Choubey Date: Sat, 22 Aug 2015 01:18:02 -0400 Subject: MDEV-8149: Random mtr test failures during warning check Do not replicate commands from check-warnings.test to other nodes in the cluster. --- mysql-test/include/check-warnings.test | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mysql-test/include/check-warnings.test b/mysql-test/include/check-warnings.test index 3a26f7eecb1..cd3fa0b0153 100644 --- a/mysql-test/include/check-warnings.test +++ b/mysql-test/include/check-warnings.test @@ -11,6 +11,10 @@ # Don't write these queries to binlog set SQL_LOG_BIN=0; +# Do not replicate updates to other galera nodes +--error 0,1193 +set WSREP_ON=0; + # Turn off any debug crashes, allow the variable to be # non existent in release builds --error 0,1193 -- cgit v1.2.1