From 036ee61246ea4540a10b425363e5379bd592bc1f Mon Sep 17 00:00:00 2001 From: Sujatha Date: Thu, 8 Apr 2021 16:09:09 +0530 Subject: 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 | --------------------------------------------------------------------------- --- sql/rpl_parallel.cc | 7 ++++++- sql/rpl_parallel.h | 23 +++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) (limited to 'sql') 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) -- cgit v1.2.1