Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-36892

Data Loss Replicating Persistent Fields if Slave Has Different Function

    XMLWordPrintable

Details

    • Bug
    • Status: Stalled (View Workflow)
    • Major
    • Resolution: Unresolved
    • 11.4, 11.8, 12.0(EOL)
    • 11.4, 11.8
    • Replication
    • None

    Description

      Since 11.2 (MDEV-29021), data can be lost when replicating tables with persistent generated columns if the replica uses a different function to generate the value. That is, the value written into the binary log in the row event is discarded, and the value is re-calculated based on the function on the replica. See the following test case and result:

      --source include/have_innodb.inc
      --source include/have_binlog_format_row.inc
      --source include/master-slave.inc
       
      --echo #
      --echo # Setup the initial table
      --connection master
      create table t1 (a int, b int as (a+100) persistent);
      --source include/save_master_gtid.inc
      --connection slave
      --source include/sync_with_master_gtid.inc
       
      --echo #
      --echo # Change the generation function on the replica
      --connection slave
      set statement sql_log_bin=0 for alter ignore table t1 drop b, add b int as (a*2) persistent;
       
      --echo #
      --echo # Insert rows
      --connection master
      insert into t1 values (1, default);
      insert into t1 values (2, default);
      --source include/save_master_gtid.inc
      --connection slave
      --source include/sync_with_master_gtid.inc
       
      --echo #
      --echo # Replication diverges
      --connection master
      select * from t1;
      --connection slave
      select * from t1;
       
      --echo #
      --echo # Cleanup
      --connection master
      drop table t1;
      --source include/save_master_gtid.inc
      --connection slave
      --source include/sync_with_master_gtid.inc
      --source include/rpl_end.inc
      

      include/master-slave.inc
      [connection master]
      #
      # Setup the initial table
      connection master;
      create table t1 (a int, b int as (a+100) persistent);
      include/save_master_gtid.inc
      connection slave;
      include/sync_with_master_gtid.inc
      #
      # Change the generation function on the replica
      connection slave;
      set statement sql_log_bin=0 for alter ignore table t1 drop b, add b int as (a*2) persistent;
      #
      # Insert rows
      connection master;
      insert into t1 values (1, default);
      insert into t1 values (2, default);
      include/save_master_gtid.inc
      connection slave;
      include/sync_with_master_gtid.inc
      #
      # Replication diverges
      connection master;
      select * from t1;
      a	b
      1	101
      2	102
      connection slave;
      select * from t1;
      a	b
      1	2
      2	4
      #
      # Cleanup
      connection master;
      drop table t1;
      include/save_master_gtid.inc
      connection slave;
      include/sync_with_master_gtid.inc
      include/rpl_end.inc
      

      Attachments

        Issue Links

          Activity

            People

              bnestere Brandon Nesterenko
              bnestere Brandon Nesterenko
              Brandon Nesterenko Brandon Nesterenko
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.