| 1 |
# ==== Purpose ==== |
| 2 |
# |
| 3 |
# Verify that the value for the "sql_text" column of the slow log |
| 4 |
# depends on @@terminology_use_previous for |
| 5 |
# COM_REGISTER_REPLICA commands. |
| 6 |
# |
| 7 |
# ==== Requirements ==== |
| 8 |
# |
| 9 |
# R1. If @@global.terminology_use_previous = NONE, |
| 10 |
# then the slow log should contain "Register Replica", |
| 11 |
# if a COM_REGISTER_REPLICA is logged as slow. |
| 12 |
# |
| 13 |
# R2. If @@global.terminology_use_previous = BEFORE_8_0_26, |
| 14 |
# then the slow log should contain "Register Slave", |
| 15 |
# if a COM_REGISTER_REPLICA is logged as slow. |
| 16 |
# |
| 17 |
# ==== Implementation ==== |
| 18 |
# |
| 19 |
# Configure the server to write any statement taking more than one |
| 20 |
# second to the slow log. Then use a debug sync point to make the |
| 21 |
# source server pause in the middle of a COM_REGISTER_REPLICA command, |
| 22 |
# and sleep for two seconds. Let the command complete. Verify that |
| 23 |
# the slow log contains the expected term. |
| 24 |
|
| 25 |
# Test is binlog_format-agnostic |
| 26 |
--source include/have_binlog_format_row.inc |
| 27 |
|
| 28 |
# Test uses SET debug and SET debug_sync to ensure source is in the |
| 29 |
# middle of the execution of a Thread Command |
| 30 |
--source include/have_debug_sync.inc |
| 31 |
--source include/have_debug.inc |
| 32 |
|
| 33 |
--source include/master-slave.inc |
| 34 |
|
| 35 |
--echo #### Initialize #### |
| 36 |
|
| 37 |
SET @save_log_output = @@global.log_output; |
| 38 |
SET @@global.log_output = 'TABLE'; |
| 39 |
SET @save_long_query_time = @@global.long_query_time; |
| 40 |
SET @@global.long_query_time = 1; |
| 41 |
SET @save_terminology_use_previous = @@global.terminology_use_previous; |
| 42 |
|
| 43 |
--let $terminology_use_previous = 0 |
| 44 |
while ($terminology_use_previous < 2) { |
| 45 |
|
| 46 |
--echo #### Test terminology_use_previous = $terminology_use_previous #### |
| 47 |
|
| 48 |
--echo * Set option |
| 49 |
--connection master |
| 50 |
eval SET @@global.terminology_use_previous = $terminology_use_previous; |
| 51 |
eval SELECT @@global.terminology_use_previous; |
| 52 |
|
| 53 |
--echo * Clear log tables |
| 54 |
TRUNCATE mysql.slow_log; |
| 55 |
|
| 56 |
--echo * Pause source during REGISTER REPLICA to make it go to slow log |
| 57 |
|
| 58 |
--source include/rpl_connection_slave.inc |
| 59 |
# Make dump thread pause during 'register replica', so we can force it |
| 60 |
# to go to the slow log. |
| 61 |
--source include/stop_slave_io.inc |
| 62 |
--connection master |
| 63 |
--let $debug_point = syncpoint_begin_register_replica |
| 64 |
--source include/add_debug_point.inc |
| 65 |
# Start connection |
| 66 |
--connection slave |
| 67 |
START REPLICA IO_THREAD; |
| 68 |
# Wait for 'master' to reach the state |
| 69 |
--connection master |
| 70 |
SET @@session.debug_sync = "now WAIT_FOR reached_begin_register_replica"; |
| 71 |
|
| 72 |
--echo * Sleep 2 seconds |
| 73 |
--sleep 2 |
| 74 |
|
| 75 |
--echo * Allow REGISTER REPLICA to finish |
| 76 |
SET @@session.debug_sync = "now SIGNAL continue_begin_register_replica"; |
| 77 |
# Wait for replica to start |
| 78 |
--connection slave |
| 79 |
--source include/wait_for_slave_io_to_start.inc |
| 80 |
|
| 81 |
--echo * Verify the logs contain the correct term, and not the incorrect one |
| 82 |
--connection master |
| 83 |
if ($terminology_use_previous == 0) { |
| 84 |
--let $expect = Register Replica |
| 85 |
--let $no_expect = Register Slave |
| 86 |
} |
| 87 |
if ($terminology_use_previous == 1) { |
| 88 |
--let $expect = Register Slave |
| 89 |
--let $no_expect = Register Replica |
| 90 |
} |
| 91 |
|
| 92 |
--let $assert_cond = [SELECT COUNT(*) FROM mysql.slow_log WHERE sql_text = "$expect"] = 1 |
| 93 |
--let $assert_text = Slow log should contain "$expect" |
| 94 |
--source include/assert.inc |
| 95 |
|
| 96 |
--let $assert_cond = [SELECT COUNT(*) FROM mysql.slow_log WHERE sql_text = "no_$expect"] = 0 |
| 97 |
--let $assert_text = Slow log should not contain "no_$expect" |
| 98 |
--source include/assert.inc |
| 99 |
|
| 100 |
--inc $terminology_use_previous |
| 101 |
} |
| 102 |
|
| 103 |
--echo #### Clean up #### |
| 104 |
|
| 105 |
--source include/rpl_connection_master.inc |
| 106 |
SET @@global.log_output = @save_log_output; |
| 107 |
TRUNCATE TABLE mysql.general_log; |
| 108 |
TRUNCATE TABLE mysql.slow_log; |
| 109 |
SET @@global.long_query_time = @save_long_query_time; |
| 110 |
SET @@global.terminology_use_previous = @save_terminology_use_previous; |
| 111 |
|
| 112 |
--let $debug_point = syncpoint_begin_register_replica |
| 113 |
--source include/remove_debug_point.inc |
| 114 |
|
| 115 |
--source include/rpl_end.inc |