summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristian Nielsen <knielsen@knielsen-hq.org>2015-03-16 14:40:29 +0100
committerKristian Nielsen <knielsen@knielsen-hq.org>2015-03-16 14:40:29 +0100
commitef4d8db5ece5edfe3574561a8cec70863d390c91 (patch)
treef0623f6ac8827339c3243fb72215d02ffd07e9d2
parent0e717c5bf424a7411030d625499485a821591830 (diff)
downloadmariadb-git-ef4d8db5ece5edfe3574561a8cec70863d390c91.tar.gz
MDEV-6981: feature request MASTER_GTID_WAIT status variables
Review fixes: - Coding style - Fix bad .result file - Fix test to be tolerant of different timing. - Fix test to give better info in case of unexpected timing.
-rw-r--r--mysql-test/suite/rpl/r/rpl_gtid_basic.result16
-rw-r--r--mysql-test/suite/rpl/t/rpl_gtid_basic.test13
-rw-r--r--sql/rpl_gtid.cc8
-rw-r--r--sql/sql_class.h4
4 files changed, 26 insertions, 15 deletions
diff --git a/mysql-test/suite/rpl/r/rpl_gtid_basic.result b/mysql-test/suite/rpl/r/rpl_gtid_basic.result
index bdb965e3fcc..22f284d6716 100644
--- a/mysql-test/suite/rpl/r/rpl_gtid_basic.result
+++ b/mysql-test/suite/rpl/r/rpl_gtid_basic.result
@@ -295,9 +295,11 @@ Master_gtid_wait_timeouts 0
SHOW STATUS LIKE 'Master_gtid_wait_count';
Variable_name Value
Master_gtid_wait_count 4
-SELECT MASTER_GTID_WAIT_TIME <= 1000000 AS Master_gtid_wait_less_than_second;
-Master_gtid_wait_less_than_second
-1
+SET @a= MASTER_GTID_WAIT_TIME;
+SELECT IF(@a <= 100*1000*1000, "OK", CONCAT("Error: wait time ", @a, " is larger than expected"))
+AS Master_gtid_wait_time_as_expected;
+Master_gtid_wait_time_as_expected
+OK
SELECT master_gtid_wait('0-1-109');
SHOW STATUS LIKE 'Master_gtid_wait_timeouts';
Variable_name Value
@@ -314,9 +316,10 @@ Master_gtid_wait_timeouts 1
SHOW STATUS LIKE 'Master_gtid_wait_count';
Variable_name Value
Master_gtid_wait_count 5
-SELECT MASTER_GTID_WAIT_TIME BETWEEN 500000 AND 3000000 AS Master_gtid_wait_time_between_half_and_3_seconds;
-Master_gtid_wait_time_between_half_and_3_seconds
-1
+SET @a= MASTER_GTID_WAIT_TIME;
+SELECT IF(@a BETWEEN 0.4*1000*1000 AND 100*1000*1000, "OK", CONCAT("Error: wait time ", @a, " not as expected")) AS Master_gtid_wait_time_as_expected;
+Master_gtid_wait_time_as_expected
+OK
KILL QUERY KILL_ID;
ERROR 70100: Query execution was interrupted
SET gtid_domain_id=2;
@@ -472,5 +475,6 @@ a
31
32
33
+34
DROP TABLE t1;
include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/t/rpl_gtid_basic.test b/mysql-test/suite/rpl/t/rpl_gtid_basic.test
index 307bbbab850..b6a4c7f7e2b 100644
--- a/mysql-test/suite/rpl/t/rpl_gtid_basic.test
+++ b/mysql-test/suite/rpl/t/rpl_gtid_basic.test
@@ -309,7 +309,7 @@ send SELECT master_gtid_wait('2-1-5,1-1-4,0-1-110');
send SELECT master_gtid_wait('2-1-2');
--connection server_2
-# This one completes immediately ( < 1 ms).
+# This one completes immediately.
SHOW STATUS LIKE 'Master_gtid_wait_timeouts';
SHOW STATUS LIKE 'Master_gtid_wait_count';
SELECT master_gtid_wait('1-1-1');
@@ -317,7 +317,9 @@ SHOW STATUS LIKE 'Master_gtid_wait_timeouts';
SHOW STATUS LIKE 'Master_gtid_wait_count';
let $wait_time = query_get_value(SHOW STATUS LIKE 'Master_gtid_wait_time', Value, 1);
--replace_result $wait_time MASTER_GTID_WAIT_TIME
-eval SELECT $wait_time <= 1000000 AS Master_gtid_wait_less_than_second;
+eval SET @a= $wait_time;
+SELECT IF(@a <= 100*1000*1000, "OK", CONCAT("Error: wait time ", @a, " is larger than expected"))
+ AS Master_gtid_wait_time_as_expected;
--connect (s10,127.0.0.1,root,,test,$SERVER_MYPORT_2,)
@@ -330,10 +332,13 @@ SHOW STATUS LIKE 'Master_gtid_wait_count';
SELECT master_gtid_wait('2-1-2', 0.5);
SHOW STATUS LIKE 'Master_gtid_wait_timeouts';
SHOW STATUS LIKE 'Master_gtid_wait_count';
-# (0.5-3 seconds)
let $wait_time = query_get_value(SHOW STATUS LIKE 'Master_gtid_wait_time', Value, 1);
--replace_result $wait_time MASTER_GTID_WAIT_TIME
-eval SELECT $wait_time BETWEEN 500000 AND 3000000 AS Master_gtid_wait_time_between_half_and_3_seconds;
+eval SET @a= $wait_time;
+# We expect a wait time of just a bit over 0.5 seconds. But thread scheduling
+# and timer inaccuracies could introduce significant jitter. So allow a
+# generous interval.
+SELECT IF(@a BETWEEN 0.4*1000*1000 AND 100*1000*1000, "OK", CONCAT("Error: wait time ", @a, " not as expected")) AS Master_gtid_wait_time_as_expected;
--replace_result $kill1_id KILL_ID
eval KILL QUERY $kill1_id;
diff --git a/sql/rpl_gtid.cc b/sql/rpl_gtid.cc
index 078ec74b263..1dc6a2720ad 100644
--- a/sql/rpl_gtid.cc
+++ b/sql/rpl_gtid.cc
@@ -2011,7 +2011,7 @@ gtid_waiting::wait_for_pos(THD *thd, String *gtid_str, longlong timeout_us)
return 1;
}
status_var_increment(thd->status_var.master_gtid_wait_count);
- before = microsecond_interval_timer();
+ before= microsecond_interval_timer();
if (timeout_us >= 0)
{
@@ -2030,8 +2030,10 @@ gtid_waiting::wait_for_pos(THD *thd, String *gtid_str, longlong timeout_us)
{
case -1:
status_var_increment(thd->status_var.master_gtid_wait_timeouts);
- case 0: /* deliberate fall through */
- status_var_add(thd->status_var.master_gtid_wait_time, microsecond_interval_timer() - before);
+ /* Deliberate fall through. */
+ case 0:
+ status_var_add(thd->status_var.master_gtid_wait_time,
+ microsecond_interval_timer() - before);
}
my_free(wait_pos);
return err;
diff --git a/sql/sql_class.h b/sql/sql_class.h
index 8871e6ace98..f7aa54b6693 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -739,8 +739,8 @@ typedef struct system_status_var
ulong feature_xml; /* +1 when XPATH is used */
/* From MASTER_GTID_WAIT usage */
- ulonglong master_gtid_wait_timeouts; /* # of timeouts */
- ulonglong master_gtid_wait_time; /* Time in microseconds */
+ ulonglong master_gtid_wait_timeouts; /* Number of timeouts */
+ ulonglong master_gtid_wait_time; /* Time in microseconds */
ulonglong master_gtid_wait_count;
ulong empty_queries;