Commit ef4d8db5 authored by Kristian Nielsen's avatar Kristian Nielsen

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.
parent 0e717c5b
......@@ -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
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment