Percona Server with XtraDB

Fake changes transactions are binlogged

Reported by Laurynas Biveinis on 2013-06-13
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Percona Server
Status tracked in 5.6
5.1
High
Laurynas Biveinis
5.5
High
Laurynas Biveinis
5.6
High
Laurynas Biveinis

Bug Description

At least some of the fake changes transactions are binlogged, if binlog is enabled. This poses data corruption issues with with deeper replication topologies.

Repeated by running https://github.com/facebook/mysql-5.6/blob/mysql-5.6.11/mysql-test/suite/rpl/t/rpl_percona_fake_changes.test (see bug 1188162) and observing that master binlog position advanced after the fake changes workload.

tags: added: fake-changes xtradb

It seems (have to confirm still) that Facebook solved this in day zero code import [1] by adding the following to ha_commit_trans(). For some reason we didn't fix it then.

    else if (is_real_trans && !trans->no_2pc && (rw_ha_count == 1))
    {
      /* When innodb_fake_changes is enabled for a transaction and that transaction
      changes no InnoDB rows then the InnoDB handlerton is marked as read-only and
      does not participate in 2 phase commit above. So InnoDB won't be able to
      raise an error during commit and the transaction would be written to the
      binlog. This code prevents that. */

      Ha_trx_info *ha;
      for (ha= ha_info_orig; ha; ha= ha->next())
      {
        handlerton *ht= ha->ht();
        if (ht->is_fake_change && ht->is_fake_change(ht, thd))
        {
          thd_reset_diagnostics(thd); /* avoid debug assertion */
          ha_rollback_trans(thd, all);
          my_error(ER_ERROR_DURING_COMMIT, MYF(0), HA_ERR_WRONG_COMMAND);
          error= 1;
          goto end;
        }
      }
    }

[1]

facebook-5.1$ bzr log -r 3763
------------------------------------------------------------
revno: 3763
committer: Mark Callaghan <email address hidden>
branch nick: 51fb
timestamp: Tue 2012-01-03 10:03:20 -0800
message:
  Port innodb_fake_changes.patch from Percona

  This adds a session parameter, innodb_fake_changes, that prevents
  rows from being locked and modified when set. It can be used to prefetch
  transactions. When set COMMIT and auto-commit statements will return an
  error. Non auto-commit statements are not foced to fail with this set.
  Binlog events are not written for a session when this is set for changes
  to InnoDB tables. All bets are off if a session mixes changes to MyISAM
  and InnoDB.

  The patch is at
  http://bazaar.launchpad.net/~percona-dev/percona-server/5.1/view/head:/patches/innodb_fake_changes.patch

I am testing an alternative fix to the Mark's fix above:

1) Currently innobase_xa_prepare is returning early with success if fake changes enabled. I think it should return early with failure instead.
2) Then, if 2PC is in use, ha_commit_trans() will simply DTRT and not binlog the transaction.
3) But 2PC might be not in use due to the fake changes handlerton not being marked as RW, as noted by Mark's patch too. Thus, add a small loop before that iterates over transaction handlertons and bumps rw_ha_count for each fake changes handlerton.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers