Bug #113251 the slow log in slave is logged ,when binlog_format is row
Submitted: 28 Nov 2023 11:54 Modified: 29 Nov 2023 9:24
Reporter: bin wang (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Row Based Replication ( RBR ) Severity:S3 (Non-critical)
Version:MySQL8.0 OS:Any
Assigned to: CPU Architecture:Any
Tags: Contribution

[28 Nov 2023 11:54] bin wang
Description:
In the MySQL Reference Manual
 
Note that if row-based replication is in use (binlog_format=ROW), log_slow_replica_statements has no effect. 
 Slow queries that are logged in row format when binlog_format=MIXED is set, or that are logged when binlog_format=ROW is set, are not added to the replica's slow query log, even if log_slow_replica_statements is enabled.

But when binlog_format is row and log_slow_replica_statements=on ,drop table is logged in the slow log.

How to repeat:
In a 2c2G lower the configuration  ECS.

master
 create table t(a int);
 insert into t.t values(1),(1),(1),(1),(1),(1),(1),(1),(1),(1);
 drop table t.t;

replica;
set long_query_time=0.001;
set binlog_format=row;
set log_slow_replica_statements=ON;

In the replica slow log :

# Time: 2023-11-29T02:51:07.472804+08:00
# User@Host: skip-grants user[] @  []  Id:    66
# Query_time: 0.026266  Lock_time: 0.000080 Rows_sent: 0  Rows_examined: 0
SET timestamp=1701197465;
DROP TABLE `t` /* generated by server */;
according MySQL Reference Manual  
The `“DROP TABLE `t`”  should not  in the   slow log.

Suggested fix:
add    when opt_log_slow_replica_statements  is on and current_stmt_binlog_format  is row or mixed  
the log not write into the slow log
[28 Nov 2023 12:03] bin wang
suggest fix

Attachment: log.patch (application/octet-stream, text), 889 bytes.

[29 Nov 2023 9:24] MySQL Verification Team
Hello bin wang,

Thank you for the report and contribution.
Please ensure to re-upload the suggested patch via contribution tab of this bug page otherwise we may not be able to use it. Thank you.

regards,
Umesh