summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSujatha <sujatha.sivakumar@mariadb.com>2020-11-30 13:22:32 +0530
committerSujatha <sujatha.sivakumar@mariadb.com>2020-11-30 13:22:32 +0530
commit21a84e23cf35a478912db4c1ccef2061fbf17c37 (patch)
treeb6f53d1bde8e7d0f4314243efd1b1e2fe81b8424
parent4e6de585ff7ce334fe5a36efd730460d0be8ff4d (diff)
downloadmariadb-git-bb-10.6-MDEV-16437.tar.gz
MDEV-16437: merge 5.7 P_S replication instrumentation and tablesbb-10.6-MDEV-16437
Merge 'replication_applier_status' table. This table captures SQL_THREAD status. Replaced following column: - CHANNEL_NAME with CONNECTION_NAME
-rw-r--r--mysql-test/suite/perfschema/r/information_schema.result2
-rw-r--r--mysql-test/suite/perfschema/r/table_schema.result2
-rw-r--r--mysql-test/suite/rpl/include/rpl_deadlock.test10
-rw-r--r--mysql-test/suite/rpl/r/rpl_deadlock_innodb.result5
-rw-r--r--mysql-test/suite/rpl/r/rpl_perfschema_applier_status.result21
-rw-r--r--mysql-test/suite/rpl/t/rpl_perfschema_applier_status.test72
-rw-r--r--storage/perfschema/table_replication_applier_status.cc19
-rw-r--r--storage/perfschema/table_replication_applier_status.h6
8 files changed, 121 insertions, 16 deletions
diff --git a/mysql-test/suite/perfschema/r/information_schema.result b/mysql-test/suite/perfschema/r/information_schema.result
index 7c7874642b2..ccf0c894831 100644
--- a/mysql-test/suite/perfschema/r/information_schema.result
+++ b/mysql-test/suite/perfschema/r/information_schema.result
@@ -229,7 +229,7 @@ objects_summary_global_by_type 10 Dynamic
performance_timers 10 Fixed
prepared_statements_instances 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_worker 10 Dynamic
replication_connection_configuration 10 Dynamic
diff --git a/mysql-test/suite/perfschema/r/table_schema.result b/mysql-test/suite/perfschema/r/table_schema.result
index bdd66d135d3..95a0a315a89 100644
--- a/mysql-test/suite/perfschema/r/table_schema.result
+++ b/mysql-test/suite/perfschema/r/table_schema.result
@@ -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 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_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 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
diff --git a/mysql-test/suite/rpl/include/rpl_deadlock.test b/mysql-test/suite/rpl/include/rpl_deadlock.test
index e9191d5fcd8..bccbe044a36 100644
--- a/mysql-test/suite/rpl/include/rpl_deadlock.test
+++ b/mysql-test/suite/rpl/include/rpl_deadlock.test
@@ -59,6 +59,16 @@ let $status_var_comparsion= >;
connection slave;
SELECT COUNT(*) FROM t2;
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;
# Check the data
diff --git a/mysql-test/suite/rpl/r/rpl_deadlock_innodb.result b/mysql-test/suite/rpl/r/rpl_deadlock_innodb.result
index bb8c45ae4eb..fd50e98414f 100644
--- a/mysql-test/suite/rpl/r/rpl_deadlock_innodb.result
+++ b/mysql-test/suite/rpl/r/rpl_deadlock_innodb.result
@@ -46,6 +46,11 @@ SELECT COUNT(*) FROM t2;
COUNT(*)
0
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;
a
1
diff --git a/mysql-test/suite/rpl/r/rpl_perfschema_applier_status.result b/mysql-test/suite/rpl/r/rpl_perfschema_applier_status.result
new file mode 100644
index 00000000000..fafdc4f01fd
--- /dev/null
+++ b/mysql-test/suite/rpl/r/rpl_perfschema_applier_status.result
@@ -0,0 +1,21 @@
+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
diff --git a/mysql-test/suite/rpl/t/rpl_perfschema_applier_status.test b/mysql-test/suite/rpl/t/rpl_perfschema_applier_status.test
new file mode 100644
index 00000000000..52ee14cef2a
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_perfschema_applier_status.test
@@ -0,0 +1,72 @@
+# ==== 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;
+
diff --git a/storage/perfschema/table_replication_applier_status.cc b/storage/perfschema/table_replication_applier_status.cc
index 7083d3ac3b9..d44cf2f613d 100644
--- a/storage/perfschema/table_replication_applier_status.cc
+++ b/storage/perfschema/table_replication_applier_status.cc
@@ -55,7 +55,7 @@ table_replication_applier_status::m_share=
sizeof(pos_t), /* ref length */
&m_table_lock,
{ 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,"
"REMAINING_DELAY INTEGER unsigned,"
"COUNT_TRANSACTIONS_RETRIES BIGINT unsigned not null)") },
@@ -140,16 +140,15 @@ void table_replication_applier_status::make_row(Master_info *mi)
DBUG_ASSERT(mi != NULL);
- m_row.channel_name_length= static_cast<uint>(mi->connection_name.length);
- memcpy(m_row.channel_name, mi->connection_name.str, m_row.channel_name_length);
+ m_row.connection_name_length= static_cast<uint>(mi->connection_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 *>
(mi->rli.sql_driver_thd ?
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->rli.data_lock);
@@ -160,9 +159,9 @@ void table_replication_applier_status::make_row(Master_info *mi)
m_row.service_state= PS_RPL_NO;
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 ?
sql_delay_end - t : 0);
m_row.remaining_delay_is_set= true;
@@ -197,8 +196,8 @@ int table_replication_applier_status::read_row_values(TABLE *table,
{
switch(f->field_index)
{
- case 0: /**channel_name*/
- set_field_char_utf8(f, m_row.channel_name, m_row.channel_name_length);
+ case 0: /**connection_name*/
+ set_field_varchar_utf8(f, m_row.connection_name, m_row.connection_name_length);
break;
case 1: /* service_state */
set_field_enum(f, m_row.service_state);
diff --git a/storage/perfschema/table_replication_applier_status.h b/storage/perfschema/table_replication_applier_status.h
index 95845f38925..58b3900e3ef 100644
--- a/storage/perfschema/table_replication_applier_status.h
+++ b/storage/perfschema/table_replication_applier_status.h
@@ -34,8 +34,6 @@
#include "pfs_engine_table.h"
#include "rpl_mi.h"
#include "mysql_com.h"
-//#include "rpl_msr.h"
-//#include "rpl_info.h" /*CHANNEL_NAME_LENGTH*/
#include "my_thread.h"
class Master_info;
@@ -56,8 +54,8 @@ enum enum_rpl_yes_no {
/** A row in the table. */
struct st_row_applier_status {
- char channel_name[CHANNEL_NAME_LENGTH];
- uint channel_name_length;
+ char connection_name[CHANNEL_NAME_LENGTH];
+ uint connection_name_length;
enum_rpl_yes_no service_state;
uint remaining_delay;
bool remaining_delay_is_set;