← Back to team overview

maria-developers team mailing list archive

Re: fa8879bc800: MDEV-16370 row-based binlog events (updates by primary key) can not be applied multiple times to system versioned tables

 

Hi, Aleksey!

Looking at the patch and the test, I get the impression you're fixing
the wrong issue.

The problem in MDEV-16370 happened when replicating from
non-system-versioned table on the master to a system-versioned table on
the slave.

You don't have a test case for that. Your fix doesn't change the
behavior for this use case.

So, I don't understand what you've actually fixed.

On Nov 06, Aleksey Midenkov wrote:
> revision-id: fa8879bc800d2babf48d082ce8c50ffe520e12cc (versioning-1.0.5-140-gfa8879bc800)
> parent(s): 28ae79650d3057ffcd849d2ef28dcd80282c85d2
> author: Aleksey Midenkov <midenok@xxxxxxxxx>
> committer: Aleksey Midenkov <midenok@xxxxxxxxx>
> timestamp: 2018-09-20 10:04:57 +0300
> message:
> 
> MDEV-16370 row-based binlog events (updates by primary key) can not be applied multiple times to system versioned tables
> 
> Rows_log_event::write_row() always overwrite historical row.
> 
> diff --git a/mysql-test/suite/versioning/t/rpl.test b/mysql-test/suite/versioning/t/rpl.test
> index a9e3af45af8..1985b17bf6d 100644
> --- a/mysql-test/suite/versioning/t/rpl.test
> +++ b/mysql-test/suite/versioning/t/rpl.test
> @@ -133,4 +133,24 @@ sync_slave_with_master;
>  connection master;
>  drop table t1;
>  
> +--echo # MDEV-16370 row-based binlog events (updates by primary key)
> +--echo # can not be applied multiple times to system versioned tables
> +create or replace table t1 (pk int primary key, x int) with system versioning;
> +insert into t1 values (1, 1);
> +--sync_slave_with_master
> +flush logs;
> +--connection master
> +update t1 set x= 2;
> +--sync_slave_with_master
> +select * from t1;
> +--let $datadir= `select @@datadir`
> +--let $f2= query_get_value(SHOW SLAVE STATUS, Relay_Log_File, 1)
> +--echo # Replaying binlog...
> +--exec $MYSQL_BINLOG $datadir/$f2| $MYSQL -S $SLAVE_MYSOCK test
> +select * from t1;
> +--connection master
> +
> +drop database test;
> +create database test;
> +
>  --source include/rpl_end.inc
> diff --git a/sql/log_event.cc b/sql/log_event.cc
> index c550adea26b..c4c04743a30 100644
> --- a/sql/log_event.cc
> +++ b/sql/log_event.cc
> @@ -13139,13 +13139,26 @@ Rows_log_event::write_row(rpl_group_info *rgi,
>    }
>  
>    // Handle INSERT.
> -  if (table->versioned(VERS_TIMESTAMP))
> +  if (table->versioned())
>    {
> -    ulong sec_part;
> -    bitmap_set_bit(table->read_set, table->vers_start_field()->field_index);
> -    // Check whether a row came from unversioned table and fix vers fields.
> -    if (table->vers_start_field()->get_timestamp(&sec_part) == 0 && sec_part == 0)
> -      table->vers_update_fields();
> +    if (table->versioned(VERS_TIMESTAMP))
> +    {
> +      // Set vers fields when replicating from not system-versioned table.
> +      ulong sec_part;
> +      bitmap_set_bit(table->read_set, table->vers_start_field()->field_index);
> +      // Check whether a row came from unversioned table and fix vers fields.
> +      if (table->vers_start_field()->get_timestamp(&sec_part) == 0 && sec_part == 0)
> +        table->vers_update_fields();
> +      else
> +        goto overwrite_historical_row;
> +    }
> +    else
> +    {
> +overwrite_historical_row:
> +      bitmap_set_bit(table->read_set, table->vers_end_field()->field_index);
> +      if (!overwrite && !table->vers_end_field()->is_max())
> +        overwrite= true;
> +    }
>    }
Regards,
Sergei
Chief Architect MariaDB
and security@xxxxxxxxxxx