[Commits] 93cc656: MDEV-6981: MASTER_GTID_WAIT status variables
Kristian Nielsen
knielsen at knielsen-hq.org
Wed Feb 4 16:42:09 EET 2015
revision-id: 93cc656527e1ecd094f5ce702e193ce6c9148d62
parent(s): bfe703a45888107936c184076eaead28b8b8a90a
committer: Kristian Nielsen
branch nick: server
timestamp: 2015-02-04 15:33:53 +0100
message:
MDEV-6981: MASTER_GTID_WAIT status variables
Implement three status variables:
master_gtid_wait_count (# of times called)
master_gtid_wait_timeouts (# of time it was called and timed out)
master_gtid_wait_time (time in microseconds waiting for results)
---
mysql-test/r/max_statement_time.result | 1 +
mysql-test/suite/rpl/r/rpl_gtid_basic.result | 48 ++++++++++++++++++++++++++
mysql-test/suite/rpl/t/rpl_gtid_basic.test | 25 +++++++++++++-
sql/mysqld.cc | 3 ++
sql/rpl_gtid.cc | 13 +++++++
sql/sql_class.h | 5 +++
6 files changed, 94 insertions(+), 1 deletion(-)
diff --git a/mysql-test/r/max_statement_time.result b/mysql-test/r/max_statement_time.result
index 38334c5..93c793b 100644
--- a/mysql-test/r/max_statement_time.result
+++ b/mysql-test/r/max_statement_time.result
@@ -87,6 +87,7 @@ SLEEP(2)
1
SHOW STATUS LIKE '%timeout%';
Variable_name Value
+Master_gtid_wait_timeouts 0
Ssl_default_timeout 0
Ssl_session_cache_timeouts 0
SET @@max_statement_time=0;
diff --git a/mysql-test/suite/rpl/r/rpl_gtid_basic.result b/mysql-test/suite/rpl/r/rpl_gtid_basic.result
index 465cc87..590b06f 100644
--- a/mysql-test/suite/rpl/r/rpl_gtid_basic.result
+++ b/mysql-test/suite/rpl/r/rpl_gtid_basic.result
@@ -202,6 +202,15 @@ a
1
Gtid_IO_Pos = '0-1-100'
*** Test @@LAST_GTID and MASTER_GTID_WAIT() ***
+SHOW STATUS LIKE 'Master_gtid_wait_count';
+Variable_name Value
+Master_gtid_wait_count 0
+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
DROP TABLE t1;
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
include/stop_slave.inc
@@ -231,6 +240,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 +289,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 floor(MASTER_GTID_WAIT_TIME / 1000) AS Master_gtid_wait_time_milliseconds;
+Master_gtid_wait_time_milliseconds
+0
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 floor(MASTER_GTID_WAIT_TIME / 100000) AS Master_gtid_wait_time_tenths_of_a_second;
+Master_gtid_wait_time_tenths_of_a_second
+5
KILL QUERY KILL_ID;
ERROR 70100: Query execution was interrupted
SET gtid_domain_id=2;
diff --git a/mysql-test/suite/rpl/t/rpl_gtid_basic.test b/mysql-test/suite/rpl/t/rpl_gtid_basic.test
index 19f90fc..ee7c4fd 100644
--- a/mysql-test/suite/rpl/t/rpl_gtid_basic.test
+++ b/mysql-test/suite/rpl/t/rpl_gtid_basic.test
@@ -206,6 +206,9 @@ SELECT * FROM t1;
--echo *** Test @@LAST_GTID and MASTER_GTID_WAIT() ***
--connection server_1
+SHOW STATUS LIKE 'Master_gtid_wait_count';
+SHOW STATUS LIKE 'Master_gtid_wait_timeouts';
+SHOW STATUS LIKE 'Master_gtid_wait_time';
DROP TABLE t1;
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
--save_master_pos
@@ -232,6 +235,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;
@@ -305,15 +312,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 floor($wait_time / 1000) AS Master_gtid_wait_time_milliseconds;
+
--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-0.6 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 floor($wait_time / 100000) AS Master_gtid_wait_time_tenths_of_a_second;
--replace_result $kill1_id KILL_ID
eval KILL QUERY $kill1_id;
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 423d07b..06319b3 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -8210,6 +8210,9 @@ int show_threadpool_idle_threads(THD *thd, SHOW_VAR *var, char *buff,
{"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_statement_time_exceeded", (char*) offsetof(STATUS_VAR, max_statement_time_exceeded), SHOW_LONG_STATUS},
{"Max_used_connections", (char*) &max_used_connections, SHOW_LONG},
{"Memory_used", (char*) &show_memory_used, SHOW_SIMPLE_FUNC},
diff --git a/sql/rpl_gtid.cc b/sql/rpl_gtid.cc
index e5620ec..3962e90 100644
--- a/sql/rpl_gtid.cc
+++ b/sql/rpl_gtid.cc
@@ -1865,10 +1865,14 @@ void rpl_binlog_state::free()
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)))
@@ -1876,6 +1880,8 @@ void rpl_binlog_state::free()
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)
{
@@ -1890,6 +1896,13 @@ void rpl_binlog_state::free()
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;
}
diff --git a/sql/sql_class.h b/sql/sql_class.h
index 1f80494..a766203 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -737,6 +737,11 @@ enum killed_type
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;
More information about the commits
mailing list