Bug #5551 Failed OPTIMIZE TABLE is logged to binary log
Submitted: 13 Sep 2004 20:41 Modified: 3 Nov 2004 17:37
Reporter: Dean Ellis Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:4.1.5 bk 1.2002 OS:
Assigned to: Lars Thalmann CPU Architecture:Any

[13 Sep 2004 20:41] Dean Ellis
Description:
A failed (lock wait timeout) OPTIMIZE TABLE statement against an InnoDB table is written to the binary log, confusing a replication slave.

How to repeat:
connection 1:

DROP TABLE IF EXISTS t1;
CREATE TABLE t1 ( a int ) ENGINE=InnoDB;
BEGIN;
SELECT * FROM t1 FOR UPDATE;

connection 2:

OPTIMIZE TABLE t1;

Wait for innodb_lock_wait_timeout to be exceeded.

Binlog stores the statement, with error_code=1205.

Suggested fix:
n/a
[14 Sep 2004 14:57] Dean Ellis
It appears that any failed OPTIMIZE TABLE is being logged.

DROP TABLE IF EXISTS t1;
OPTIMIZE TABLE t1;

This also appears in the binary log, with appropriate error number, also confusing any replication slaves.
[3 Nov 2004 17:37] Lars Thalmann
This bug is fixed in release 4.1.8 and 5.0.2.