mirror of
https://github.com/MariaDB/server.git
synced 2025-01-22 06:44:16 +01:00
01cdba58ba
NOTE: this is the backport to next-mr. When using replication, the slave will not log any slow query logs queries replicated from the master, even if the option "--log-slow-slave-statements" is set and these take more than "log_query_time" to execute. In order to log slow queries in replicated thread one needs to set the --log-slow-slave-statements, so that the SQL thread is initialized with the correct switch. Although setting this flag correctly configures the slave thread option to log slow queries, there is an issue with the condition that is used to check whether to log the slow query or not. When replaying binlog events the statement contains the SET TIMESTAMP clause which will force the slow logging condition check to fail. Consequently, the slow query logging will not take place. This patch addresses this issue by removing the second condition from the log_slow_statements as it prevents slow queries to be binlogged and seems to be deprecated.
47 lines
1,004 B
Text
47 lines
1,004 B
Text
stop slave;
|
|
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
|
|
reset master;
|
|
reset slave;
|
|
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
|
|
start slave;
|
|
include/stop_slave.inc
|
|
SET @old_log_output= @@log_output;
|
|
SET GLOBAL log_output= 'TABLE';
|
|
SET @old_long_query_time= @@long_query_time;
|
|
SET GLOBAL long_query_time= 2;
|
|
TRUNCATE mysql.slow_log;
|
|
include/start_slave.inc
|
|
CREATE TABLE t1 (a int, b int);
|
|
INSERT INTO t1 values(1, 1);
|
|
INSERT INTO t1 values(1, sleep(3));
|
|
TRUNCATE mysql.slow_log;
|
|
SELECT 1, sleep(3);
|
|
1 sleep(3)
|
|
1 0
|
|
SELECT 1;
|
|
1
|
|
1
|
|
TRUNCATE mysql.slow_log;
|
|
SET TIMESTAMP= 1;
|
|
SELECT 2, sleep(3);
|
|
2 sleep(3)
|
|
2 0
|
|
SELECT 2;
|
|
2
|
|
2
|
|
TRUNCATE mysql.slow_log;
|
|
SET @old_slow_query_log= @@slow_query_log;
|
|
SET GLOBAL slow_query_log= 'OFF';
|
|
SELECT 3, sleep(3);
|
|
3 sleep(3)
|
|
3 0
|
|
SELECT 3;
|
|
3
|
|
3
|
|
TRUNCATE mysql.slow_log;
|
|
SET GLOBAL slow_query_log= @old_slow_query_log;
|
|
DROP TABLE t1;
|
|
include/stop_slave.inc
|
|
SET GLOBAL long_query_time= @old_long_query_time;
|
|
SET GLOBAL log_output= @old_log_output;
|
|
include/start_slave.inc
|