summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSujatha <sujatha.sivakumar@mariadb.com>2020-11-27 23:15:38 +0530
committerSujatha <sujatha.sivakumar@mariadb.com>2020-11-30 12:05:41 +0530
commit4e6de585ff7ce334fe5a36efd730460d0be8ff4d (patch)
tree788b0b298173b265440e8e4c8ef35fb2aaf357d5
parentd51a373a176f348f8b517c3b0988f0677e3ac6d3 (diff)
downloadmariadb-git-4e6de585ff7ce334fe5a36efd730460d0be8ff4d.tar.gz
MDEV-16437: merge 5.7 P_S replication instrumentation and tables
Merge 'replication_applier_configuration' table. This table captures SQL_THREAD configuration parameters. 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/r/rpl_perfschema_applier_config.result35
-rw-r--r--mysql-test/suite/rpl/t/rpl_perfschema_applier_config.test96
-rw-r--r--storage/perfschema/table_replication_applier_configuration.cc31
-rw-r--r--storage/perfschema/table_replication_applier_configuration.h6
6 files changed, 144 insertions, 28 deletions
diff --git a/mysql-test/suite/perfschema/r/information_schema.result b/mysql-test/suite/perfschema/r/information_schema.result
index c0aff9bb956..7c7874642b2 100644
--- a/mysql-test/suite/perfschema/r/information_schema.result
+++ b/mysql-test/suite/perfschema/r/information_schema.result
@@ -228,7 +228,7 @@ mutex_instances 10 Dynamic
objects_summary_global_by_type 10 Dynamic
performance_timers 10 Fixed
prepared_statements_instances 10 Dynamic
-replication_applier_configuration 10 Fixed
+replication_applier_configuration 10 Dynamic
replication_applier_status 10 Fixed
replication_applier_status_by_coordinator 10 Dynamic
replication_applier_status_by_worker 10 Dynamic
diff --git a/mysql-test/suite/perfschema/r/table_schema.result b/mysql-test/suite/perfschema/r/table_schema.result
index 36c42478162..bdd66d135d3 100644
--- a/mysql-test/suite/perfschema/r/table_schema.result
+++ b/mysql-test/suite/perfschema/r/table_schema.result
@@ -853,7 +853,7 @@ def performance_schema prepared_statements_instances SUM_SORT_ROWS 32 NULL NO bi
def performance_schema prepared_statements_instances SUM_SORT_SCAN 33 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_INDEX_USED 34 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 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_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 SERVICE_STATE 2 NULL NO enum 3 9 NULL NULL NULL utf8 utf8_general_ci enum('ON','OFF') select,insert,update,references NEVER NULL
diff --git a/mysql-test/suite/rpl/r/rpl_perfschema_applier_config.result b/mysql-test/suite/rpl/r/rpl_perfschema_applier_config.result
new file mode 100644
index 00000000000..a910bbc834d
--- /dev/null
+++ b/mysql-test/suite/rpl/r/rpl_perfschema_applier_config.result
@@ -0,0 +1,35 @@
+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 [Value returned by SSS and PS table for Desired_Delay should be same.]
+
+# Verify that the value of this field is correct after STOP SLAVE.
+
+include/stop_slave.inc
+include/assert.inc [Value returned by SSS and PS table for Desired_Delay should be same.]
+
+# Verify that, when desired delay is set, the value is shown corectly.
+
+change master to master_delay= 2;
+include/start_slave.inc
+include/assert.inc [Value returned by SSS and PS table for Desired_Delay should be same.]
+
+# Verify that the value is preserved after STOP SLAVE.
+
+include/stop_slave.inc
+include/assert.inc [Value returned by SSS and PS table for Desired_Delay should be same.]
+
+# Verify that, when desired delay is reset, the value is shown corectly.
+
+change master to master_delay= 0;
+include/start_slave.inc
+include/assert.inc [Value returned by SSS and PS table for Desired_Delay should be same.]
+include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/t/rpl_perfschema_applier_config.test b/mysql-test/suite/rpl/t/rpl_perfschema_applier_config.test
new file mode 100644
index 00000000000..132d9912222
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_perfschema_applier_config.test
@@ -0,0 +1,96 @@
+# ==== Purpose ====
+#
+# This test script serves as the functionality testing for the table
+# performance_schema.replication_applier_configuration. Test for ddl and dml
+# operations is a part of the perfschema suite. The ddl/dml tests are named:
+# 1) ddl_replication_applier_configuration.test and
+# 2) dml_replication_applier_configuration.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.
+# - Verify that, when desired delay is set, the value is shown corectly.
+# - Verify that the value is preserved after STOP SLAVE.
+# - Verify that, when desired delay is reset, the value is shown corectly.
+#
+# ==== 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_configuration;
+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, SQL_Delay, 1);
+let $ps_value= query_get_value(select Desired_Delay from performance_schema.replication_applier_configuration, Desired_Delay, 1);
+let $assert_text= Value returned by SSS and PS table for Desired_Delay should be same.;
+let $assert_cond= "$sss_value" = "$ps_value";
+source include/assert.inc;
+
+--echo
+--echo # Verify that the value of this field is correct after STOP SLAVE.
+--echo
+
+source include/stop_slave.inc;
+
+let $sss_value= query_get_value(SHOW SLAVE STATUS, SQL_Delay, 1);
+let $ps_value= query_get_value(select Desired_Delay from performance_schema.replication_applier_configuration, Desired_Delay, 1);
+let $assert_text= Value returned by SSS and PS table for Desired_Delay should be same.;
+let $assert_cond= "$sss_value" = "$ps_value";
+source include/assert.inc;
+
+--echo
+--echo # Verify that, when desired delay is set, the value is shown corectly.
+--echo
+
+eval change master to master_delay= 2;
+source include/start_slave.inc;
+
+let $sss_value= query_get_value(SHOW SLAVE STATUS, SQL_Delay, 1);
+let $ps_value= query_get_value(select Desired_Delay from performance_schema.replication_applier_configuration, Desired_Delay, 1);
+let $assert_text= Value returned by SSS and PS table for Desired_Delay should be same.;
+let $assert_cond= "$sss_value" = "$ps_value";
+source include/assert.inc;
+
+--echo
+--echo # Verify that the value is preserved after STOP SLAVE.
+--echo
+
+source include/stop_slave.inc;
+
+let $ss_value= query_get_value(SHOW SLAVE STATUS, SQL_Delay, 1);
+let $ps_value= query_get_value(select Desired_Delay from performance_schema.replication_applier_configuration, Desired_Delay, 1);
+let $assert_text= Value returned by SSS and PS table for Desired_Delay should be same.;
+let $assert_cond= "$sss_value" = "$ps_value";
+source include/assert.inc;
+
+--echo
+--echo # Verify that, when desired delay is reset, the value is shown corectly.
+--echo
+
+eval change master to master_delay= 0;
+source include/start_slave.inc;
+
+let $sss_value= query_get_value(SHOW SLAVE STATUS, SQL_Delay, 1);
+let $ps_value= query_get_value(select Desired_Delay from performance_schema.replication_applier_configuration, Desired_Delay, 1);
+let $assert_text= Value returned by SSS and PS table for Desired_Delay should be same.;
+let $assert_cond= "$sss_value" = "$ps_value";
+source include/assert.inc;
+
+source include/rpl_end.inc;
diff --git a/storage/perfschema/table_replication_applier_configuration.cc b/storage/perfschema/table_replication_applier_configuration.cc
index 06de6c6e141..4cd57d48b47 100644
--- a/storage/perfschema/table_replication_applier_configuration.cc
+++ b/storage/perfschema/table_replication_applier_configuration.cc
@@ -29,17 +29,15 @@
//#define HAVE_REPLICATION
#include "my_global.h"
+#ifdef HAVE_REPLICATION
#include "table_replication_applier_configuration.h"
#include "pfs_instr_class.h"
#include "pfs_instr.h"
#include "slave.h"
-//#include "rpl_info.h"
#include "rpl_rli.h"
#include "rpl_mi.h"
#include "sql_parse.h"
-//#include "rpl_msr.h" /* Multisource replication */
-#ifdef HAVE_REPLICATION
THR_LOCK table_replication_applier_configuration::m_table_lock;
PFS_engine_table_share
@@ -54,7 +52,7 @@ table_replication_applier_configuration::m_share=
sizeof(pos_t), /* ref length */
&m_table_lock,
{ C_STRING_WITH_LEN("CREATE TABLE replication_applier_configuration("
- "CHANNEL_NAME CHAR(64) collate utf8_general_ci not null,"
+ "CONNECTION_NAME VARCHAR(256) collate utf8_general_ci not null,"
"DESIRED_DELAY INTEGER not null)") },
false /* perpetual */
};
@@ -139,9 +137,9 @@ void table_replication_applier_configuration::make_row(Master_info *mi)
mysql_mutex_lock(&mi->data_lock);
mysql_mutex_lock(&mi->rli.data_lock);
- 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.desired_delay= 0; //mi->rli->get_sql_delay();
+ 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);
+ m_row.desired_delay= mi->rli.get_sql_delay();
mysql_mutex_unlock(&mi->rli.data_lock);
mysql_mutex_unlock(&mi->data_lock);
@@ -159,18 +157,7 @@ int table_replication_applier_configuration::read_row_values(TABLE *table,
if (unlikely(! m_row_exists))
return HA_ERR_RECORD_DELETED;
- /*
- Note:
- There are no NULL columns in this table,
- so there are no null bits reserved for NULL flags per column.
- There are no VARCHAR columns either, so the record is not
- in HA_OPTION_PACK_RECORD format as most other performance_schema tables.
- When HA_OPTION_PACK_RECORD is not set,
- the table record reserves an extra null byte, see open_binary_frm().
- */
-
- DBUG_ASSERT(table->s->null_bytes == 1);
- buf[0]= 0;
+ DBUG_ASSERT(table->s->null_bytes == 0);
for (; (f= *fields) ; fields++)
{
@@ -178,10 +165,10 @@ int table_replication_applier_configuration::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: /** desired_delay */
+ case 1: /* desired_delay */
set_field_ulong(f, static_cast<ulong>(m_row.desired_delay));
break;
default:
diff --git a/storage/perfschema/table_replication_applier_configuration.h b/storage/perfschema/table_replication_applier_configuration.h
index 18321ac079e..d3d340cb70a 100644
--- a/storage/perfschema/table_replication_applier_configuration.h
+++ b/storage/perfschema/table_replication_applier_configuration.h
@@ -35,8 +35,6 @@
#include "rpl_mi.h"
#include "mysql_com.h"
#include "my_thread.h"
-//#include "rpl_msr.h"
-//#include "rpl_info.h" /*CHANNEL_NAME_LENGTH*/
class Master_info;
@@ -47,8 +45,8 @@ class Master_info;
/** A row in the table*/
struct st_row_applier_config {
- char channel_name[CHANNEL_NAME_LENGTH];
- uint channel_name_length;
+ char connection_name[CHANNEL_NAME_LENGTH];
+ uint connection_name_length;
time_t desired_delay;
bool desired_delay_is_set;
};