diff options
author | Sujatha <sujatha.sivakumar@mariadb.com> | 2021-04-08 16:09:09 +0530 |
---|---|---|
committer | Sujatha <sujatha.sivakumar@mariadb.com> | 2021-04-08 17:19:51 +0530 |
commit | 036ee61246ea4540a10b425363e5379bd592bc1f (patch) | |
tree | b46efc1d6a634f45b28638f36efa146509ec8c40 | |
parent | 94f1d0f84d58535e6f14a33b91daf7f47da4a29e (diff) | |
download | mariadb-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 |
---------------------------------------------------------------------------
-rw-r--r-- | mysql-test/suite/perfschema/r/table_schema.result | 2 | ||||
-rw-r--r-- | mysql-test/suite/rpl/r/rpl_parallel_retry.result | 15 | ||||
-rw-r--r-- | mysql-test/suite/rpl/r/rpl_perfschema_applier_status_by_worker.result | 3 | ||||
-rw-r--r-- | mysql-test/suite/rpl/t/rpl_parallel_retry.test | 46 | ||||
-rw-r--r-- | mysql-test/suite/rpl/t/rpl_perfschema_applier_status_by_worker.test | 8 | ||||
-rw-r--r-- | sql/rpl_parallel.cc | 7 | ||||
-rw-r--r-- | sql/rpl_parallel.h | 23 | ||||
-rw-r--r-- | storage/perfschema/table_replication_applier_status_by_worker.cc | 19 | ||||
-rw-r--r-- | storage/perfschema/table_replication_applier_status_by_worker.h | 2 |
9 files changed, 93 insertions, 32 deletions
diff --git a/mysql-test/suite/perfschema/r/table_schema.result b/mysql-test/suite/perfschema/r/table_schema.result index babee1d624c..8abbdab8352 100644 --- a/mysql-test/suite/perfschema/r/table_schema.result +++ b/mysql-test/suite/perfschema/r/table_schema.result @@ -872,6 +872,8 @@ def performance_schema replication_applier_status_by_worker LAST_SEEN_TRANSACTIO def performance_schema replication_applier_status_by_worker LAST_ERROR_NUMBER 5 NULL NO int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references NEVER NULL def performance_schema replication_applier_status_by_worker LAST_ERROR_MESSAGE 6 NULL NO varchar 1024 3072 NULL NULL NULL utf8 utf8_general_ci varchar(1024) select,insert,update,references NEVER NULL def performance_schema replication_applier_status_by_worker LAST_ERROR_TIMESTAMP 7 current_timestamp() NO timestamp NULL NULL NULL NULL 0 NULL NULL timestamp on update current_timestamp() select,insert,update,references NEVER NULL +def performance_schema replication_applier_status_by_worker WORKER_IDLE_TIME 8 NULL NO bigint NULL NULL 20 0 NULL NULL NULL bigint(20) unsigned select,insert,update,references NEVER NULL +def performance_schema replication_applier_status_by_worker LAST_TRANS_RETRY_COUNT 9 NULL NO int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references NEVER NULL def performance_schema replication_connection_configuration CHANNEL_NAME 1 NULL NO char 64 192 NULL NULL NULL utf8 utf8_general_ci char(64) select,insert,update,references NEVER NULL def performance_schema replication_connection_configuration HOST 2 NULL NO char 60 180 NULL NULL NULL utf8 utf8_bin char(60) select,insert,update,references NEVER NULL def performance_schema replication_connection_configuration PORT 3 NULL NO int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references NEVER NULL diff --git a/mysql-test/suite/rpl/r/rpl_parallel_retry.result b/mysql-test/suite/rpl/r/rpl_parallel_retry.result index 381fec649ff..29657a13eb7 100644 --- a/mysql-test/suite/rpl/r/rpl_parallel_retry.result +++ b/mysql-test/suite/rpl/r/rpl_parallel_retry.result @@ -49,8 +49,7 @@ SET @old_dbug= @@GLOBAL.debug_dbug; SET GLOBAL debug_dbug="+d,rpl_parallel_simulate_temp_err_gtid_0_x_100"; include/start_slave.inc SET GLOBAL debug_dbug=@old_dbug; -retries -1 +include/assert.inc [Performance Schema retries should match with actual retries] SELECT * FROM t1 ORDER BY a; a b 1 2 @@ -82,8 +81,7 @@ SET @old_dbug= @@GLOBAL.debug_dbug; SET GLOBAL debug_dbug="+d,rpl_parallel_simulate_temp_err_gtid_0_x_100,rpl_parallel_simulate_double_temp_err_gtid_0_x_100"; include/start_slave.inc SET GLOBAL debug_dbug=@old_dbug; -retries -2 +include/assert.inc [Performance Schema retries should match with actual retries] SELECT * FROM t1 ORDER BY a; a b 1 3 @@ -179,8 +177,7 @@ SET @old_dbug= @@GLOBAL.debug_dbug; SET GLOBAL debug_dbug="+d,rpl_parallel_simulate_temp_err_gtid_0_x_100"; include/start_slave.inc SET GLOBAL debug_dbug=@old_dbug; -retries -1 +include/assert.inc [Performance Schema retries should match with actual retries] SELECT * FROM t1 WHERE a >= 10 ORDER BY a; a b 10 4 @@ -224,8 +221,7 @@ SET @old_dbug= @@GLOBAL.debug_dbug; SET GLOBAL debug_dbug="+d,rpl_parallel_simulate_temp_err_xid"; include/start_slave.inc SET GLOBAL debug_dbug=@old_dbug; -retries -1 +include/assert.inc [Performance Schema retries should match with actual retries] SELECT * FROM t1 WHERE a >= 100 ORDER BY a; a b 100 0 @@ -323,8 +319,7 @@ SET debug_sync='now WAIT_FOR t3_waiting'; SET debug_sync='now SIGNAL t1_start'; SET GLOBAL debug_dbug=@old_dbug; SET debug_sync='RESET'; -retries -1 +include/assert.inc [Performance Schema retries should match with actual retries] SELECT * FROM t3 ORDER BY a; a b 1 NULL diff --git a/mysql-test/suite/rpl/r/rpl_perfschema_applier_status_by_worker.result b/mysql-test/suite/rpl/r/rpl_perfschema_applier_status_by_worker.result index 25edbe716e2..85f7d52dff7 100644 --- a/mysql-test/suite/rpl/r/rpl_perfschema_applier_status_by_worker.result +++ b/mysql-test/suite/rpl/r/rpl_perfschema_applier_status_by_worker.result @@ -28,6 +28,9 @@ include/assert.inc [Value returned by SSS and PS table for Last_Error_Number sho include/assert.inc [Value returned by SSS and PS table for Last_Error_Message should both be empty.] include/assert.inc [Value returned by PS table for Last_Error_Timestamp should be 0000-00-00 00:00:00.] connection master; +connection slave; +include/assert.inc [Value returned by PS table for worker_idle_time should be >= 1] +connection master; DROP TABLE t1; connection slave; STOP SLAVE 'slave1'; diff --git a/mysql-test/suite/rpl/t/rpl_parallel_retry.test b/mysql-test/suite/rpl/t/rpl_parallel_retry.test index 0449995621a..048c6e1df9b 100644 --- a/mysql-test/suite/rpl/t/rpl_parallel_retry.test +++ b/mysql-test/suite/rpl/t/rpl_parallel_retry.test @@ -68,9 +68,13 @@ let $old_retry= query_get_value(SHOW STATUS LIKE 'Slave_retried_transactions', V --sync_with_master SET GLOBAL debug_dbug=@old_dbug; let $new_retry= query_get_value(SHOW STATUS LIKE 'Slave_retried_transactions', Value, 1); ---disable_query_log -eval SELECT $new_retry - $old_retry AS retries; ---enable_query_log +let $ps_value= query_get_value(select last_trans_retry_count from + performance_schema.replication_applier_status_by_worker where + last_trans_retry_count > 0, last_trans_retry_count, 1); +let $assert_text= Performance Schema retries should match with actual retries; +let $assert_cond= "$ps_value" = $new_retry - $old_retry; +source include/assert.inc; + SELECT * FROM t1 ORDER BY a; @@ -100,9 +104,12 @@ let $old_retry= query_get_value(SHOW STATUS LIKE 'Slave_retried_transactions', V --sync_with_master SET GLOBAL debug_dbug=@old_dbug; let $new_retry= query_get_value(SHOW STATUS LIKE 'Slave_retried_transactions', Value, 1); ---disable_query_log -eval SELECT $new_retry - $old_retry AS retries; ---enable_query_log +let $ps_value= query_get_value(select last_trans_retry_count from + performance_schema.replication_applier_status_by_worker where + last_trans_retry_count > 0, last_trans_retry_count, 1); +let $assert_text= Performance Schema retries should match with actual retries; +let $assert_cond= "$ps_value" = $new_retry - $old_retry; +source include/assert.inc; SELECT * FROM t1 ORDER BY a; @@ -187,9 +194,12 @@ let $old_retry= query_get_value(SHOW STATUS LIKE 'Slave_retried_transactions', V --sync_with_master SET GLOBAL debug_dbug=@old_dbug; let $new_retry= query_get_value(SHOW STATUS LIKE 'Slave_retried_transactions', Value, 1); ---disable_query_log -eval SELECT $new_retry - $old_retry AS retries; ---enable_query_log +let $ps_value= query_get_value(select last_trans_retry_count from + performance_schema.replication_applier_status_by_worker where + last_trans_retry_count > 0, last_trans_retry_count, 1); +let $assert_text= Performance Schema retries should match with actual retries; +let $assert_cond= "$ps_value" = $new_retry - $old_retry; +source include/assert.inc; SELECT * FROM t1 WHERE a >= 10 ORDER BY a; SELECT a, LENGTH(b) FROM t2 ORDER BY a; @@ -235,9 +245,12 @@ let $old_retry= query_get_value(SHOW STATUS LIKE 'Slave_retried_transactions', V --sync_with_master SET GLOBAL debug_dbug=@old_dbug; let $new_retry= query_get_value(SHOW STATUS LIKE 'Slave_retried_transactions', Value, 1); ---disable_query_log -eval SELECT $new_retry - $old_retry AS retries; ---enable_query_log +let $ps_value= query_get_value(select last_trans_retry_count from + performance_schema.replication_applier_status_by_worker where + last_trans_retry_count > 0, last_trans_retry_count, 1); +let $assert_text= Performance Schema retries should match with actual retries; +let $assert_cond= "$ps_value" = $new_retry - $old_retry; +source include/assert.inc; SELECT * FROM t1 WHERE a >= 100 ORDER BY a; # Stop the SQL thread. When the bug was there to give the incorrect relay log @@ -365,9 +378,12 @@ SET debug_sync='now SIGNAL t1_start'; SET GLOBAL debug_dbug=@old_dbug; SET debug_sync='RESET'; let $new_retry= query_get_value(SHOW STATUS LIKE 'Slave_retried_transactions', Value, 1); ---disable_query_log -eval SELECT $new_retry - $old_retry >= 1 AS retries; ---enable_query_log +let $ps_value= query_get_value(select last_trans_retry_count from + performance_schema.replication_applier_status_by_worker where + last_trans_retry_count > 0, last_trans_retry_count, 1); +let $assert_text= Performance Schema retries should match with actual retries; +let $assert_cond= "$ps_value" = $new_retry - $old_retry; +source include/assert.inc; SELECT * FROM t3 ORDER BY a; diff --git a/mysql-test/suite/rpl/t/rpl_perfschema_applier_status_by_worker.test b/mysql-test/suite/rpl/t/rpl_perfschema_applier_status_by_worker.test index 50325985efe..b59ab826bcc 100644 --- a/mysql-test/suite/rpl/t/rpl_perfschema_applier_status_by_worker.test +++ b/mysql-test/suite/rpl/t/rpl_perfschema_applier_status_by_worker.test @@ -114,6 +114,14 @@ let $assert_cond= "$ps_value" = "0000-00-00 00:00:00"; source include/assert.inc; --connection master +sleep 1; +--connection slave +let $ps_value= query_get_value(select worker_idle_time from performance_schema.replication_applier_status_by_worker, worker_idle_time, 1); +let $assert_text= Value returned by PS table for worker_idle_time should be >= 1; +let $assert_cond= "$ps_value" >= "1"; +source include/assert.inc; + +--connection master DROP TABLE t1; --save_master_pos 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) diff --git a/storage/perfschema/table_replication_applier_status_by_worker.cc b/storage/perfschema/table_replication_applier_status_by_worker.cc index 1cebeae0fc7..3b6ac4031cd 100644 --- a/storage/perfschema/table_replication_applier_status_by_worker.cc +++ b/storage/perfschema/table_replication_applier_status_by_worker.cc @@ -58,7 +58,9 @@ table_replication_applier_status_by_worker::m_share= "LAST_SEEN_TRANSACTION CHAR(57) not null," "LAST_ERROR_NUMBER INTEGER not null," "LAST_ERROR_MESSAGE VARCHAR(1024) not null," - "LAST_ERROR_TIMESTAMP TIMESTAMP(0) not null)") }, + "LAST_ERROR_TIMESTAMP TIMESTAMP(0) not null," + "WORKER_IDLE_TIME BIGINT UNSIGNED not null," + "LAST_TRANS_RETRY_COUNT INTEGER not null)") }, false /* perpetual */ }; @@ -153,6 +155,7 @@ void table_replication_applier_status_by_worker::make_row(rpl_parallel_thread *r if (m_row.channel_name_length) memcpy(m_row.channel_name, rpt->channel_name, m_row.channel_name_length); + m_row.thread_id_is_null= true; if (rpt->running) { PSI_thread *psi= thd_get_psi(rpt->thd); @@ -162,14 +165,10 @@ void table_replication_applier_status_by_worker::make_row(rpl_parallel_thread *r m_row.thread_id= pfs->m_thread_internal_id; m_row.thread_id_is_null= false; } - else - m_row.thread_id_is_null= true; } - else - m_row.thread_id_is_null= true; if ((gtid.seq_no > 0 && - !rpl_slave_state_tostring_helper(&str, >id, &first))) + !rpl_slave_state_tostring_helper(&str, >id, &first))) { strmake(m_row.last_seen_transaction,str.ptr(), str.length()); m_row.last_seen_transaction_length= str.length(); @@ -197,6 +196,8 @@ void table_replication_applier_status_by_worker::make_row(rpl_parallel_thread *r m_row.last_error_timestamp= rpt->last_error_timestamp; } + m_row.last_trans_retry_count= rpt->last_trans_retry_count; + m_row.worker_idle_time= rpt->get_worker_idle_time(); m_row_exists= true; } @@ -242,6 +243,12 @@ int table_replication_applier_status_by_worker case 6: /*last_error_timestamp*/ set_field_timestamp(f, m_row.last_error_timestamp); break; + case 7: /*worker_idle_time*/ + set_field_ulonglong(f, m_row.worker_idle_time); + break; + case 8: /*last_trans_retry_count*/ + set_field_ulong(f, m_row.last_trans_retry_count); + break; default: DBUG_ASSERT(false); } diff --git a/storage/perfschema/table_replication_applier_status_by_worker.h b/storage/perfschema/table_replication_applier_status_by_worker.h index 44c097b288f..5aacf053fea 100644 --- a/storage/perfschema/table_replication_applier_status_by_worker.h +++ b/storage/perfschema/table_replication_applier_status_by_worker.h @@ -68,6 +68,8 @@ struct st_row_worker { char last_error_message[MAX_SLAVE_ERRMSG]; uint last_error_message_length; ulonglong last_error_timestamp; + ulonglong worker_idle_time; + ulong last_trans_retry_count; }; /** |