I'm looking at moving my production systems from Statement Based Replication
to Row Based Replication
, but in my testing I am finding it very difficult to locate problems in the binary logs.
For example. I run a query like:
UPDATE tablename SET updateTime = NOW() where customerid = 100;
This statement updates 1000 rows. However on the slave I have removed one, so replication breaks and I get:
[ERROR] Slave SQL: Could not execute Update_rows event on table dbname.tablename;
Can't find record in 'tablename', Error_code: 1032;
handler error HA_ERR_KEY_NOT_FOUND; the event's master log dbmaster.010915, end_log_pos 82982844, Error_code: 1032
I then run mysqlbinlog against the binary log, and search for 82982844
.
I find that in a long list like:
#161201 3:05:05 server id 21 end_log_pos 82977769 Table_map: `dbname`.`tablename` mapped to number 269238158
#161201 3:05:05 server id 21 end_log_pos 82978768 Update_rows: table id 269238158
#161201 3:05:05 server id 21 end_log_pos 82979752 Update_rows: table id 269238158
#161201 3:05:05 server id 21 end_log_pos 82980784 Update_rows: table id 269238158
#161201 3:05:05 server id 21 end_log_pos 82981808 Update_rows: table id 269238158
#161201 3:05:05 server id 21 end_log_pos 82982844 Update_rows: table id 269238158
#161201 3:05:05 server id 21 end_log_pos 82983872 Update_rows: table id 269238158
#161201 3:05:05 server id 21 end_log_pos 82984904 Update_rows: table id 269238158
which is followed by a whole load of:
### UPDATE `dbname`.`tablename`
### WHERE
### @1=1
### @2=2
### @3=3
### @4=4
### @5='abcdef'
### @6=2016-12-01 09:00:16
### SET
### @1=1
### @2=2
### @3=3
### @4=4
### @5='abcdef'
### @6=2016-12-01 10:01:08
Bear in mind that there is apx 1000 entries in the first section, and apx 1000 entries in the second section, how do I identify which row was missing?
Is there perhaps a better tool than mysqlbinlog to help in these situations?