mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
BUG#11760927: 53375: RBR + NO PK => HIGH LOAD ON SLAVE (TABLE
SCAN/CPU) => SLAVE FAILURE When a statement containing a large amount of ROWs to be applied on the slave, and the slave's table does not contain a PK, it can take a considerable amount of time to find and change all the rows that are to be changed. The proper slave enhancement will be implemented in WL 5597. However, in this bug we are making it clear to the user what the problem is, by printing a message to the error log if the execution time, for a given statement in RBR, takes more than LONG_FIND_ROW_THRESHOLD (set to 60 seconds). This shall help the DBA to diagnose what's happening when facing a slave server that is quiet for no apparent reason... The note is only printed to the error log if log_warnings is set to be greater than 1. sql/log_event.cc: Core of the patch. In Rows_log_event::do_apply_event, sets STMT start timestamp. In Rows_log_event::find_row, if a PK is not used, then the start timestamp is checked to see if the time spent on this STMT is enough to justify the printing of a note (only if it was not printed before). sql/log_event.h: Defining LONG_FIND_ROW_THRESHOLD. sql/rpl_rli.cc: Resets long_find_row state in rli->context_cleanup(). sql/rpl_rli.h: Two new rli properties that are necessary to control when to emit a note in the error log: 1) timestamp that states when the ROW statement started; 2) flag indicating whether the note has been emitted for the current statement or not. Also deployed accessors.
This commit is contained in:
62
mysql-test/suite/rpl/t/rpl_row_find_row_debug.test
Normal file
62
mysql-test/suite/rpl/t/rpl_row_find_row_debug.test
Normal file
@ -0,0 +1,62 @@
|
||||
#
|
||||
# Bug#11760927: 53375: RBR + NO PK => HIGH LOAD ON SLAVE (TABLE SCAN/CPU) => SLAVE FAILURE
|
||||
#
|
||||
--source include/master-slave.inc
|
||||
--source include/have_binlog_format_row.inc
|
||||
--source include/have_debug.inc
|
||||
|
||||
# SETUP
|
||||
# - setup log_warnings and debug
|
||||
--connection slave
|
||||
--source include/stop_slave.inc
|
||||
--let $debug_save= `SELECT @@GLOBAL.debug`
|
||||
--let $log_warnings_save= `SELECT @@GLOBAL.log_warnings`
|
||||
|
||||
SET GLOBAL log_warnings = 2;
|
||||
|
||||
let $log_error_= `SELECT @@GLOBAL.log_error`;
|
||||
if(!$log_error_)
|
||||
{
|
||||
# MySQL Server on windows is started with --console and thus
|
||||
# does not know the location of its .err log, use default location
|
||||
let $log_error_ = $MYSQLTEST_VARDIR/log/mysqld.2.err;
|
||||
}
|
||||
|
||||
# Assign env variable LOG_ERROR
|
||||
let LOG_ERROR=$log_error_;
|
||||
|
||||
# force printing the notes to the error log
|
||||
SET GLOBAL debug="d,inject_long_find_row_note";
|
||||
--source include/start_slave.inc
|
||||
|
||||
# test
|
||||
--connection master
|
||||
CREATE TABLE t1 (c1 INT);
|
||||
--sync_slave_with_master
|
||||
--connection master
|
||||
|
||||
INSERT INTO t1 VALUES (1), (2);
|
||||
UPDATE t1 SET c1= 1000 WHERE c1=2;
|
||||
DELETE FROM t1;
|
||||
DROP TABLE t1;
|
||||
--sync_slave_with_master
|
||||
|
||||
--echo # Check if any note related to long DELETE_ROWS and UPDATE_ROWS appears in the error log
|
||||
perl;
|
||||
use strict;
|
||||
my $log_error= $ENV{'LOG_ERROR'} or die "LOG_ERROR not set";
|
||||
open(FILE, "$log_error") or die("Unable to open $log_error: $!\n");
|
||||
my $upd_count = () = grep(/The slave is applying a ROW event on behalf of an UPDATE statement on table t1 and is currently taking a considerable amount/g,<FILE>);
|
||||
seek(FILE, 0, 0) or die "Can't seek to beginning of file: $!";
|
||||
my $del_count = () = grep(/The slave is applying a ROW event on behalf of a DELETE statement on table t1 and is currently taking a considerable amount/g,<FILE>);
|
||||
print "Occurrences: update=$upd_count, delete=$del_count\n";
|
||||
close(FILE);
|
||||
EOF
|
||||
|
||||
# cleanup
|
||||
--source include/stop_slave.inc
|
||||
--eval SET GLOBAL debug = '$debug_save'
|
||||
--eval SET GLOBAL log_warnings = $log_warnings_save
|
||||
--source include/start_slave.inc
|
||||
|
||||
--source include/rpl_end.inc
|
Reference in New Issue
Block a user