Bug #105558 OPTIMIZE TABLE replication to slave
Submitted: 12 Nov 2021 17:21 Modified: 12 Dec 2021 17:35
Reporter: sad asd asd dasd Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Server: Replication Severity:S3 (Non-critical)
Version:8.0.27 OS:CentOS (8.4.2105)
Assigned to: CPU Architecture:Any
Tags: master, optimize table, replication, slave

[12 Nov 2021 17:21] sad asd asd dasd
Description:
I have a master (mysql server 8.0.27) and a slave (mysql server 8.0.27). Replication Row based.

I run "OPTIMIZE TABLE foo;" in the master into an innodb table with partitioning. The size of the table is around 300GB, the "OPTIMIZE TABLE" takes a few hours.
Seems the OPTIMIZE TABLE is added to the master binary log after the master has completed the OPTIMIZE TABLE process. All good until here.

But if I stop or kill the OPTIMIZE TABLE in the master without being completed, the slave still replicates it.

I am not sure if it's a bug or not. But OPTIMIZE TABLE should only be added to the master binary log if it is completed "successfully".

How to repeat:
1. Get any master to slave replication row based.
2. Run OPTIMIZE TABLE in the master in an innodb table.
3. Kill or stop the process before its completed (be sure you have enough data in the table, so you will be able to stop/kill before its completed).
4. Even after you stoped or killed in the master before its completed, it gets replicated to the slave.

Suggested fix:
Only add the OPTIMIZE TABLE in the master binary log if it's completed "successfully".
[12 Nov 2021 17:35] MySQL Verification Team
Thank you for the bug report. Please check https://bugs.mysql.com/bug.php?id=93761 for duplicate.
[13 Dec 2021 1:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".