Commit f615a99d authored by Sujatha Sivakumar's avatar Sujatha Sivakumar

Bug#18432495:RBR REPLICATION SLAVE CRASHES WHEN DELETE

NON-EXISTS RECORDS

Problem:
========
In RBR replication, master deletes a record but the record
don't exist on slave. when slave tries to apply the
Delete_row_log_event from master, it will result in an
assert on slave.

Analysis:
========
This problem exists not only with Delete_rows event but also
with Update_rows event as well. Trying to update a non
existing row on the slave from the master will cause the
same assert.  This assert occurs only for the tables that
doesn't have primary keys and which basically require
sequential scan to be done to locate a record. This bug
occurs only with innodb engine not with myisam.

When update or delete rows is executed on a slave on a table
which doesn't have primary key the updated record is stored
in a buffer named table->record[0] and the same is copied to
table->record[1] so that during sequential scan
table->record[0] can reloaded with fetched data from the
table and compared against table->record[1].  In a special
case where there is no record on the slave side scan will
result in EOF in that case we reinit the scan and we try to
compare record[0]  with record[1] which are basically the
same. This comparison is incorrect. Since they both are the
same record_compare() will report that record is found and
we try to go ahead and try to update/delete non existing
row. Ideally if the scan results in EOF means no data found
hence no need to do a record_compare() at all.

Fix:
===
Avoid comparision of records on EOF.
parent ada5a9a2
...@@ -9962,6 +9962,7 @@ int Rows_log_event::find_row(const Relay_log_info *rli) ...@@ -9962,6 +9962,7 @@ int Rows_log_event::find_row(const Relay_log_info *rli)
table->file->print_error(error, MYF(0)); table->file->print_error(error, MYF(0));
goto err; goto err;
} }
goto restart_rnd_next;
} }
break; break;
......
/* Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved. /* Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
...@@ -2479,6 +2479,7 @@ int Old_rows_log_event::find_row(const Relay_log_info *rli) ...@@ -2479,6 +2479,7 @@ int Old_rows_log_event::find_row(const Relay_log_info *rli)
table->file->print_error(error, MYF(0)); table->file->print_error(error, MYF(0));
DBUG_RETURN(error); DBUG_RETURN(error);
} }
goto restart_rnd_next;
} }
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment