1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

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; select * from t1;
x x
connection master; 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; drop table t1;
include/rpl_end.inc include/rpl_end.inc

View File

@@ -109,5 +109,18 @@ connection slave;
select * from t1; select * from t1;
x x
connection master; 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; drop table t1;
include/rpl_end.inc include/rpl_end.inc

View File

@@ -86,5 +86,16 @@ select * from t1 for system_time all;
sync_slave_with_master; sync_slave_with_master;
select * from t1; 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; connection master;
drop table t1; drop table t1;

View File

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

View File

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