Skip to content

Commit

Permalink
Fix issue percona#18: slave crash on update with row based binary log…
Browse files Browse the repository at this point in the history
…ging

Summary:
ha_rocksdb::position() should not return rowid of the last read row,
it should get the rowid of the record passed as parameter.

Differential Revision: https://reviews.facebook.net/D31983

fbshipit-source-id: 0d43d66ad06
  • Loading branch information
spetrunia authored and facebook-github-bot committed Mar 8, 2021
1 parent a2a8506 commit c7e2cef
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
15 changes: 15 additions & 0 deletions mysql-test/suite/rocksdb/rpl_row_rocksdb.result
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,19 @@ pk
2
3
drop table t1;
#
# Issue #18: slave crash on update with row based binary logging
#
create table t1 (id int primary key, value int, value2 int, index(value)) engine=rocksdb;
insert into t1 values (1,1,1);
insert into t1 values (2,1,1);
insert into t1 values (3,1,1);
insert into t1 values (4,1,1);
insert into t1 values (5,1,1);
update t1 set value2=100 where id=1;
include/sync_slave_sql_with_master.inc
select * from t1 where id=1;
id value value2
1 1 100
drop table t1;
include/rpl_end.inc
18 changes: 18 additions & 0 deletions mysql-test/suite/rocksdb/rpl_row_rocksdb.test
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,23 @@ select * from t1;
connection master;
drop table t1;

--echo #
--echo # Issue #18: slave crash on update with row based binary logging
--echo #
create table t1 (id int primary key, value int, value2 int, index(value)) engine=rocksdb;
insert into t1 values (1,1,1);
insert into t1 values (2,1,1);
insert into t1 values (3,1,1);
insert into t1 values (4,1,1);
insert into t1 values (5,1,1);
update t1 set value2=100 where id=1;

--source include/sync_slave_sql_with_master.inc
connection slave;
select * from t1 where id=1;

connection master;
drop table t1;

--source include/rpl_end.inc

10 changes: 8 additions & 2 deletions storage/rocksdb/ha_rocksdb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3271,8 +3271,14 @@ int ha_rocksdb::info(uint flag)
void ha_rocksdb::position(const uchar *record)
{
DBUG_ENTER("ha_rocksdb::position");

memcpy(ref, last_rowkey.ptr(), ref_length);
/*
Get packed primary key value from the record.
(Note: last_rowkey has the packed PK of last-read-row, which allows to
handle most cases, but there is an exception to this: when slave applies
RBR events, it fills the record and then calls position(); rnd_pos())
*/
pk_descr->pack_record(table, pack_buffer, record, ref,
NULL, NULL);
DBUG_VOID_RETURN;
}

Expand Down

0 comments on commit c7e2cef

Please sign in to comment.