IB: skip sys_trx_start when comparing master and slave rows [closes #107]

This commit is contained in:
kevg 2016-12-26 18:46:02 +03:00 committed by Aleksey Midenkov
parent 4383e16cbe
commit abb2f9488d
5 changed files with 47 additions and 6 deletions

View file

@ -109,5 +109,18 @@ connection slave;
select * from t1;
x
connection master;
create or replace table t1 (a int) with system versioning engine = innodb;
insert into t1 values (1);
update t1 set a=2;
select * from t1 for system_time all;
a
2
1
connection slave;
select * from t1 for system_time all;
a
2
1
connection master;
drop table t1;
include/rpl_end.inc

View file

@ -109,5 +109,18 @@ connection slave;
select * from t1;
x
connection master;
create or replace table t1 (a int) with system versioning engine = innodb;
insert into t1 values (1);
update t1 set a=2;
select * from t1 for system_time all;
a
2
1
connection slave;
select * from t1 for system_time all;
a
2
1
connection master;
drop table t1;
include/rpl_end.inc

View file

@ -86,5 +86,16 @@ select * from t1 for system_time all;
sync_slave_with_master;
select * from t1;
# at this point in this particular test master and slave have different curr_trx_id
# and the same rows have different sys_trx_start
# slave should ignore sys_trx_start while searching for a record to update in a InnoDB table
connection master;
create or replace table t1 (a int) with system versioning engine = innodb;
insert into t1 values (1);
update t1 set a=2;
select * from t1 for system_time all;
sync_slave_with_master;
select * from t1 for system_time all;
connection master;
drop table t1;

View file

@ -12766,7 +12766,7 @@ uint8 Write_rows_log_event::get_trg_event_map()
Returns TRUE if different.
*/
static bool record_compare(TABLE *table, bool skip_sys_start)
static bool record_compare(TABLE *table)
{
bool result= FALSE;
/**
@ -12799,7 +12799,7 @@ static bool record_compare(TABLE *table, bool skip_sys_start)
/* Compare fields */
for (Field **ptr=table->field ; *ptr ; ptr++)
{
if (skip_sys_start && *ptr == table->vers_start_field())
if (table->versioned_by_engine() && *ptr == table->vers_start_field())
{
continue;
}
@ -12997,7 +12997,6 @@ int Rows_log_event::find_row(rpl_group_info *rgi)
prepare_record(table, m_width, FALSE);
error= unpack_current_row(rgi);
bool skip_sys_start= false;
if (table->versioned())
{
@ -13011,7 +13010,6 @@ int Rows_log_event::find_row(rpl_group_info *rgi)
bitmap_set_bit(table->write_set, sys_trx_end->field_index);
sys_trx_end->set_max();
table->vers_start_field()->set_notnull();
skip_sys_start= true;
}
}
@ -13190,7 +13188,7 @@ int Rows_log_event::find_row(rpl_group_info *rgi)
/* We use this to test that the correct key is used in test cases. */
DBUG_EXECUTE_IF("slave_crash_if_index_scan", abort(););
while (record_compare(table, skip_sys_start))
while (record_compare(table))
{
while ((error= table->file->ha_index_next(table->record[0])))
{
@ -13254,7 +13252,7 @@ int Rows_log_event::find_row(rpl_group_info *rgi)
goto end;
}
}
while (record_compare(table, skip_sys_start));
while (record_compare(table));
/*
Note: above record_compare will take into accout all record fields

View file

@ -1522,6 +1522,12 @@ public:
return s->versioned && !file->versioned();
}
bool versioned_by_engine() const
{
DBUG_ASSERT(file);
return s->versioned && file->versioned();
}
Field *vers_start_field() const
{
DBUG_ASSERT(s->versioned);