Commit fa5809ce authored by Daniel Black's avatar Daniel Black

Add Master_gtid_wait_{count,time,timeouts} status

MASTER_GTID_WAIT function needs some status to evaluate its use.

master_gtid_wait_count indicates how many times the function is called.
master_gtid_wait_time indicates how much time in microseconds occurred
waiting (or timing out)
master_gtid_timeouts indicates how many time times this function timed
out rather than all successful gtids events being available.
parent d61573d3
......@@ -231,6 +231,15 @@ NULL
SELECT master_gtid_wait('', NULL);
master_gtid_wait('', NULL)
0
SHOW STATUS LIKE 'Master_gtid_wait_count';
Variable_name Value
Master_gtid_wait_count 1
SHOW STATUS LIKE 'Master_gtid_wait_timeouts';
Variable_name Value
Master_gtid_wait_timeouts 0
SHOW STATUS LIKE 'Master_gtid_wait_time';
Variable_name Value
Master_gtid_wait_time 0
SELECT master_gtid_wait(@pos, 0.5);
master_gtid_wait(@pos, 0.5)
-1
......@@ -271,13 +280,43 @@ SELECT master_gtid_wait('2-1-5');
SELECT master_gtid_wait('2-1-10');
SELECT master_gtid_wait('2-1-5,1-1-4,0-1-110');
SELECT master_gtid_wait('2-1-2');
SHOW STATUS LIKE 'Master_gtid_wait_timeouts';
Variable_name Value
Master_gtid_wait_timeouts 0
SHOW STATUS LIKE 'Master_gtid_wait_count';
Variable_name Value
Master_gtid_wait_count 3
SELECT master_gtid_wait('1-1-1');
master_gtid_wait('1-1-1')
0
SHOW STATUS LIKE 'Master_gtid_wait_timeouts';
Variable_name Value
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
SELECT master_gtid_wait('0-1-109');
SHOW STATUS LIKE 'Master_gtid_wait_timeouts';
Variable_name Value
Master_gtid_wait_timeouts 0
SHOW STATUS LIKE 'Master_gtid_wait_count';
Variable_name Value
Master_gtid_wait_count 4
SELECT master_gtid_wait('2-1-2', 0.5);
master_gtid_wait('2-1-2', 0.5)
-1
SHOW STATUS LIKE 'Master_gtid_wait_timeouts';
Variable_name Value
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
KILL QUERY KILL_ID;
ERROR 70100: Query execution was interrupted
SET gtid_domain_id=2;
......@@ -433,6 +472,5 @@ a
31
32
33
34
DROP TABLE t1;
include/rpl_end.inc
......@@ -232,6 +232,10 @@ eval SET @pos= '$pos';
SELECT master_gtid_wait(NULL);
# Check empty argument returns immediately.
SELECT master_gtid_wait('', NULL);
# Check this gets counted
SHOW STATUS LIKE 'Master_gtid_wait_count';
SHOW STATUS LIKE 'Master_gtid_wait_timeouts';
SHOW STATUS LIKE 'Master_gtid_wait_time';
# Let's check that we get a timeout
SELECT master_gtid_wait(@pos, 0.5);
SELECT * FROM t1 ORDER BY a;
......@@ -276,7 +280,7 @@ SELECT master_gtid_wait('1-1-1', 0);
send SELECT master_gtid_wait('2-1-1,1-1-4,0-1-110');
--connect (s2,127.0.0.1,root,,test,$SERVER_MYPORT_2,)
# This will time out.
# This will time out. No event 0-1-1000 exists
send SELECT master_gtid_wait('0-1-1000', 0.5);
--connect (s3,127.0.0.1,root,,test,$SERVER_MYPORT_2,)
......@@ -305,15 +309,31 @@ 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.
# This one completes immediately ( < 1 ms).
SHOW STATUS LIKE 'Master_gtid_wait_timeouts';
SHOW STATUS LIKE 'Master_gtid_wait_count';
SELECT master_gtid_wait('1-1-1');
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;
--connect (s10,127.0.0.1,root,,test,$SERVER_MYPORT_2,)
send SELECT master_gtid_wait('0-1-109');
--connection server_2
# This one should time out.
SHOW STATUS LIKE 'Master_gtid_wait_timeouts';
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;
--replace_result $kill1_id KILL_ID
eval KILL QUERY $kill1_id;
......
......@@ -7879,6 +7879,9 @@ SHOW_VAR status_vars[]= {
{"Handler_write", (char*) offsetof(STATUS_VAR, ha_write_count), SHOW_LONG_STATUS},
{"Key", (char*) &show_default_keycache, SHOW_FUNC},
{"Last_query_cost", (char*) offsetof(STATUS_VAR, last_query_cost), SHOW_DOUBLE_STATUS},
{"Master_gtid_wait_count", (char*) offsetof(STATUS_VAR, master_gtid_wait_count), SHOW_LONGLONG_STATUS},
{"Master_gtid_wait_timeouts", (char*) offsetof(STATUS_VAR, master_gtid_wait_timeouts), SHOW_LONGLONG_STATUS},
{"Master_gtid_wait_time", (char*) offsetof(STATUS_VAR, master_gtid_wait_time), SHOW_LONGLONG_STATUS},
{"Max_used_connections", (char*) &max_used_connections, SHOW_LONG},
{"Memory_used", (char*) offsetof(STATUS_VAR, memory_used), SHOW_LONGLONG_STATUS},
{"Not_flushed_delayed_rows", (char*) &delayed_rows_in_use, SHOW_LONG_NOFLUSH},
......
......@@ -1911,10 +1911,14 @@ gtid_waiting::wait_for_pos(THD *thd, String *gtid_str, longlong timeout_us)
rpl_gtid *wait_pos;
uint32 count, i;
struct timespec wait_until, *wait_until_ptr;
ulonglong before;
/* Wait for the empty position returns immediately. */
if (gtid_str->length() == 0)
{
status_var_increment(thd->status_var.master_gtid_wait_count);
return 0;
}
if (!(wait_pos= gtid_parse_string_to_list(gtid_str->ptr(), gtid_str->length(),
&count)))
......@@ -1922,6 +1926,8 @@ gtid_waiting::wait_for_pos(THD *thd, String *gtid_str, longlong timeout_us)
my_error(ER_INCORRECT_GTID_STATE, MYF(0));
return 1;
}
status_var_increment(thd->status_var.master_gtid_wait_count);
before = microsecond_interval_timer();
if (timeout_us >= 0)
{
......@@ -1936,6 +1942,13 @@ gtid_waiting::wait_for_pos(THD *thd, String *gtid_str, longlong timeout_us)
if ((err= wait_for_gtid(thd, &wait_pos[i], wait_until_ptr)))
break;
}
switch (err)
{
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);
}
my_free(wait_pos);
return err;
}
......
......@@ -726,6 +726,11 @@ typedef struct system_status_var
ulong feature_trigger; /* +1 opening a table with triggers */
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_count;
ulong empty_queries;
ulong access_denied_errors;
ulong lost_connections;
......
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