Bug #23213 Relay log deleted without all events being applied
Submitted: 12 Oct 2006 12:28 Modified: 6 Nov 2007 15:29
Reporter: Andrei Elkin Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server: Replication Severity:S3 (Non-critical)
Version:5.1.12 OS:Any
Assigned to: Andrei Elkin CPU Architecture:Any

[12 Oct 2006 12:28] Andrei Elkin
Description:
Manipulation with stop, flush logs, start slave can end up
with a new relay log that is empty, and the old logs deleted.
My expectation is to have upon the manipulations (below) the old, prior rotate event, log file closed and never deleted.

How to repeat:
reset master;
reset slave; start slave;

connection master;
set @@session.binlog_format=row;
create table t (a int);
insert values (1);

connection slave;

show slave status\G  # to see relay_log_pos upon rows applied
# check with 
mysqlbinlog relay-log.000002 ->  (the index may vary, adjust it) shows \        \ the events are in
stop slave sql_thread;
flush logs;
start slave sql_thread;

When slave is fully up 
  1 there will be no relay-log.000002, relay-log.000003
  2 the new log won't have the last log's event neither

Suggested fix:
Consider how rotate event is handled.
[12 Oct 2006 12:50] Andrei Elkin
To make it more dramatic i slightly change the conditions.

connection master;
create table t(a int);

connection slave;
stop slave sql_thead;

connection master;
insert into t values (1);

...
the rest remains, just exclude `stop slave sql_thread'.

Now upon `flush logs; start slave sql_thread' all what has been reported remains plus 
connection slave;
select * from t; # -> empty table

which means the insert got lost.
[14 Oct 2006 17:14] Andrei Elkin
Taking back for one more verification.