diff options
-rw-r--r-- | mysql-test/include/check-warnings.test | 4 | ||||
-rw-r--r-- | mysql-test/suite/galera/r/partition.result | 36 | ||||
-rw-r--r-- | mysql-test/suite/galera/t/partition.test | 113 | ||||
-rw-r--r-- | mysql-test/suite/wsrep/suite.pm | 4 | ||||
-rw-r--r-- | sql/mysqld.cc | 4 | ||||
-rw-r--r-- | storage/innobase/handler/ha_innodb.cc | 31 | ||||
-rw-r--r-- | storage/xtradb/handler/ha_innodb.cc | 31 |
7 files changed, 191 insertions, 32 deletions
diff --git a/mysql-test/include/check-warnings.test b/mysql-test/include/check-warnings.test index 9ecf7de419a..b2f73c32e35 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 diff --git a/mysql-test/suite/galera/r/partition.result b/mysql-test/suite/galera/r/partition.result index dbd082347e4..3907b4f08c9 100644 --- a/mysql-test/suite/galera/r/partition.result +++ b/mysql-test/suite/galera/r/partition.result @@ -101,4 +101,40 @@ t1 CREATE TABLE `t1` ( (PARTITION p1 VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION pMax VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */ DROP TABLE t1, p1; +# +# 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 d6775fdc958..bb5a02411c3 100644 --- a/mysql-test/suite/galera/t/partition.test +++ b/mysql-test/suite/galera/t/partition.test @@ -90,5 +90,118 @@ SHOW CREATE TABLE t1; # Cleanup DROP TABLE t1, p1; +--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/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 4d22e1d01de..fab1477a87b 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -9676,10 +9676,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; diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index d2c7b21dc45..f18eca7cf2b 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -7483,10 +7483,11 @@ no_commit: ; } else if (src_table == prebuilt->table) { #ifdef WITH_WSREP - if (wsrep_on(user_thd) && wsrep_load_data_splitting && + if (wsrep_on(user_thd) && + wsrep_load_data_splitting && sql_command == SQLCOM_LOAD && - !thd_test_options( - user_thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) + !thd_test_options(user_thd, + OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) { switch (wsrep_run_wsrep_commit(user_thd, wsrep_hton, 1)) { @@ -7514,10 +7515,11 @@ no_commit: prebuilt->sql_stat_start = TRUE; } else { #ifdef WITH_WSREP - if (wsrep_on(user_thd) && wsrep_load_data_splitting && + if (wsrep_on(user_thd) && + wsrep_load_data_splitting && sql_command == SQLCOM_LOAD && - !thd_test_options( - user_thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) + !thd_test_options(user_thd, + OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) { switch (wsrep_run_wsrep_commit(user_thd, wsrep_hton, 1)) { @@ -7739,14 +7741,15 @@ report_error: 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 8257264034a..9579fbba6f5 100644 --- a/storage/xtradb/handler/ha_innodb.cc +++ b/storage/xtradb/handler/ha_innodb.cc @@ -8055,10 +8055,11 @@ no_commit: ; } else if (src_table == prebuilt->table) { #ifdef WITH_WSREP - if (wsrep_on(user_thd) && wsrep_load_data_splitting && + if (wsrep_on(user_thd) && + wsrep_load_data_splitting && sql_command == SQLCOM_LOAD && - !thd_test_options( - user_thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) + !thd_test_options(user_thd, + OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) { switch (wsrep_run_wsrep_commit(user_thd, wsrep_hton, 1)) { @@ -8086,10 +8087,11 @@ no_commit: prebuilt->sql_stat_start = TRUE; } else { #ifdef WITH_WSREP - if (wsrep_on(user_thd) && wsrep_load_data_splitting && + if (wsrep_on(user_thd) && + wsrep_load_data_splitting && sql_command == SQLCOM_LOAD && - !thd_test_options( - user_thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) + !thd_test_options(user_thd, + OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) { switch (wsrep_run_wsrep_commit(user_thd, wsrep_hton, 1)) { @@ -8320,14 +8322,15 @@ report_error: 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; } } |