mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 20:12:31 +01:00
Merge branch 'mdev-6981-master_gtid_wait-status-variables' of https://github.com/openquery/mariadb-server into danblack
Conflicts: sql/mysqld.cc
This commit is contained in:
commit
0e717c5bf4
5 changed files with 82 additions and 3 deletions
|
@ -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;
|
||||
|
|
|
@ -8221,6 +8221,9 @@ SHOW_VAR status_vars[]= {
|
|||
{"Key", (char*) &show_default_keycache, SHOW_FUNC},
|
||||
{"Last_query_cost", (char*) offsetof(STATUS_VAR, last_query_cost), SHOW_DOUBLE_STATUS},
|
||||
{"Max_statement_time_exceeded", (char*) offsetof(STATUS_VAR, max_statement_time_exceeded), SHOW_LONG_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*) &show_memory_used, SHOW_SIMPLE_FUNC},
|
||||
{"Not_flushed_delayed_rows", (char*) &delayed_rows_in_use, SHOW_LONG_NOFLUSH},
|
||||
|
|
|
@ -1995,10 +1995,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)))
|
||||
|
@ -2006,6 +2010,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)
|
||||
{
|
||||
|
@ -2020,6 +2026,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;
|
||||
}
|
||||
|
|
|
@ -738,6 +738,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;
|
||||
|
|
Loading…
Reference in a new issue