Commit 21a84e23 authored by Sujatha's avatar Sujatha

MDEV-16437: merge 5.7 P_S replication instrumentation and tables

Merge 'replication_applier_status' table.

This table captures SQL_THREAD status.

Replaced following column:
  - CHANNEL_NAME with CONNECTION_NAME
parent 4e6de585
...@@ -229,7 +229,7 @@ objects_summary_global_by_type 10 Dynamic ...@@ -229,7 +229,7 @@ objects_summary_global_by_type 10 Dynamic
performance_timers 10 Fixed performance_timers 10 Fixed
prepared_statements_instances 10 Dynamic prepared_statements_instances 10 Dynamic
replication_applier_configuration 10 Dynamic replication_applier_configuration 10 Dynamic
replication_applier_status 10 Fixed replication_applier_status 10 Dynamic
replication_applier_status_by_coordinator 10 Dynamic replication_applier_status_by_coordinator 10 Dynamic
replication_applier_status_by_worker 10 Dynamic replication_applier_status_by_worker 10 Dynamic
replication_connection_configuration 10 Dynamic replication_connection_configuration 10 Dynamic
......
...@@ -855,7 +855,7 @@ def performance_schema prepared_statements_instances SUM_NO_INDEX_USED 34 NULL N ...@@ -855,7 +855,7 @@ def performance_schema prepared_statements_instances SUM_NO_INDEX_USED 34 NULL N
def performance_schema prepared_statements_instances SUM_NO_GOOD_INDEX_USED 35 NULL NO bigint NULL NULL 20 0 NULL NULL NULL bigint(20) unsigned select,insert,update,references NEVER NULL def performance_schema prepared_statements_instances SUM_NO_GOOD_INDEX_USED 35 NULL NO bigint NULL NULL 20 0 NULL NULL NULL bigint(20) unsigned select,insert,update,references NEVER NULL
def performance_schema replication_applier_configuration CONNECTION_NAME 1 NULL NO varchar 256 768 NULL NULL NULL utf8 utf8_general_ci varchar(256) select,insert,update,references NEVER NULL def performance_schema replication_applier_configuration CONNECTION_NAME 1 NULL NO varchar 256 768 NULL NULL NULL utf8 utf8_general_ci varchar(256) select,insert,update,references NEVER NULL
def performance_schema replication_applier_configuration DESIRED_DELAY 2 NULL NO int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references NEVER NULL def performance_schema replication_applier_configuration DESIRED_DELAY 2 NULL NO int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references NEVER NULL
def performance_schema replication_applier_status 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_applier_status CONNECTION_NAME 1 NULL NO varchar 256 768 NULL NULL NULL utf8 utf8_general_ci varchar(256) select,insert,update,references NEVER NULL
def performance_schema replication_applier_status SERVICE_STATE 2 NULL NO enum 3 9 NULL NULL NULL utf8 utf8_general_ci enum('ON','OFF') select,insert,update,references NEVER NULL def performance_schema replication_applier_status SERVICE_STATE 2 NULL NO enum 3 9 NULL NULL NULL utf8 utf8_general_ci enum('ON','OFF') select,insert,update,references NEVER NULL
def performance_schema replication_applier_status REMAINING_DELAY 3 NULL YES int NULL NULL 10 0 NULL NULL NULL int(10) unsigned select,insert,update,references NEVER NULL def performance_schema replication_applier_status REMAINING_DELAY 3 NULL YES int NULL NULL 10 0 NULL NULL NULL int(10) unsigned select,insert,update,references NEVER NULL
def performance_schema replication_applier_status COUNT_TRANSACTIONS_RETRIES 4 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 COUNT_TRANSACTIONS_RETRIES 4 NULL NO bigint NULL NULL 20 0 NULL NULL NULL bigint(20) unsigned select,insert,update,references NEVER NULL
......
...@@ -59,6 +59,16 @@ let $status_var_comparsion= >; ...@@ -59,6 +59,16 @@ let $status_var_comparsion= >;
connection slave; connection slave;
SELECT COUNT(*) FROM t2; SELECT COUNT(*) FROM t2;
COMMIT; COMMIT;
--echo
--echo # Test that the performance schema coulumn shows > 0 values.
--echo
--let $assert_text= current number of retries should be more than the value saved before deadlock.
--let $assert_cond= [SELECT COUNT_TRANSACTIONS_RETRIES FROM performance_schema.replication_applier_status, COUNT_TRANSACTIONS_RETRIES, 1] > "$slave_retried_transactions"
--source include/assert.inc
source include/check_slave_is_running.inc;
sync_with_master; sync_with_master;
# Check the data # Check the data
......
...@@ -46,6 +46,11 @@ SELECT COUNT(*) FROM t2; ...@@ -46,6 +46,11 @@ SELECT COUNT(*) FROM t2;
COUNT(*) COUNT(*)
0 0
COMMIT; COMMIT;
# Test that the performance schema coulumn shows > 0 values.
include/assert.inc [current number of retries should be more than the value saved before deadlock.]
include/check_slave_is_running.inc
SELECT * FROM t1; SELECT * FROM t1;
a a
1 1
......
include/master-slave.inc
[connection master]
include/assert.inc [On master, the table should return an empty set.]
connection slave;
# Verify that SELECT works and produces an output similar to
# the corresponding field in SHOW SLAVE STATUS(SSS) in all scenarios.
# Verify that output is same as SSS on a fresh slave.
include/assert.inc [SSS shows Slave_SQL_Running as "Yes". So, Service_State from this PS table should be "ON".]
include/assert.inc [COUNT_TRANSACTION_RETRIES should be equal to Slave_retried_transactions.]
# Verify that the fields show the correct values after STOP SLAVE.
include/stop_slave.inc
include/assert.inc [SSS shows Slave_SQL_Running as "No". So, Service_State from this PS table should be "OFF".]
include/assert.inc [COUNT_TRANSACTION_RETRIES should be equal to Slave_retried_transactions.]
include/start_slave.inc
include/rpl_end.inc
# ==== Purpose ====
#
# This test script serves as the functionality testing for the table
# performance_schema.replication_applier_status. Test for ddl and dml
# operations is a part of the perfschema suite. The ddl/dml tests are named:
# 1) ddl_replication_applier_status.test and
# 2) dml_replication_applier_status.test.
#
# The follwing scenarios are tested in this script:
#
# - Verify that output is same as SSS on a fresh slave.
# - Verify that the value of this field is correct after STOP SLAVE.
# - Remaining delay is not tested.
# - Count_trnsaction is partially tested here making sure it can be queried.
# More testing in rpl/include/rpl_deadlock.test
#
# ==== Related Worklog ====
#
# MDEV-16437: merge 5.7 P_S replication instrumentation and tables
#
source include/master-slave.inc;
source include/have_binlog_format_mixed.inc;
let $assert_text= On master, the table should return an empty set.;
let $assert_cond= count(*) = 0 from performance_schema.replication_applier_status;
source include/assert.inc;
--connection slave
--echo
--echo # Verify that SELECT works and produces an output similar to
--echo # the corresponding field in SHOW SLAVE STATUS(SSS) in all scenarios.
--echo
--echo
--echo # Verify that output is same as SSS on a fresh slave.
--echo
let $sss_value= query_get_value(SHOW SLAVE STATUS, Slave_SQL_Running, 1);
let $ps_value= query_get_value(select Service_State from performance_schema.replication_applier_status, Service_State, 1);
let $assert_text= SSS shows Slave_SQL_Running as "Yes". So, Service_State from this PS table should be "ON".;
let $assert_cond= "$sss_value" = "Yes" AND "$ps_value"= "ON";
source include/assert.inc;
let $ss_value= query_get_value(SHOW STATUS LIKE 'Slave_retried_transactions', Value, 1);
let $ps_value= query_get_value(select count_transactions_retries from performance_schema.replication_applier_status, count_transactions_retries, 1);
let $assert_text= COUNT_TRANSACTION_RETRIES should be equal to Slave_retried_transactions.;
let $assert_cond= "$ps_value"= "$ss_value";
source include/assert.inc;
--echo
--echo # Verify that the fields show the correct values after STOP SLAVE.
--echo
source include/stop_slave.inc;
let $sss_value= query_get_value(SHOW SLAVE STATUS, Slave_SQL_Running, 1);
let $ps_value= query_get_value(select Service_State from performance_schema.replication_applier_status, Service_State, 1);
let $assert_text= SSS shows Slave_SQL_Running as "No". So, Service_State from this PS table should be "OFF".;
let $assert_cond= "$sss_value" = "No" AND "$ps_value"= "OFF";
source include/assert.inc;
let $ss_value= query_get_value(SHOW STATUS LIKE 'Slave_retried_transactions', Value, 1);
let $ps_value= query_get_value(select count_transactions_retries from performance_schema.replication_applier_status, count_transactions_retries, 1);
let $assert_text= COUNT_TRANSACTION_RETRIES should be equal to Slave_retried_transactions.;
let $assert_cond= "$ps_value"= "$ss_value";
source include/assert.inc;
source include/start_slave.inc;
source include/rpl_end.inc;
...@@ -55,7 +55,7 @@ table_replication_applier_status::m_share= ...@@ -55,7 +55,7 @@ table_replication_applier_status::m_share=
sizeof(pos_t), /* ref length */ sizeof(pos_t), /* ref length */
&m_table_lock, &m_table_lock,
{ C_STRING_WITH_LEN("CREATE TABLE replication_applier_status(" { C_STRING_WITH_LEN("CREATE TABLE replication_applier_status("
"CHANNEL_NAME CHAR(64) collate utf8_general_ci not null," "CONNECTION_NAME VARCHAR(256) collate utf8_general_ci not null,"
"SERVICE_STATE ENUM('ON','OFF') not null," "SERVICE_STATE ENUM('ON','OFF') not null,"
"REMAINING_DELAY INTEGER unsigned," "REMAINING_DELAY INTEGER unsigned,"
"COUNT_TRANSACTIONS_RETRIES BIGINT unsigned not null)") }, "COUNT_TRANSACTIONS_RETRIES BIGINT unsigned not null)") },
...@@ -140,16 +140,15 @@ void table_replication_applier_status::make_row(Master_info *mi) ...@@ -140,16 +140,15 @@ void table_replication_applier_status::make_row(Master_info *mi)
DBUG_ASSERT(mi != NULL); DBUG_ASSERT(mi != NULL);
m_row.channel_name_length= static_cast<uint>(mi->connection_name.length); m_row.connection_name_length= static_cast<uint>(mi->connection_name.length);
memcpy(m_row.channel_name, mi->connection_name.str, m_row.channel_name_length); memcpy(m_row.connection_name, mi->connection_name.str, m_row.connection_name_length);
//mysql_mutex_lock(&mi->rli->info_thd_lock); mysql_mutex_lock(&mi->rli.run_lock);
slave_sql_running_state= const_cast<char *> slave_sql_running_state= const_cast<char *>
(mi->rli.sql_driver_thd ? (mi->rli.sql_driver_thd ?
mi->rli.sql_driver_thd->get_proc_info() : ""); mi->rli.sql_driver_thd->get_proc_info() : "");
//mysql_mutex_unlock(&mi->rli->info_thd_lock); mysql_mutex_unlock(&mi->rli.run_lock);
mysql_mutex_lock(&mi->data_lock); mysql_mutex_lock(&mi->data_lock);
mysql_mutex_lock(&mi->rli.data_lock); mysql_mutex_lock(&mi->rli.data_lock);
...@@ -160,9 +159,9 @@ void table_replication_applier_status::make_row(Master_info *mi) ...@@ -160,9 +159,9 @@ void table_replication_applier_status::make_row(Master_info *mi)
m_row.service_state= PS_RPL_NO; m_row.service_state= PS_RPL_NO;
m_row.remaining_delay= 0; m_row.remaining_delay= 0;
if (slave_sql_running_state == stage_sql_thd_waiting_until_delay.m_name) if (slave_sql_running_state == Relay_log_info::state_delaying_string)
{ {
time_t t= my_time(0), sql_delay_end= 0; //mi->rli.>get_sql_delay_end(); time_t t= my_time(0), sql_delay_end= mi->rli.get_sql_delay_end();
m_row.remaining_delay= (uint)(t < sql_delay_end ? m_row.remaining_delay= (uint)(t < sql_delay_end ?
sql_delay_end - t : 0); sql_delay_end - t : 0);
m_row.remaining_delay_is_set= true; m_row.remaining_delay_is_set= true;
...@@ -197,8 +196,8 @@ int table_replication_applier_status::read_row_values(TABLE *table, ...@@ -197,8 +196,8 @@ int table_replication_applier_status::read_row_values(TABLE *table,
{ {
switch(f->field_index) switch(f->field_index)
{ {
case 0: /**channel_name*/ case 0: /**connection_name*/
set_field_char_utf8(f, m_row.channel_name, m_row.channel_name_length); set_field_varchar_utf8(f, m_row.connection_name, m_row.connection_name_length);
break; break;
case 1: /* service_state */ case 1: /* service_state */
set_field_enum(f, m_row.service_state); set_field_enum(f, m_row.service_state);
......
...@@ -34,8 +34,6 @@ ...@@ -34,8 +34,6 @@
#include "pfs_engine_table.h" #include "pfs_engine_table.h"
#include "rpl_mi.h" #include "rpl_mi.h"
#include "mysql_com.h" #include "mysql_com.h"
//#include "rpl_msr.h"
//#include "rpl_info.h" /*CHANNEL_NAME_LENGTH*/
#include "my_thread.h" #include "my_thread.h"
class Master_info; class Master_info;
...@@ -56,8 +54,8 @@ enum enum_rpl_yes_no { ...@@ -56,8 +54,8 @@ enum enum_rpl_yes_no {
/** A row in the table. */ /** A row in the table. */
struct st_row_applier_status { struct st_row_applier_status {
char channel_name[CHANNEL_NAME_LENGTH]; char connection_name[CHANNEL_NAME_LENGTH];
uint channel_name_length; uint connection_name_length;
enum_rpl_yes_no service_state; enum_rpl_yes_no service_state;
uint remaining_delay; uint remaining_delay;
bool remaining_delay_is_set; bool remaining_delay_is_set;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment