[Commits] ef4d8db: MDEV-6981: feature request MASTER_GTID_WAIT status variables

Kristian Nielsen knielsen at knielsen-hq.org
Mon Mar 16 15:40:40 EET 2015


revision-id: ef4d8db5ece5edfe3574561a8cec70863d390c91
parent(s): 0e717c5bf424a7411030d625499485a821591830
committer: Kristian Nielsen
branch nick: server
timestamp: 2015-03-16 14:40:29 +0100
message:

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.

---
 mysql-test/suite/rpl/r/rpl_gtid_basic.result |   16 ++++++++++------
 mysql-test/suite/rpl/t/rpl_gtid_basic.test   |   13 +++++++++----
 sql/rpl_gtid.cc                              |    8 +++++---
 sql/sql_class.h                              |    4 ++--
 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 bdb965e..22f284d 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 307bbba..b6a4c7f 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 078ec74..1dc6a27 100644
--- a/sql/rpl_gtid.cc
+++ b/sql/rpl_gtid.cc
@@ -2011,7 +2011,7 @@ static int rpl_binlog_state_load_cb(rpl_gtid *gtid, void *data)
     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 @@ static int rpl_binlog_state_load_cb(rpl_gtid *gtid, void *data)
   {
     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 8871e6a..f7aa54b 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -739,8 +739,8 @@ enum killed_type
   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;


More information about the commits mailing list