summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorSujatha <sujatha.sivakumar@mariadb.com>2021-04-08 16:09:09 +0530
committerSujatha <sujatha.sivakumar@mariadb.com>2021-04-08 17:19:51 +0530
commit036ee61246ea4540a10b425363e5379bd592bc1f (patch)
treeb46efc1d6a634f45b28638f36efa146509ec8c40 /sql
parent94f1d0f84d58535e6f14a33b91daf7f47da4a29e (diff)
downloadmariadb-git-036ee61246ea4540a10b425363e5379bd592bc1f.tar.gz
MDEV-20220: Merge 5.7 P_S replication table 'replication_applier_status_by_worker
Step2: ===== Add two extra columns mentioned below. --------------------------------------------------------------------------- |Column Name: | Description: | |-------------------------------------------------------------------------| | | | |WORKER_IDLE_TIME | Total idle time in seconds that the worker | | | thread has spent waiting for work from | | | co-ordinator thread | | | | |LAST_TRANS_RETRY_COUNT | Total number of retries attempted by last | | | transaction | ---------------------------------------------------------------------------
Diffstat (limited to 'sql')
-rw-r--r--sql/rpl_parallel.cc7
-rw-r--r--sql/rpl_parallel.h23
2 files changed, 29 insertions, 1 deletions
diff --git a/sql/rpl_parallel.cc b/sql/rpl_parallel.cc
index d1ca1c1bf6f..44fba4e30e7 100644
--- a/sql/rpl_parallel.cc
+++ b/sql/rpl_parallel.cc
@@ -799,6 +799,7 @@ do_retry:
mysql_mutex_lock(&rli->data_lock);
++rli->retried_trans;
+ ++rpt->last_trans_retry_count;
statistic_increment(slave_retried_transactions, LOCK_status);
mysql_mutex_unlock(&rli->data_lock);
@@ -1125,6 +1126,7 @@ handle_rpl_parallel_thread(void *arg)
uint wait_count= 0;
rpl_parallel_thread::queued_event *qev, *next_qev;
+ rpt->start_time_tracker();
thd->ENTER_COND(&rpt->COND_rpl_thread, &rpt->LOCK_rpl_thread,
&stage_waiting_for_work_from_sql_thread, &old_stage);
/*
@@ -1148,6 +1150,7 @@ handle_rpl_parallel_thread(void *arg)
}
rpt->dequeue1(events);
thd->EXIT_COND(&old_stage);
+ rpt->add_to_worker_idle_time_and_reset();
more_events:
for (qev= events; qev; qev= next_qev)
@@ -1193,6 +1196,7 @@ handle_rpl_parallel_thread(void *arg)
/* Handle a new event group, which will be initiated by a GTID event. */
if ((event_type= qev->ev->get_type_code()) == GTID_EVENT)
{
+ rpt->last_trans_retry_count= 0;
rpt->last_seen_gtid= rgi->current_gtid;
rpt->channel_name_length= (uint)rgi->rli->mi->connection_name.length;
if (rpt->channel_name_length)
@@ -2015,7 +2019,8 @@ rpl_parallel_thread::loc_free_gco(group_commit_orderer *gco)
rpl_parallel_thread::rpl_parallel_thread()
- : channel_name_length(0), last_error_number(0), last_error_timestamp(0)
+ : channel_name_length(0), last_error_number(0), last_error_timestamp(0),
+ worker_idle_time(0), last_trans_retry_count(0), start_time(0)
{
}
diff --git a/sql/rpl_parallel.h b/sql/rpl_parallel.h
index 49e245176ff..4f7bd49120a 100644
--- a/sql/rpl_parallel.h
+++ b/sql/rpl_parallel.h
@@ -167,6 +167,29 @@ struct rpl_parallel_thread {
int last_error_number;
char last_error_message[MAX_SLAVE_ERRMSG];
ulonglong last_error_timestamp;
+ ulonglong worker_idle_time;
+ ulong last_trans_retry_count;
+ ulonglong start_time;
+ void start_time_tracker()
+ {
+ start_time= microsecond_interval_timer();
+ }
+ ulonglong compute_time_lapsed()
+ {
+ return (ulonglong)((microsecond_interval_timer() - start_time) / 1000000.0);
+ }
+ void add_to_worker_idle_time_and_reset()
+ {
+ worker_idle_time+= compute_time_lapsed();
+ start_time=0;
+ }
+ ulonglong get_worker_idle_time()
+ {
+ if (start_time)
+ return compute_time_lapsed();
+ else
+ return worker_idle_time;
+ }
void enqueue(queued_event *qev)
{
if (last_in_queue)