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

CREATE-SELECT may lose in binlog side-effects of stored-routine

Details

    • Bug
    • Status: Closed (View Workflow)
    • Critical
    • Resolution: Fixed
    • 11.5.2, 11.8
    • 11.8.2
    • Replication
    • None

    Description

      When the SELECT sub-statement executes a stored function that is defined
      to modify a non-transactional table any modified records that the function has succeeded
      on must be binlogged (as a "side effect" of CREATE-SELECT).
      This of course also applies to a failing CREATE-SELECT.
      Unfortunately MDEV-34150 fixes flawed this requirement through removing the cached modification before they get cached for eventual sinking into binlog.
      The mtr test fails at the diff line 34.

       --source include/have_binlog_format_row.inc
      --source include/have_innodb.inc
      --source include/master-slave.inc
      --source include/have_sequence.inc
       
      create table ti_pk (a int primary key) engine=innodb;
      insert into ti_pk set a=10;
       
       create table ta (a int) engine=myisam;
       delimiter |;
       create function f_ia(arg int)
       returns integer
       begin
         insert into ta set a=arg;
         insert into ti_pk set a=arg;
         return 1;
       end |
       delimiter ;|
       
       --let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1)
       --let $binlog_start = query_get_value(SHOW MASTER STATUS, Position, 1)
       
       --error ER_DUP_ENTRY
       create table error_table (a int) engine=myisam select f_ia(seq) as a from seq_1_to_10;
       --error ER_NO_SUCH_TABLE
       select * from error_table;
       
       --echo # correct execution: `ta` is modified and its new record is binlogged
       --source include/show_binlog_events.inc
       select count(*) from ta;
       select count(*) from ti_pk;
       
       --sync_slave_with_master
       # Fails happens here
       --let  $diff_tables=master:ta,slave:ta
       --source include/diff_tables.inc
       
       # Cleanup
       --connection master
       drop function f_ia;
       drop table ti_pk, ta;
       
       --echo End of the tests
       --source include/rpl_end.inc
      

      For fixing is enough to remove the added
      thd->binlog_remove_rows_events(); .
      Apparently it should not have been there, as proper emptying (either with reset for the transactional cache or flush and then reset for the statement cache) is (must be) always done via binlog_rollback of the top-level statement.

      Attachments

        Issue Links

          Activity

            Transition Time In Source Status Execution Times
            Andrei Elkin made transition -
            Open In Progress
            3h 37m 1
            Andrei Elkin made transition -
            In Progress In Review
            22s 1
            Andrei Elkin made transition -
            In Review Closed
            3d 19h 2m 1

            People

              monty Michael Widenius
              Elkin Andrei Elkin
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

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