summaryrefslogtreecommitdiff
path: root/sql/mysqld.cc
diff options
context:
space:
mode:
authorAndrei Elkin <aelkin@mysql.com>2009-09-29 14:16:23 +0300
committerAndrei Elkin <aelkin@mysql.com>2009-09-29 14:16:23 +0300
commit5983785ef4b04b865ea1d78c8d452642913a83f3 (patch)
treef79e672485606b6da384195da6a4c1c6729ed362 /sql/mysqld.cc
parent5d2f79def9b67dd5400411070d47f8180ceb072b (diff)
downloadmariadb-git-5983785ef4b04b865ea1d78c8d452642913a83f3.tar.gz
WL#342 heartbeat
backporting from 6.0 code base to 5.1.
Diffstat (limited to 'sql/mysqld.cc')
-rw-r--r--sql/mysqld.cc36
1 files changed, 36 insertions, 0 deletions
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 7e9eb6e7291..4bbb49f47ff 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -7068,6 +7068,40 @@ static int show_slave_retried_trans(THD *thd, SHOW_VAR *var, char *buff)
pthread_mutex_unlock(&LOCK_active_mi);
return 0;
}
+
+static int show_slave_received_heartbeats(THD *thd, SHOW_VAR *var, char *buff)
+{
+ pthread_mutex_lock(&LOCK_active_mi);
+ if (active_mi)
+ {
+ var->type= SHOW_LONGLONG;
+ var->value= buff;
+ pthread_mutex_lock(&active_mi->rli.data_lock);
+ *((longlong *)buff)= active_mi->received_heartbeats;
+ pthread_mutex_unlock(&active_mi->rli.data_lock);
+ }
+ else
+ var->type= SHOW_UNDEF;
+ pthread_mutex_unlock(&LOCK_active_mi);
+ return 0;
+}
+
+static int show_heartbeat_period(THD *thd, SHOW_VAR *var, char *buff)
+{
+ pthread_mutex_lock(&LOCK_active_mi);
+ if (active_mi)
+ {
+ var->type= SHOW_CHAR;
+ var->value= buff;
+ my_sprintf(buff, (buff, "%.3f",active_mi->heartbeat_period));
+ }
+ else
+ var->type= SHOW_UNDEF;
+ pthread_mutex_unlock(&LOCK_active_mi);
+ return 0;
+}
+
+
#endif /* HAVE_REPLICATION */
static int show_open_tables(THD *thd, SHOW_VAR *var, char *buff)
@@ -7432,6 +7466,8 @@ SHOW_VAR status_vars[]= {
{"Slave_open_temp_tables", (char*) &slave_open_temp_tables, SHOW_LONG},
#ifdef HAVE_REPLICATION
{"Slave_retried_transactions",(char*) &show_slave_retried_trans, SHOW_FUNC},
+ {"Slave_heartbeat_period", (char*) &show_heartbeat_period, SHOW_FUNC},
+ {"Slave_received_heartbeats",(char*) &show_slave_received_heartbeats, SHOW_FUNC},
{"Slave_running", (char*) &show_slave_running, SHOW_FUNC},
#endif
{"Slow_launch_threads", (char*) &slow_launch_threads, SHOW_LONG},