mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
This commit adds 3 new status variables to 'show all slaves status': - Master_last_event_time ; timestamp of the last event read from the master by the IO thread. - Slave_last_event_time ; Master timestamp of the last event committed on the slave. - Master_Slave_time_diff: The difference of the above two timestamps. All the above variables are NULL until the slave has started and the slave has read one query event from the master that changes data. - Added information_schema.slave_status, which allows us to remove: - show_master_info(), show_master_info_get_fields(), send_show_master_info_data(), show_all_master_info() - class Sql_cmd_show_slave_status. - Protocol::store(I_List<i_string_pair>* str_list) as it is not used anymore. - Changed old SHOW SLAVE STATUS and SHOW ALL SLAVES STATUS to use the SELECT code path, as all other SHOW ... STATUS commands. Other things: - Xid_log_time is set to time of commit to allow slave that reads the binary log to calculate Master_last_event_time and Slave_last_event_time. This is needed as there is not 'exec_time' for row events. - Fixed that Load_log_event calculates exec_time identically to Query_event. - Updated RESET SLAVE to reset Master/Slave_last_event_time - Updated SQL thread's update on first transaction read-in to only update Slave_last_event_time on group events. - Fixed possible (unlikely) bugs in sql_show.cc ...old_format() functions if allocation of 'field' would fail. Reviewed By: Brandon Nesterenko <brandon.nesterenko@mariadb.com> Kristian Nielsen <knielsen@knielsen-hq.org>
117 lines
3.3 KiB
Plaintext
117 lines
3.3 KiB
Plaintext
#
|
|
# Statement specific tests for master_last_event_time
|
|
#
|
|
--source include/have_binlog_format_statement.inc
|
|
--source include/have_innodb.inc
|
|
--let $rpl_topology=1->2->3
|
|
--source include/rpl_init.inc
|
|
|
|
# Server_3 state is maintained by master_last_event_time.inc
|
|
--connection server_3
|
|
--source include/stop_slave.inc
|
|
|
|
--connection server_1
|
|
call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
|
|
alter table mysql.gtid_slave_pos engine=innodb;
|
|
create table t1 (a int) engine=aria;
|
|
create table t2 (a int) engine=innodb;
|
|
--source include/save_master_gtid.inc
|
|
|
|
--echo # Sleep 1 to ensure setup DDL and test statements have different binlog timestamps
|
|
--sleep 1
|
|
|
|
--connection server_2
|
|
set @old_par_thds= @@global.slave_parallel_threads;
|
|
|
|
|
|
--echo #
|
|
--echo # Ensure that the slave doesn't overwrite exec_time when binlogging
|
|
--echo #
|
|
|
|
--let $slave_delay= 3
|
|
|
|
--connection server_2
|
|
--source include/sync_with_master_gtid.inc
|
|
--source include/stop_slave.inc
|
|
--replace_result $slave_delay SLAVE_DELAY
|
|
--eval change master to master_delay=$slave_delay
|
|
--source include/start_slave.inc
|
|
|
|
--let $serial_slave_const=2
|
|
--let $parallel_slave_const=1
|
|
--let $mode_ctr= 2
|
|
while ($mode_ctr)
|
|
{
|
|
--connection server_2
|
|
--source include/stop_slave.inc
|
|
if ($mode_ctr == $parallel_slave_const)
|
|
{
|
|
--let $mode_name= parallel
|
|
set @@global.slave_parallel_threads= 1;
|
|
}
|
|
if ($mode_ctr == $serial_slave_const)
|
|
{
|
|
--let $mode_name= serial
|
|
set @@global.slave_parallel_threads= 0;
|
|
}
|
|
--source include/start_slave.inc
|
|
|
|
--connection server_2
|
|
flush logs;
|
|
--connection server_1
|
|
--disable_warnings
|
|
--echo # Only sleep on master so the real execution time on the slave is less
|
|
insert into t1 values (sleep(if(@@global.server_id=1, 2, 0)));
|
|
--source include/save_master_gtid.inc
|
|
--enable_warnings
|
|
|
|
--echo # Waiting for slave to delay and commit transaction..
|
|
--connection server_2
|
|
--source include/sync_with_master_gtid.inc
|
|
|
|
--let $datadir= `select @@datadir`
|
|
--let $filename= query_get_value(SHOW MASTER STATUS, File, 1)
|
|
--let $slave_local_binlog=$datadir/$filename
|
|
--let $slave_outfile=$MYSQLTEST_VARDIR/tmp/slave_binlog.sql
|
|
--echo # MYSQL_BINLOG slave_local_binlog > slave_outfile
|
|
--exec $MYSQL_BINLOG $slave_local_binlog > $slave_outfile
|
|
--let $assert_count=0
|
|
--let $assert_text= Ensure $mode_name slave doesn't overwrite exec_time in the binlog event (0s)
|
|
--let $assert_select=exec_time=0
|
|
--let $assert_file= $slave_outfile
|
|
--source include/assert_grep.inc
|
|
|
|
# Double-check in the unlikely case execution time could be rounded to 1
|
|
--let $assert_text= Ensure $mode_name slave doesn't overwrite exec_time in the binlog event (1s)
|
|
--let $assert_select=exec_time=1
|
|
--let $assert_file= $slave_outfile
|
|
--source include/assert_grep.inc
|
|
|
|
--source master_last_event_time.inc
|
|
|
|
--connection server_2
|
|
--source include/stop_slave.inc
|
|
set @@global.slave_parallel_threads= @old_par_thds;
|
|
--source include/start_slave.inc
|
|
|
|
--dec $mode_ctr
|
|
}
|
|
|
|
--echo #
|
|
--echo # Cleanup
|
|
|
|
--connection server_2
|
|
--source include/stop_slave.inc
|
|
change master to master_delay=0;
|
|
--source include/start_slave.inc
|
|
--connection server_3
|
|
--source include/start_slave.inc
|
|
|
|
--connection server_1
|
|
drop table t1;
|
|
drop table t2;
|
|
|
|
--source include/rpl_end.inc
|
|
--remove_file $slave_outfile
|
|
--echo # End of master_last_event_time_stmt
|