Hi Kristian, I am stuck at one problem in Mdev-10664. Suppose there is multisource replication('master1' and 'master2' ) and we want to update status var, How to know which master_info to update ?. Does slave threads have current replication channel name? (I was not able to find any , I have looked in rpl_group_info)
I am attaching patch file, only above problem need to solved in patch. -- Regards Sachin Setiya Software Engineer at MariaDB
diff --git a/mysql-test/suite/multi_source/multi_parallel.result b/mysql-test/suite/multi_source/multi_parallel.result new file mode 100644 index 0000000..6aa0658 --- /dev/null +++ b/mysql-test/suite/multi_source/multi_parallel.result @@ -0,0 +1,184 @@ +set global slave_parallel_threads=10; +change master 'master1' to +master_port=MYPORT_1, +master_host='127.0.0.1', +master_user='root', +master_heartbeat_period = 25; +change master 'master2' to +master_port=MYPORT_2, +master_host='127.0.0.1', +master_user='root', +master_heartbeat_period=35; +start all slaves; +Warnings: +Note 1937 SLAVE 'master2' started +Note 1937 SLAVE 'master1' started +set default_master_connection = 'master1'; +include/wait_for_slave_to_start.inc +set default_master_connection = 'master2'; +include/wait_for_slave_to_start.inc +show variables like 'slave%'; +Variable_name Value +slave_compressed_protocol OFF +slave_ddl_exec_mode IDEMPOTENT +slave_domain_parallel_threads 0 +slave_exec_mode STRICT +slave_load_tmpdir /home/sachin/mdev-10664/build/mysql-test/var/tmp/mysqld.3 +slave_max_allowed_packet 1073741824 +slave_net_timeout 120 +slave_parallel_max_queued 131072 +slave_parallel_mode conservative +slave_parallel_threads 10 +slave_run_triggers_for_rbr NO +slave_skip_errors OFF +slave_sql_verify_checksum ON +slave_transaction_retries 10 +slave_type_conversions +## Slave status variable +set default_master_connection = 'master1'; +show status like 'slave%'; +Variable_name Value +Slave_connections 0 +Slave_ddl_statements 0 +Slave_heartbeat_period 25.000 +Slave_non_transactional_statements 0 +Slave_open_temp_tables 0 +Slave_received_heartbeats 0 +Slave_retried_transactions 0 +Slave_running ON +Slave_skipped_errors 0 +Slaves_connected 0 +Slaves_running 2 +set default_master_connection = 'master2'; +show status like 'slave%'; +Variable_name Value +Slave_connections 0 +Slave_ddl_statements 0 +Slave_heartbeat_period 35.000 +Slave_non_transactional_statements 0 +Slave_open_temp_tables 0 +Slave_received_heartbeats 0 +Slave_retried_transactions 0 +Slave_running ON +Slave_skipped_errors 0 +Slaves_connected 0 +Slaves_running 2 +#master 1 +create table t1(a int primary key); +insert into t1 values(1); +insert into t1 values(2); +drop table t1; +create table t1(a int primary key); +insert into t1 values(1); +insert into t1 values(2); +drop table t1; +create table t1(a int primary key); +insert into t1 values(1); +insert into t1 values(2); +drop table t1; +create table t1(a int primary key); +insert into t1 values(1); +insert into t1 values(2); +drop table t1; +create table t1(a int primary key); +insert into t1 values(1); +insert into t1 values(2); +drop table t1; +create table t1(a int primary key); +insert into t1 values(1); +insert into t1 values(2); +drop table t1; +create table t1(a int primary key); +insert into t1 values(1); +insert into t1 values(2); +drop table t1; +create table t1(a int primary key); +insert into t1 values(1); +insert into t1 values(2); +drop table t1; +create table t1(a int primary key); +insert into t1 values(1); +insert into t1 values(2); +drop table t1; +create table t1(a int primary key); +insert into t1 values(1); +insert into t1 values(2); +drop table t1; +set default_master_connection = 'master1'; +show status like 'Slave%'; +Variable_name Value +Slave_connections 0 +Slave_ddl_statements 0 +Slave_heartbeat_period 25.000 +Slave_non_transactional_statements 0 +Slave_open_temp_tables 0 +Slave_received_heartbeats 0 +Slave_retried_transactions 0 +Slave_running ON +Slave_skipped_errors 0 +Slaves_connected 0 +Slaves_running 2 +#master 2 +create table t2(a int primary key); +insert into t2 values(1); +insert into t2 values(2); +drop table t2; +create table t2(a int primary key); +insert into t2 values(1); +insert into t2 values(2); +drop table t2; +create table t2(a int primary key); +insert into t2 values(1); +insert into t2 values(2); +drop table t2; +create table t2(a int primary key); +insert into t2 values(1); +insert into t2 values(2); +drop table t2; +create table t2(a int primary key); +insert into t2 values(1); +insert into t2 values(2); +drop table t2; +create table t2(a int primary key); +insert into t2 values(1); +insert into t2 values(2); +drop table t2; +create table t2(a int primary key); +insert into t2 values(1); +insert into t2 values(2); +drop table t2; +create table t2(a int primary key); +insert into t2 values(1); +insert into t2 values(2); +drop table t2; +create table t2(a int primary key); +insert into t2 values(1); +insert into t2 values(2); +drop table t2; +create table t2(a int primary key); +insert into t2 values(1); +insert into t2 values(2); +drop table t2; +set default_master_connection = 'master2'; +show status like 'Slave%'; +Variable_name Value +Slave_connections 0 +Slave_ddl_statements 0 +Slave_heartbeat_period 35.000 +Slave_non_transactional_statements 0 +Slave_open_temp_tables 0 +Slave_received_heartbeats 0 +Slave_retried_transactions 0 +Slave_running ON +Slave_skipped_errors 0 +Slaves_connected 0 +Slaves_running 2 +stop all slaves; +Warnings: +Note 1938 SLAVE 'master2' stopped +Note 1938 SLAVE 'master1' stopped +include/wait_for_slave_to_stop.inc +set global slave_parallel_threads=0; +include/reset_master_slave.inc +include/reset_master_slave.inc +include/reset_master_slave.inc diff --git a/mysql-test/suite/multi_source/multi_parallel.test b/mysql-test/suite/multi_source/multi_parallel.test new file mode 100644 index 0000000..e27345d --- /dev/null +++ b/mysql-test/suite/multi_source/multi_parallel.test @@ -0,0 +1,113 @@ +#multi source parallel replication + +--source include/not_embedded.inc +--let $rpl_server_count= 0 + +--connect (master1,127.0.0.1,root,,,$SERVER_MYPORT_1) +--connect (master2,127.0.0.1,root,,,$SERVER_MYPORT_2) +--connect (slave,127.0.0.1,root,,,$SERVER_MYPORT_3) + +#save state +--let $par_thd= `select @@slave_parallel_threads;` + +set global slave_parallel_threads=10; + +--replace_result $SERVER_MYPORT_1 MYPORT_1 +eval change master 'master1' to +master_port=$SERVER_MYPORT_1, +master_host='127.0.0.1', +master_user='root', +master_heartbeat_period = 25; + + + +--replace_result $SERVER_MYPORT_2 MYPORT_2 +eval change master 'master2' to +master_port=$SERVER_MYPORT_2, +master_host='127.0.0.1', +master_user='root', +master_heartbeat_period=35; + + +#start all slaves + +start all slaves; + +set default_master_connection = 'master1'; +--source include/wait_for_slave_to_start.inc + +set default_master_connection = 'master2'; +--source include/wait_for_slave_to_start.inc + +show variables like 'slave%'; + +--echo ## Slave status variable + +set default_master_connection = 'master1'; +show status like 'slave%'; + +set default_master_connection = 'master2'; +show status like 'slave%'; + + +--echo #master 1 +--connection master1 + +--let $counter=10 +while ($counter) +{ + #DDL statement + create table t1(a int primary key); + + #non trans update statement + insert into t1 values(1); + insert into t1 values(2); + + drop table t1; + --dec $counter +} +--save_master_pos + +--connection slave + +--sync_with_master 0,'master1' +set default_master_connection = 'master1'; +show status like 'Slave%'; + +--echo #master 2 +--connection master2 + +--let $counter=10 +while ($counter) +{ + #DDL statement + create table t2(a int primary key); + + #non trans update statement + insert into t2 values(1); + insert into t2 values(2); + + drop table t2; + --dec $counter +} +--save_master_pos + +--connection slave +--sync_with_master 0,'master2' +set default_master_connection = 'master2'; +show status like 'Slave%'; + +# Cleanup +stop all slaves; +--source include/wait_for_slave_to_stop.inc + +--eval set global slave_parallel_threads=$par_thd + +--source include/reset_master_slave.inc +--disconnect slave +--connection master1 +--source include/reset_master_slave.inc +--disconnect master1 +--connection master2 +--source include/reset_master_slave.inc +--disconnect master2 diff --git a/sql/log_event.cc b/sql/log_event.cc index ced2626..c041116 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -6780,6 +6780,17 @@ Gtid_log_event::do_apply_event(rpl_group_info *rgi) } DBUG_ASSERT((bits & OPTION_GTID_BEGIN) == 0); + mysql_mutex_lock(&LOCK_active_mi); + Master_info *mi= master_info_index->get_master_info(&thd->variables.default_master_connection, + Sql_condition::WARN_LEVEL_NOTE); + if (mi) + { + if (flags2 & FL_DDL) + mi->total_ddl_statements++; + if (!(flags & FL_TRANSACTIONAL)) + mi->total_non_trans_statements++; + } + mysql_mutex_unlock(&LOCK_active_mi); if (flags2 & FL_STANDALONE) return 0; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index adb1b27..5fcaf34 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -7805,7 +7805,59 @@ static int show_heartbeat_period(THD *thd, SHOW_VAR *var, char *buff, return 0; } +static long show_slave_ddl_stmts(THD *thd, SHOW_VAR *var, char *buff, + enum enum_var_type scope) +{ + Master_info *mi= NULL; + longlong UNINIT_VAR(tmp); + + var->type= SHOW_LONGLONG; + var->value= buff; + + mysql_mutex_lock(&LOCK_active_mi); + if (master_info_index) + { + mi= master_info_index-> + get_master_info(&thd->variables.default_master_connection, + Sql_condition::WARN_LEVEL_NOTE); + if (mi) + tmp= mi->total_ddl_statements; + } + mysql_mutex_unlock(&LOCK_active_mi); + if (mi) + *((longlong *)buff)= tmp; + else + var->type= SHOW_UNDEF; + + return 0; +} +static long show_slave_non_trans_stmts(THD *thd, SHOW_VAR *var, char *buff, + enum enum_var_type scope) +{ + Master_info *mi= NULL; + longlong UNINIT_VAR(tmp); + + var->type= SHOW_LONGLONG; + var->value= buff; + + mysql_mutex_lock(&LOCK_active_mi); + if (master_info_index) + { + mi= master_info_index-> + get_master_info(&thd->variables.default_master_connection, + Sql_condition::WARN_LEVEL_NOTE); + if (mi) + tmp= mi->total_non_trans_statements; + } + mysql_mutex_unlock(&LOCK_active_mi); + if (mi) + *((longlong *)buff)= tmp; + else + var->type= SHOW_UNDEF; + + return 0; +} #endif /* HAVE_REPLICATION */ static int show_open_tables(THD *thd, SHOW_VAR *var, char *buff, @@ -8473,6 +8525,8 @@ SHOW_VAR status_vars[]= { {"Slave_retried_transactions",(char*)&slave_retried_transactions, SHOW_LONG}, {"Slave_running", (char*) &show_slave_running, SHOW_SIMPLE_FUNC}, {"Slave_skipped_errors", (char*) &slave_skipped_errors, SHOW_LONGLONG}, + {"Slave_DDL_statements", (char*) &show_slave_ddl_stmts, SHOW_SIMPLE_FUNC}, + {"Slave_Non_transactional_statements", (char *) &show_slave_non_trans_stmts, SHOW_SIMPLE_FUNC}, #endif {"Slow_launch_threads", (char*) &slow_launch_threads, SHOW_LONG}, {"Slow_queries", (char*) offsetof(STATUS_VAR, long_query_count), SHOW_LONG_STATUS}, diff --git a/sql/rpl_mi.cc b/sql/rpl_mi.cc index 6048d26..0d74b88 100644 --- a/sql/rpl_mi.cc +++ b/sql/rpl_mi.cc @@ -40,7 +40,8 @@ Master_info::Master_info(LEX_STRING *connection_name_arg, sync_counter(0), heartbeat_period(0), received_heartbeats(0), master_id(0), prev_master_id(0), using_gtid(USE_GTID_NO), events_queued_since_last_gtid(0), - gtid_reconnect_event_skip_count(0), gtid_event_seen(false) + gtid_reconnect_event_skip_count(0), gtid_event_seen(false), + total_ddl_statements(0), total_non_trans_statements(0) { host[0] = 0; user[0] = 0; password[0] = 0; ssl_ca[0]= 0; ssl_capath[0]= 0; ssl_cert[0]= 0; diff --git a/sql/rpl_mi.h b/sql/rpl_mi.h index 9365c06..38a7b22 100644 --- a/sql/rpl_mi.h +++ b/sql/rpl_mi.h @@ -303,6 +303,12 @@ class Master_info : public Slave_reporting_capability /* The parallel replication mode. */ enum_slave_parallel_mode parallel_mode; + + /* No of DDL statements */ + long total_ddl_statements; + + /* No of non-transactional statements*/ + long total_non_trans_statements; }; int init_master_info(Master_info* mi, const char* master_info_fname,
_______________________________________________ Mailing list: https://launchpad.net/~maria-developers Post to : maria-developers@lists.launchpad.net Unsubscribe : https://launchpad.net/~maria-developers More help : https://help.launchpad.net/ListHelp