From 44e3046d3b09a21e21295979d6ddad9f332ebadd Mon Sep 17 00:00:00 2001 From: Nirbhay Choubey Date: Wed, 3 Aug 2016 22:15:57 -0400 Subject: [PATCH 1/5] 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 3202087f526..7f0901c10fb 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 2/5] 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 ad3e94d43ca..e42eeacfff0 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 50e8a09706b..4d665775f2d 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 3/5] 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 00000000000..f038f880efa --- /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 00000000000..945d9f42458 --- /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 4/5] 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 00000000000..589522a55b0 --- /dev/null +++ b/mysql-test/include/galera_clear_sync_point.inc @@ -0,0 +1 @@ +SET GLOBAL wsrep_provider_options = 'dbug='; diff --git a/mysql-test/include/galera_set_sync_point.inc b/mysql-test/include/galera_set_sync_point.inc new file mode 100644 index 00000000000..5fe4e8c38c0 --- /dev/null +++ b/mysql-test/include/galera_set_sync_point.inc @@ -0,0 +1 @@ +--eval SET GLOBAL wsrep_provider_options = 'dbug=d,$galera_sync_point' diff --git a/mysql-test/include/galera_signal_sync_point.inc b/mysql-test/include/galera_signal_sync_point.inc new file mode 100644 index 00000000000..eaa5cdd43f5 --- /dev/null +++ b/mysql-test/include/galera_signal_sync_point.inc @@ -0,0 +1 @@ +--eval SET GLOBAL wsrep_provider_options = 'signal=$galera_sync_point' diff --git a/mysql-test/include/galera_wait_sync_point.inc b/mysql-test/include/galera_wait_sync_point.inc new file mode 100644 index 00000000000..cf3a4980186 --- /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 00000000000..7c0156052d8 --- /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 945d9f42458..7e4cf9050ae 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 5/5] 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 9e0cb07b86c..75b8f821d22 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()